-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
07e8505
commit 744f912
Showing
9 changed files
with
105 additions
and
63 deletions.
There are no files selected for viewing
26 changes: 0 additions & 26 deletions
26
app/src/androidTest/java/com/yy/mobile/rollingtext/ExampleInstrumentedTest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
app/src/test/java/com/yy/mobile/rollingtext/ExampleUnitTest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...ngtextview/src/main/java/com/yy/mobile/rollingtextview/strategy/AlignAnimationStrategy.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.yy.mobile.rollingtextview.strategy | ||
|
||
import com.yy.mobile.rollingtextview.TextManager | ||
|
||
/** | ||
* Created by 张宇 on 2019/4/29. | ||
* E-mail: [email protected] | ||
* YY: 909017428 | ||
*/ | ||
@Suppress("MemberVisibilityCanBePrivate") | ||
open class AlignAnimationStrategy(val alignment: TextAlignment) : NormalAnimationStrategy() { | ||
|
||
override fun findCharOrder( | ||
sourceText: CharSequence, | ||
targetText: CharSequence, | ||
index: Int, | ||
charPool: CharPool | ||
): Pair<List<Char>, Direction> { | ||
val maxLen = Math.max(sourceText.length, targetText.length) | ||
var srcChar = TextManager.EMPTY | ||
var tgtChar = TextManager.EMPTY | ||
|
||
val srcRange = getTextRange(sourceText, maxLen) | ||
val tgtRange = getTextRange(targetText, maxLen) | ||
if (index in srcRange) { | ||
srcChar = sourceText[index - srcRange.first] | ||
} | ||
if (index in tgtRange) { | ||
tgtChar = targetText[index - tgtRange.first] | ||
} | ||
|
||
return findCharOrder(srcChar, tgtChar, index, charPool) | ||
} | ||
|
||
private fun getTextRange(text: CharSequence, maxLen: Int): IntRange { | ||
val from: Int = when (alignment) { | ||
TextAlignment.Left -> 0 | ||
TextAlignment.Center -> Math.round((maxLen - text.length) / 2f) | ||
TextAlignment.Right -> maxLen - text.length | ||
} | ||
val to: Int = from + text.length | ||
return from until to | ||
} | ||
|
||
enum class TextAlignment { | ||
Left, Right, Center | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import com.yy.mobile.rollingtextview.PreviousProgress | |
* E-mail: [email protected] | ||
* YY: 909017428 | ||
*/ | ||
@Suppress("MemberVisibilityCanBePrivate") | ||
class StickyStrategy(val factor: Double) : NormalAnimationStrategy() { | ||
|
||
init { | ||
|