Is there some reason that I cannot call .cancel() on the Animator provided in an animation listener?
When I execute the following code I get a StackOverflowError:
animation.addListener(new ValueAnimator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
if (!showCircles)
animator.cancel();
}
....
I discovered a solution.
I found that you must call
animator.removeAllListeners();, before callinganimator.cancel();. (This is true for most all 4.0+ devices, but on the GSIII, for some reason, you do not need to.)For some reason, the
cancel()command was causingonAnimationStartto be triggered again (ending up in an infinite loop).