1

I need to check when the progressbar animation is done.
Then i need to do something.

I already have this:

private ObjectAnimator progressAnimator;

mProgressBar = (ProgressBar)findViewById(R.id.progressbar);
mProgressBar.setMax(1000);
progressAnimator = ObjectAnimator.ofInt(mProgressBar, "progress", 1000, 0);
progressAnimator.setDuration(10000);
progressAnimator.start();

How to check if this animation is done??

  • [How do I do something when an animation finishes?](http://stackoverflow.com/questions/7274001/how-do-i-do-something-when-an-animation-finishes) – Rick S Mar 30 '17 at 14:50
  • thanks but could someone give me an example inside my code? –  Mar 30 '17 at 14:52

2 Answers2

3

Use addListener() method:

     progressAnimator.addListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {   
            }
            @Override
            public void onAnimationEnd(Animator animation) {
               //here animation finished
            }

            @Override
            public void onAnimationCancel(Animator animation) {
            }

            @Override
            public void onAnimationRepeat(Animator animation) {
            }
        });
John
  • 1,304
  • 1
  • 9
  • 17
0

You can use:

if(progressAnimator.isRunning()){
    //Code here
}
Pozzo Apps
  • 1,859
  • 2
  • 22
  • 32
Onur Çeker
  • 133
  • 2
  • 9