0

I have been trying to make something happen after an AnimatedVectorDrawable is done animating and I was looking at the answer to this question regarding the AVDWrapper, but I have a gut feeling that there is a more elegant way.

Namely, setting a boolean change listener to check if anim.isRunning() has changed. I have been following this question and it's answers and have set up a boolean change listener (pretty much exactly the same way and setBoo to anim.isRunning()) but it's not working. Am I understanding something conceptually wrong here? The observer pattern should trigger at the end of the animation when anim.isRunning() changes from true to false. Or is it because an animation is time sensitive/continuous and needs to be continuously polled, therefore this won't work? How about if the listener implements Runnable?

Thank you.

Community
  • 1
  • 1
skwear
  • 563
  • 1
  • 5
  • 24
  • tried to override `registerAnimationCallback`? – pskink Nov 16 '16 at 02:16
  • I'm looking at it right now, but I'm not sure how I would go about it without an example. But I'm guessing the callback calls back to the boolean listener? – skwear Nov 16 '16 at 02:23
  • sorry not override (when writing i was thinking about different post), just call it with a custom callback – pskink Nov 16 '16 at 02:24
  • I see, I'll try it. I'm actually using the support library that allows `AnimatedVectorDrawables` to be used with lower APIs. Would this break the compatability? – skwear Nov 16 '16 at 02:26

1 Answers1

2

Use a custom Animatable2.AnimationCallback and call anim.registerAnimationCallback().

Larry Schiefer
  • 15,687
  • 2
  • 27
  • 33