private void animateOffsetToCorrectPosition(int from, AnimationListener listener) {
   mFrom = from;
   mAnimateToCorrectPosition.reset();
   mAnimateToCorrectPosition.setDuration(ANIMATE_TO_TRIGGER_DURATION);
   mAnimateToCorrectPosition.setInterpolator(mDecelerateInterpolator);
   if (listener != null) {
     mCircleView.setAnimationListener(listener);
   }
   mCircleView.clearAnimation();
   mCircleView.startAnimation(mAnimateToCorrectPosition);
 }
 private void startScaleDownAnimation(Animation.AnimationListener listener) {
   mScaleDownAnimation =
       new Animation() {
         @Override
         public void applyTransformation(float interpolatedTime, Transformation t) {
           setAnimationProgress(1 - interpolatedTime);
         }
       };
   mScaleDownAnimation.setDuration(SCALE_DOWN_DURATION);
   mCircleView.setAnimationListener(listener);
   mCircleView.clearAnimation();
   mCircleView.startAnimation(mScaleDownAnimation);
 }
 private void animateOffsetToStartPosition(int from, AnimationListener listener) {
   if (mScale) {
     // Scale the item back down
     startScaleDownReturnToStartAnimation(from, listener);
   } else {
     mFrom = from;
     mAnimateToStartPosition.reset();
     mAnimateToStartPosition.setDuration(ANIMATE_TO_START_DURATION);
     mAnimateToStartPosition.setInterpolator(mDecelerateInterpolator);
     if (listener != null) {
       mCircleView.setAnimationListener(listener);
     }
     mCircleView.clearAnimation();
     mCircleView.startAnimation(mAnimateToStartPosition);
   }
 }
 private Animation startAlphaAnimation(final int startingAlpha, final int endingAlpha) {
   // Pre API 11, alpha is used in place of scale. Don't also use it to
   // show the trigger point.
   if (mScale && isAlphaUsedForScale()) {
     return null;
   }
   Animation alpha =
       new Animation() {
         @Override
         public void applyTransformation(float interpolatedTime, Transformation t) {
           mProgress.setAlpha(
               (int) (startingAlpha + ((endingAlpha - startingAlpha) * interpolatedTime)));
         }
       };
   alpha.setDuration(ALPHA_ANIMATION_DURATION);
   // Clear out the previous animation listeners.
   mCircleView.setAnimationListener(null);
   mCircleView.clearAnimation();
   mCircleView.startAnimation(alpha);
   return alpha;
 }
 private void startScaleUpAnimation(AnimationListener listener) {
   mCircleView.setVisibility(View.VISIBLE);
   if (android.os.Build.VERSION.SDK_INT >= 11) {
     // Pre API 11, alpha is used in place of scale up to show the
     // progress circle appearing.
     // Don't adjust the alpha during appearance otherwise.
     mProgress.setAlpha(MAX_ALPHA);
   }
   mScaleAnimation =
       new Animation() {
         @Override
         public void applyTransformation(float interpolatedTime, Transformation t) {
           setAnimationProgress(interpolatedTime);
         }
       };
   mScaleAnimation.setDuration(mMediumAnimationDuration);
   if (listener != null) {
     mCircleView.setAnimationListener(listener);
   }
   mCircleView.clearAnimation();
   mCircleView.startAnimation(mScaleAnimation);
 }
 private void startScaleDownReturnToStartAnimation(
     int from, Animation.AnimationListener listener) {
   mFrom = from;
   if (isAlphaUsedForScale()) {
     mStartingScale = mProgress.getAlpha();
   } else {
     mStartingScale = ViewCompat.getScaleX(mCircleView);
   }
   mScaleDownToStartAnimation =
       new Animation() {
         @Override
         public void applyTransformation(float interpolatedTime, Transformation t) {
           float targetScale = (mStartingScale + (-mStartingScale * interpolatedTime));
           setAnimationProgress(targetScale);
           moveToStart(interpolatedTime);
         }
       };
   mScaleDownToStartAnimation.setDuration(SCALE_DOWN_DURATION);
   if (listener != null) {
     mCircleView.setAnimationListener(listener);
   }
   mCircleView.clearAnimation();
   mCircleView.startAnimation(mScaleDownToStartAnimation);
 }