title: How to stop an animation (from ObjectAnimator)
body: <p>Below is the code belonging to my activity where I have a button (someButton) which, when clicked, starts an animation on another view, more specifically, a progressbar view, on that same activity:</p>
  
  <pre><code>// [...]
  someButton.setOnClickListener(new OnClickListener() {
      public void onClick(View v) {
          ObjectAnimator animation = ObjectAnimator.ofInt(progressView, "progress", 0, 2000);
          animation.setDuration(2000);
          animation.setInterpolator(new DecelerateInterpolator());
          animation.addListener(new AnimatorListenerAdapter() {
              @Override
              public void onAnimationEnd(Animator animation) {
                  // some code to execute when the animation ends
              }
          });
          animation.start();
      }
  });
  // [...]
  </code></pre>
  
  <p>Now, at some point I may need to stop that progress bar view's animation (when the user taps a stop button, for example). I called <code>progressView.clearAnimation()</code> to stop the animation but got no success. I have also noticed that progressView.getAnimation() returns null... 
  And when I make <code>ObjectAnimator animation</code> variable final and move it outside the <code>someButton.setOnClickListener</code>, so that I can access it later to stop the animation, I get the following exception when I tap on someButton (just like what happens <a href="https://stackoverflow.com/questions/24105843/choreographer-nullpointerexception">here</a>):</p>
  
  <pre><code>java.lang.NullPointerException
     at android.animation.PropertyValuesHolder.setupSetterAndGetter(PropertyValuesHolder.java:505)
     at android.animation.ObjectAnimator.initAnimation(ObjectAnimator.java:487)
     at android.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:517)
     at android.animation.ValueAnimator.start(ValueAnimator.java:936)
     at android.animation.ValueAnimator.start(ValueAnimator.java:946)
     at android.animation.ObjectAnimator.start(ObjectAnimator.java:465)
     at android.animation.AnimatorSet$1.onAnimationEnd(AnimatorSet.java:579)
     at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1056)
     at android.animation.ValueAnimator.access$400(ValueAnimator.java:50)
  [...]
  </code></pre>
  
  <p>And the code that throws that exception is:</p>
  
  <pre><code>// [...]
  
  final ObjectAnimator animation = ObjectAnimator.ofInt(progressView, "progress", 0, 2000);
  animation.setDuration(2000);
  animation.setInterpolator(new DecelerateInterpolator());
  animation.addListener(new AnimatorListenerAdapter() {
      @Override
      public void onAnimationEnd(Animator animation) {
          // some code to execute when the animation ends
      }
  });
  
  someButton.setOnClickListener(new OnClickListener() {
      public void onClick(View v) {
          animation.start();// NPE occurs here!
      }
  });
  // [...]
  </code></pre>
  
  <p>What am doing wrong here?? How can one stop that animation???</p>