Closed GuilhE closed 4 years ago
Same problem. @GuilhE Is annotation processing enabled? I think the better solution is to migrate to upgraded https://developer.android.com/reference/android/arch/lifecycle/DefaultLifecycleObserver
I've tested and this function is being called:
private class ProgressButtonHolder(private val textView: WeakReference<TextView>) :
LifecycleObserver {
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
fun onDestroy() {
textView.get()?.let {
it.cancelAnimations()
it.cleanUpDrawable()
it.removeTextAnimationAttachViewListener()
it.removeDrawableAttachViewListener()
attachedViews.remove(it)
}
}
}
The only way I'm getting rid of this leaks is by making sure I'm calling:
bindProgressButton(binding.submitMaterialButton)
and
override fun onDestroy() {
binding.submitMaterialButton.cleanUpDrawable()
super.onDestroy()
}
@razir any thoughts on this?
I've found the problem and it was mine, really hard to catch involving removeObservers(), etc. But I think your suggestion is good and I'll create a PR regarding Google doc:
If you use Java 8 language, always prefer it over annotations.
Output from LeakCanary:
Any clue?