I'm trying to play a sequence of more than 1 animations on the same progress bar. I am actually using a library called AnimateHorizontalProgressBar which allows the progress bars to fill up with an animation. The bar is an experience bar in a game, and if the player gets enough experience at one time, I want the bar to fill up as many times as there are level ups. (e.g. a level 1 character going to level 3 would have their experience bar fill up 2 full times, resetting whenever it gets full, then once more for however much progress they made from level 3 to level 4)
The solution I tried was to set an AnimateProgressListener on the AnimateHorizontalProgressBar, and in the onAnimationEnd function, to call the next animation to be played. The list containing these animations is an arraylist of custom POJOs which hold a reference to the view (the progress bar), and the percent to set it to.
bar.setAnimateProgressListener(new AnimateHorizontalProgressBar.AnimateProgressListener() {
@Override
public void onAnimationStart(int progress, int max) { }
@Override
public void onAnimationEnd(int progress, int max) {
if (animNumber < animationList.size() - 1){
animNumber++;
animationList.get(animNumber).getXpBar().setProgressWithAnim(animationList.get(animNumber).getProgressPercent()); // this not getting called
}
}
});
animationList.get(0).getXpBar().setProgressWithAnim(animationList.get(0).getProgressPercent());
The problem is that after the first animation which I start explicitly, it runs the onAnimationEnd function, and hits the line to run the next animation, but it never starts. The onAnimationStart function is never even called for the 2nd animation. Any ideas on why this might be?
from Play sequence of animations on one view from onAnimationEnd
No comments:
Post a Comment