Skip to content

Commit

Permalink
Merge pull request #29 from ebayraktar/feature/rename-attributes
Browse files Browse the repository at this point in the history
Rename attributes on FadingTextView #27
  • Loading branch information
rosenpin authored Dec 28, 2023
2 parents 57fcd6c + 92300ad commit a2058a6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions app/src/main/res/layout/content_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
app:texts="@array/examples"
app:shuffle="true"
app:timeout="500" />
app:fadingTextViewTexts="@array/examples"
app:fadingTextViewShuffle="true"
app:fadingTextViewTimeout="500" />

<org.adw.library.widgets.discreteseekbar.DiscreteSeekBar
android:id="@+id/timeout_bar"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,20 @@ class FadingTextView @JvmOverloads constructor(
val typedArray =
context.obtainStyledAttributes(attributeSet, R.styleable.FadingTextView)

typedArray.getTextArray(R.styleable.FadingTextView_texts)?.let { textArray ->
typedArray.getTextArray(R.styleable.FadingTextView_fadingTextViewTexts)?.let { textArray ->
texts = textArray
}

val baseTimeout = typedArray.getInteger(
R.styleable.FadingTextView_timeout,
R.styleable.FadingTextView_fadingTextViewTimeout,
DEFAULT_TIME_OUT.toInt(DurationUnit.MILLISECONDS)
).milliseconds
val animationDuration =
resources.getInteger(android.R.integer.config_longAnimTime).milliseconds

timeout = baseTimeout + animationDuration

typedArray.getBoolean(R.styleable.FadingTextView_shuffle, false).also { shouldShuffle ->
typedArray.getBoolean(R.styleable.FadingTextView_fadingTextViewShuffle, false).also { shouldShuffle ->
if (shouldShuffle) {
shuffle()
}
Expand Down Expand Up @@ -193,6 +193,7 @@ class FadingTextView @JvmOverloads constructor(
* Sets the length of time to wait between text changes in specific time units
*
* @param timeout The duration to wait between text changes
* @throws IllegalArgumentException if the duration is not positive.
*/
fun setTimeout(timeout: Duration) {
require(timeout.isPositive()) { "Timeout must be longer than 0" }
Expand Down
6 changes: 3 additions & 3 deletions fadingtextview/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="FadingTextView">
<attr name="texts" format="reference" />
<attr name="timeout" format="integer"/>
<attr name="shuffle" format="boolean" />
<attr name="fadingTextViewTexts" format="reference" />
<attr name="fadingTextViewTimeout" format="integer"/>
<attr name="fadingTextViewShuffle" format="boolean" />
</declare-styleable>
</resources>

0 comments on commit a2058a6

Please sign in to comment.