List of usage examples for android.view.animation BounceInterpolator BounceInterpolator
public BounceInterpolator()
From source file:self.philbrown.droidQuery.$.java
/** * This reusable chunk of code can set up the given animation using the given animation options * @param options the options used to manipulate how the animation behaves * @return the container for placing views that will be animated using the given options *///from ww w. j av a 2s . c om private AnimatorSet animationWithOptions(final AnimationOptions options, List<Animator> animators) { AnimatorSet animation = new AnimatorSet(); animation.playTogether(animators); animation.setDuration(options.duration()); animation.addListener(new AnimatorListener() { @Override public void onAnimationCancel(Animator animation) { if (options.fail() != null) options.fail().invoke($.this); if (options.complete() != null) options.complete().invoke($.this); } @Override public void onAnimationEnd(Animator animation) { if (options.success() != null) options.success().invoke($.this); if (options.complete() != null) options.complete().invoke($.this); } @Override public void onAnimationRepeat(Animator animation) { } @Override public void onAnimationStart(Animator animation) { } }); Interpolator interpolator = null; if (options.easing() == null) options.easing(Easing.LINEAR); final Easing easing = options.easing(); switch (easing) { case ACCELERATE: { interpolator = new AccelerateInterpolator(); break; } case ACCELERATE_DECELERATE: { interpolator = new AccelerateDecelerateInterpolator(); break; } case ANTICIPATE: { interpolator = new AnticipateInterpolator(); break; } case ANTICIPATE_OVERSHOOT: { interpolator = new AnticipateOvershootInterpolator(); break; } case BOUNCE: { interpolator = new BounceInterpolator(); break; } case DECELERATE: { interpolator = new DecelerateInterpolator(); break; } case OVERSHOOT: { interpolator = new OvershootInterpolator(); break; } //linear is default. case LINEAR: default: interpolator = new LinearInterpolator(); break; } //allow custom interpolator if (options.specialEasing() != null) interpolator = options.specialEasing(); animation.setInterpolator(interpolator); return animation; }
From source file:com.nihaskalam.progressbuttonlibrary.CircularProgressButton.java
private void animateIdleStateButtonAfterClick() { int textColorChangeDuration = 10; ObjectAnimator colorAnim = ObjectAnimator.ofInt(this, "textColor", getNormalColor(this.getTextColors()), mIdleStateTextColorAfterClick); colorAnim.setDuration(textColorChangeDuration); colorAnim.setEvaluator(new ArgbEvaluator()); colorAnim.start();/*from ww w.j a v a 2 s . co m*/ ObjectAnimator colorAnim1 = ObjectAnimator.ofInt(this, "textColor", mIdleStateTextColorAfterClick, getNormalColor(this.getTextColors())); colorAnim1.setDuration(0); colorAnim1.setStartDelay(IDLE_STATE_ANIMATION_DURATION_AFTER_CLICK - textColorChangeDuration); colorAnim1.setEvaluator(new ArgbEvaluator()); colorAnim1.setInterpolator(new BounceInterpolator()); colorAnim1.start(); ObjectAnimator bgAnim = ObjectAnimator.ofInt(this, "backgroundColor", getNormalColor(mIdleColorState), mIdleStateBackgroundColorAfterClick); bgAnim.setDuration(0); bgAnim.setEvaluator(new ArgbEvaluator()); bgAnim.start(); int textSizeAnimationDuration = 150; ValueAnimator animator = ValueAnimator.ofFloat(textSize, textSize - textSize / 4); animator.setDuration(textSizeAnimationDuration); animator.setRepeatCount(1); animator.setRepeatMode(ValueAnimator.REVERSE); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { float animatedValue = (float) valueAnimator.getAnimatedValue(); setTextSize(animatedValue); } }); animator.start(); }