mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 20:06:51 +03:00
Fixing missing cancel on infinite ObjectAnimators
This commit is contained in:
parent
050c23b578
commit
fbd1009ebc
1 changed files with 6 additions and 3 deletions
|
@ -42,6 +42,7 @@ class TypingMessageDotsView(context: Context, attrs: AttributeSet) :
|
|||
}
|
||||
|
||||
private val circles = mutableListOf<View>()
|
||||
private val objectAnimators = mutableListOf<ObjectAnimator>()
|
||||
|
||||
init {
|
||||
orientation = HORIZONTAL
|
||||
|
@ -76,15 +77,17 @@ class TypingMessageDotsView(context: Context, attrs: AttributeSet) :
|
|||
}
|
||||
|
||||
private fun animateCircle(index: Int, circle: View) {
|
||||
ObjectAnimator.ofFloat(circle, "alpha", DEFAULT_MAX_ALPHA, DEFAULT_MIN_ALPHA).apply {
|
||||
val objectAnimator = ObjectAnimator.ofFloat(circle, "alpha", DEFAULT_MAX_ALPHA, DEFAULT_MIN_ALPHA).apply {
|
||||
duration = DEFAULT_CIRCLE_DURATION
|
||||
startDelay = DEFAULT_START_ANIM_CIRCLE_DURATION * index
|
||||
repeatCount = ValueAnimator.INFINITE
|
||||
}.start()
|
||||
}
|
||||
objectAnimators.add(objectAnimator)
|
||||
objectAnimator.start()
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
circles.forEach { it.clearAnimation() }
|
||||
objectAnimators.forEach { it.cancel() }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue