I am using overridePendingTransition
method to perform custom Activity animations.
I would like to know when the animation ends ( a callback/listener ).
Is there any direct way of achieving this, if not please suggest me some work around.
I use this method to start any animation (resID of the animation XML). If nextPuzzleOnEnd is true, the method "nextPuzzle" is called when the animation has finished.
The method is part of my puzzle-apps and I use it to display any success animation and afterwards (after anim has finished) continue with the next puzzle.
/*
* start animation (any view)
*/
private void startAnimation(View v, int resId, Boolean nextPuzzleOnEnd){
Animation anim;
if(v!=null){ // can be null, after change of orientation
anim = AnimationUtils.loadAnimation(this.getContext(),resId);
anim.setFillAfter(false);
v.setAnimation(anim);
if( nextPuzzleOnEnd ){
anim.setAnimationListener(new AnimationListener() {
public void onAnimationStart(Animation anim)
{
};
public void onAnimationRepeat(Animation anim)
{
};
public void onAnimationEnd(Animation anim)
{
nextPuzzle();
};
});
}
v.startAnimation(anim);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With