@Override
  protected Animator createSoftwareExit() {
    final AnimatorSet set = new AnimatorSet();

    // Linear exit after enter is completed.
    final ObjectAnimator exit = ObjectAnimator.ofFloat(this, RippleBackground.OPACITY, 0);
    exit.setInterpolator(LINEAR_INTERPOLATOR);
    exit.setDuration(OPACITY_EXIT_DURATION);
    AnimatorsCompat.setAutoCancel(exit);
    // exit.setAutoCancel(true);

    final AnimatorSet.Builder builder = set.play(exit);

    // Linear "fast" enter based on current opacity.
    final int fastEnterDuration = (int) ((1 - mOpacity) * OPACITY_ENTER_DURATION_FAST);
    if (fastEnterDuration > 0) {
      final ObjectAnimator enter = ObjectAnimator.ofFloat(this, RippleBackground.OPACITY, 1);
      enter.setInterpolator(LINEAR_INTERPOLATOR);
      enter.setDuration(fastEnterDuration);
      AnimatorsCompat.setAutoCancel(enter);
      // enter.setAutoCancel(true);

      builder.after(enter);
    }

    return set;
  }
示例#2
0
 /**
  * Sets up the animation supplied in the {@link AnimatorSet#play(Animator)} call that created
  * this <code>Builder</code> object to play when the given amount of time elapses.
  *
  * @param delay The number of milliseconds that should elapse before the animation starts.
  */
 public Builder after(long delay) {
   // setup dummy ValueAnimator just to run the clock
   ValueAnimator anim = ValueAnimator.ofFloat(0f, 1f);
   anim.setDuration(delay);
   after(anim);
   return this;
 }