-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
The following Magellan code would lead to a persisted Context reference:
override fun onShow(context: Context, binding: LoadingSectionBinding) {
...
blend {
immediate()
target(placeholderViews).animations {
alpha(minAlpha)
}
}.then {
stagger(subjects = placeholderViews, timeBetweenTargets = staggerStepMillis, timeUnit = MILLISECONDS) { currentView ->
duration(time = pulseDurationMillis, timeUnit = MILLISECONDS)
repeat(count = INFINITE, mode = REVERSE)
target(currentView).animations {
alpha(maxAlpha)
}
}
}.start()
}
override fun onHide(context: Context, binding: LoadingSectionBinding) {
...
blend.stopPulsing(*placeholderViews.toTypedArray())
}
Avoiding the use of Blend's wrapper and using the Android animator directly fixes the leak:
override fun onShow(context: Context, binding: LoadingSectionBinding) {
...
animator = blend {
immediate()
target(placeholderViews).animations {
alpha(minAlpha)
}
}.then {
stagger(subjects = placeholderViews, timeBetweenTargets = staggerStepMillis, timeUnit = MILLISECONDS) { currentView ->
duration(time = pulseDurationMillis, timeUnit = MILLISECONDS)
repeat(count = INFINITE, mode = REVERSE)
target(currentView).animations {
alpha(maxAlpha)
}
}
}.prepare()
animator!!.start()
}
override fun onHide(context: Context, binding: LoadingSectionBinding) {
animator!!.cancel()
animator = null
}
Metadata
Metadata
Assignees
Labels
No labels