I made an endless ValueAnimatorone that contains a link to the view (and of course the view contains a link to Context), and the log shows that it does not stop when the view is (presumably) destroyed.
ValueAnimator anim = ValueAnimator.ofFloat(0, 1);
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationRepeat(Animator animation) {
myView.setText(...);
Log.d("my_tag", "I am still running and repeating");
}
});
anim.setRepeatCount(ValueAnimator.INFINITE);
anim.start();
Of course, I can make it not hold the (strong) link by retrieving the listener as a static inner class and holding it instead WeakReference. However, my question is that in the case of a final animator (e.g. anim.setRepeatCount(3)) that stops for a certain amount of time, will this also cause a memory leak after the animation ends? (So I need to do the same weak reference strategy)?
source
share