mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-17 19:29:02 +00:00
Merge pull request #1853 from booker-lee/1842-fix-hp-under-1
Fix hp display when value is under 1 #1842
This commit is contained in:
commit
5d9f2d4b5f
1 changed files with 7 additions and 2 deletions
|
|
@ -184,11 +184,16 @@ class ValueBar(context: Context, attrs: AttributeSet?) : FrameLayout(context, at
|
|||
if (animationDuration == 0L || binding.valueTextView.text.isEmpty()) {
|
||||
currentValue = value
|
||||
} else {
|
||||
val animator = ValueAnimator.ofInt(currentValue.toInt(), value.toInt())
|
||||
val animator = if (0 < value && value < 1) {
|
||||
// Show floating points in animation only if the value is between 0 to 1
|
||||
ValueAnimator.ofFloat(currentValue.toFloat(), value.toFloat())
|
||||
} else {
|
||||
ValueAnimator.ofInt(currentValue.toInt(), value.toInt())
|
||||
}
|
||||
animator.duration = animationDuration
|
||||
animator.startDelay = animationDelay
|
||||
animator.addUpdateListener {
|
||||
currentValue = (it.animatedValue as Int).toDouble()
|
||||
currentValue = (it.animatedValue as? Int)?.toDouble() ?: (it.animatedValue as Float).toDouble()
|
||||
updateBar()
|
||||
}
|
||||
animator.start()
|
||||
|
|
|
|||
Loading…
Reference in a new issue