static float getAnimatedFraction(ValueAnimator animator) {
    float fraction =
        animator.getDuration() > 0
            ? ((float) animator.getCurrentPlayTime()) / animator.getDuration()
            : 0f;

    fraction = min(fraction, 1f);
    fraction = animator.getInterpolator().getInterpolation(fraction);
    return fraction;
  }
Example #2
0
 /**
  * Returns the timing interpolator that this animation uses.
  *
  * @return The timing interpolator for this animation.
  */
 public TimeInterpolator getInterpolator() {
   if (mInterpolatorSet) {
     return mInterpolator;
   } else {
     // Just return the default from ValueAnimator, since that's what we'd get if
     // the value has not been set otherwise
     if (mTempValueAnimator == null) {
       mTempValueAnimator = new ValueAnimator();
     }
     return mTempValueAnimator.getInterpolator();
   }
 }