so I have an AnimationDrawable to move a character one space on the screen. The animation works fine, but I need to stall out the rest of the GUI from refreshing the screen. Basically when the map moves, the game has to refresh the screen to update the new location. The code for the redraw is inside of the game class, and the animation is in the image adapter for the gridview that displays the actual game board. Here's the two lines of code that are trouble.
playerAdapter.animateLeft();
redraw();
The first line calls the adapter which has the two animations that need to happen, both take 700ms. Then, redraw updates the board itself. The problem is, redraw doesn't wait for the animations. I've tried using sleep and stuff like that but that just pauses the whole damn thing and nothing happens. I think I need to use Threads or Handlers but I'm unsure how that works. Any ideas? All help is much appreciated :)
Another interesting solution:
Try:
EDIT: Oops. Didn't read the drawable part. Here's a recursive function I use to check if all frames are over:
You could also log the time when you start the animation, and add the duration (which you know before hand) to it to get the ending time. However, this can be inaccurate, as setting and starting the animation takes a bit of time as well.