@@ -7,6 +7,7 @@ import android.util.AttributeSet
77import android.view.View
88import android.view.animation.LinearInterpolator
99import androidx.annotation.ColorInt
10+ import androidx.annotation.ColorRes
1011import androidx.annotation.FloatRange
1112import androidx.core.animation.addListener
1213import androidx.core.content.ContextCompat
@@ -94,7 +95,7 @@ class TiledProgressView @JvmOverloads constructor(
9495 )
9596 }
9697
97- fun setProgress (@FloatRange(from = 0.0 , to = 1 .0 ) progressValue : Float ) {
98+ fun setProgress (@FloatRange(from = 0.0 , to = 100 .0 ) progressValue : Float ) {
9899 progressAnimator.setFloatValues(currentProgressValue, progressValue)
99100 progressAnimator.start()
100101 currentProgressValue = progressValue
@@ -105,6 +106,21 @@ class TiledProgressView @JvmOverloads constructor(
105106 invalidate()
106107 }
107108
109+ fun setLoadingColorRes (@ColorRes progressColorRes : Int ) {
110+ foregroundProgressPaint.color = ContextCompat .getColor(context, progressColorRes)
111+ invalidate()
112+ }
113+
114+ fun setColor (@ColorInt color : Int ) {
115+ backgroundProgressPaint.color = color
116+ invalidate()
117+ }
118+
119+ fun setColorRes (@ColorRes colorRes : Int ) {
120+ backgroundProgressPaint.color = ContextCompat .getColor(context, colorRes)
121+ invalidate()
122+ }
123+
108124 private fun initializeProgressRectFs () {
109125 if (viewRect.isEmpty) return
110126 backgroundProgressRect.set(viewRect)
@@ -179,7 +195,7 @@ class TiledProgressView @JvmOverloads constructor(
179195 val min = foregroundProgressRectMin.width()
180196 val max = foregroundProgressRectMax.width()
181197 val maxProgress = max - min
182- val currentProgress = maxProgress * animatedValue
198+ val currentProgress = maxProgress * animatedValue / 100f
183199 foregroundProgressRectCurrent.right =
184200 foregroundProgressRectCurrent.left +
185201 (foregroundProgressRadius * 2f ) +
0 commit comments