I have an view property animator and when i update controller with new data, animator is recreated.
`
@EpoxyModelClass(layout = R.layout.item)
abstract class MyEpoxyModel :
ViewBindingEpoxyModelWithHolder() {
// other fields
var breatheAnimator: Animator? = null
var isAnimateRunning = false
override fun MyBinding.bind() {
// other binding
maybeCreateAnimator(button)
maybeStartAnimator()
}
private fun maybeCreateAnimator(view: View) {
if (breatheAnimator == null) { // always null
breatheAnimator = BreathInOutFactory().create(view, BREATHE_ANIMATION_DURATION)
}
}
private fun maybeStartAnimator() {
if (breatheAnimator == null) return
if (!isAnimateRunning) {
isAnimateRunning = true
breatheAnimator?.start()
}
}
override fun unbind(holder: ViewBindingHolder) {
breatheAnimator?.cancel()
isAnimateRunning = false
super.unbind(holder)
}
companion object {
const val BREATHE_ANIMATION_DURATION = 800L
}`
How can i keep animator from recreating and save animator state?
I have an view property animator and when i update controller with new data, animator is recreated. ` @EpoxyModelClass(layout = R.layout.item) abstract class MyEpoxyModel : ViewBindingEpoxyModelWithHolder() {
}`
How can i keep animator from recreating and save animator state?