mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-23 04:28:35 +00:00
Fix spoiler animation running after view is returned to cache.
This commit is contained in:
committed by
Greyson Parrelli
parent
36ef36be61
commit
a35a167e7a
@@ -5,6 +5,8 @@ import android.graphics.Canvas
|
||||
import android.text.Annotation
|
||||
import android.text.Layout
|
||||
import android.text.Spanned
|
||||
import android.view.View
|
||||
import android.view.View.OnAttachStateChangeListener
|
||||
import android.view.animation.LinearInterpolator
|
||||
import android.widget.TextView
|
||||
import org.thoughtcrime.securesms.components.spoiler.SpoilerAnnotation.SpoilerClickableSpan
|
||||
@@ -42,6 +44,11 @@ class SpoilerRendererDelegate @JvmOverloads constructor(private val view: TextVi
|
||||
spoilerDrawable = SpoilerDrawable(textColor)
|
||||
single = SingleLineSpoilerRenderer(spoilerDrawable)
|
||||
multi = MultiLineSpoilerRenderer(spoilerDrawable)
|
||||
|
||||
view.addOnAttachStateChangeListener(object : OnAttachStateChangeListener {
|
||||
override fun onViewDetachedFromWindow(v: View) = stopAnimating()
|
||||
override fun onViewAttachedToWindow(v: View) = Unit
|
||||
})
|
||||
}
|
||||
|
||||
fun updateFromTextColor() {
|
||||
@@ -90,11 +97,15 @@ class SpoilerRendererDelegate @JvmOverloads constructor(private val view: TextVi
|
||||
animatorRunning = true
|
||||
}
|
||||
} else {
|
||||
animator.pause()
|
||||
animatorRunning = false
|
||||
stopAnimating()
|
||||
}
|
||||
}
|
||||
|
||||
private fun stopAnimating() {
|
||||
animator.pause()
|
||||
animatorRunning = false
|
||||
}
|
||||
|
||||
private inline fun <V> MutableMap<Int, V>.getFromCache(vararg keys: Any, default: () -> V): V {
|
||||
if (renderForComposing) {
|
||||
return default()
|
||||
|
||||
Reference in New Issue
Block a user