コード例 #1
0
  @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;
  }