Search in sources :

Example 1 with OvershootInterpolator

use of android.view.animation.OvershootInterpolator in project cw-omnibus by commonsguy.

the class AsyncDemoFragment method changeMenuIconAnimation.

// based on https://goo.gl/3IUM8K
private void changeMenuIconAnimation(final FloatingActionMenu menu) {
    AnimatorSet set = new AnimatorSet();
    final ImageView v = menu.getMenuIconView();
    ObjectAnimator scaleOutX = ObjectAnimator.ofFloat(v, "scaleX", 1.0f, 0.2f);
    ObjectAnimator scaleOutY = ObjectAnimator.ofFloat(v, "scaleY", 1.0f, 0.2f);
    ObjectAnimator scaleInX = ObjectAnimator.ofFloat(v, "scaleX", 0.2f, 1.0f);
    ObjectAnimator scaleInY = ObjectAnimator.ofFloat(v, "scaleY", 0.2f, 1.0f);
    scaleOutX.setDuration(50);
    scaleOutY.setDuration(50);
    scaleInX.setDuration(150);
    scaleInY.setDuration(150);
    scaleInX.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationStart(Animator animation) {
            v.setImageResource(menu.isOpened() ? R.drawable.ic_action_settings : R.drawable.ic_close);
        }
    });
    set.play(scaleOutX).with(scaleOutY);
    set.play(scaleInX).with(scaleInY).after(scaleOutX);
    set.setInterpolator(new OvershootInterpolator(2));
    menu.setIconToggleAnimatorSet(set);
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) OvershootInterpolator(android.view.animation.OvershootInterpolator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorSet(android.animation.AnimatorSet) ImageView(android.widget.ImageView)

Example 2 with OvershootInterpolator

use of android.view.animation.OvershootInterpolator in project Signal-Android by WhisperSystems.

the class AttachmentTypeSelector method animateButtonIn.

private void animateButtonIn(View button, int delay) {
    AnimationSet animation = new AnimationSet(true);
    Animation scale = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.0f);
    animation.addAnimation(scale);
    animation.setInterpolator(new OvershootInterpolator(1));
    animation.setDuration(ANIMATION_DURATION);
    animation.setStartOffset(delay);
    button.startAnimation(animation);
}
Also used : OvershootInterpolator(android.view.animation.OvershootInterpolator) ScaleAnimation(android.view.animation.ScaleAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) Animation(android.view.animation.Animation) AnimationSet(android.view.animation.AnimationSet) ScaleAnimation(android.view.animation.ScaleAnimation)

Example 3 with OvershootInterpolator

use of android.view.animation.OvershootInterpolator in project UltimateAndroid by cymcsg.

the class DownloadProgressBar method setupAnimations.

private void setupAnimations() {
    mOvershootInterpolator = new OvershootInterpolator(mOvershootValue);
    mArrowLineToDot = ValueAnimator.ofFloat(0, mRadius / 4);
    mArrowLineToDot.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            mArrowLineToDotAnimatedValue = (float) valueAnimator.getAnimatedValue();
            invalidate();
        }
    });
    mArrowLineToDot.setDuration(200);
    mArrowLineToDot.addListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animator) {
            mState = State.ANIMATING_LINE_TO_DOT;
            if (mOnProgressUpdateListener != null) {
                mOnProgressUpdateListener.onAnimationStarted();
            }
        }

        @Override
        public void onAnimationEnd(Animator animator) {
        }

        @Override
        public void onAnimationCancel(Animator animator) {
        }

        @Override
        public void onAnimationRepeat(Animator animator) {
        }
    });
    mArrowLineToDot.setInterpolator(new AccelerateInterpolator());
    mArrowLineToHorizontalLine = ValueAnimator.ofFloat(0, mRadius / 2);
    mArrowLineToHorizontalLine.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            mArrowLineToHorizontalLineAnimatedValue = (float) valueAnimator.getAnimatedValue();
            invalidate();
        }
    });
    mArrowLineToHorizontalLine.addListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animator) {
        }

        @Override
        public void onAnimationEnd(Animator animator) {
        }

        @Override
        public void onAnimationCancel(Animator animator) {
        }

        @Override
        public void onAnimationRepeat(Animator animator) {
        }
    });
    mArrowLineToHorizontalLine.setDuration(600);
    mArrowLineToHorizontalLine.setStartDelay(400);
    mArrowLineToHorizontalLine.setInterpolator(mOvershootInterpolator);
    mDotToProgressAnimation = ValueAnimator.ofFloat(0, mRadius);
    mDotToProgressAnimation.setDuration(600);
    mDotToProgressAnimation.setStartDelay(600);
    mDotToProgressAnimation.setInterpolator(mOvershootInterpolator);
    mDotToProgressAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            mDotToProgressAnimatedValue = (float) valueAnimator.getAnimatedValue();
            invalidate();
        }
    });
    mDotToProgressAnimation.addListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animator) {
        }

        @Override
        public void onAnimationEnd(Animator animator) {
            if (mWhichProgress == State.ANIMATING_PROGRESS)
                mProgressAnimationSet.start();
            else if (mWhichProgress == State.ANIMATING_MANUAL_PROGRESS)
                mManualProgressAnimationSet.start();
            mState = mWhichProgress;
        }

        @Override
        public void onAnimationCancel(Animator animator) {
        }

        @Override
        public void onAnimationRepeat(Animator animator) {
        }
    });
    mArrowToLineAnimatorSet = new AnimatorSet();
    mArrowToLineAnimatorSet.playTogether(mArrowLineToDot, mArrowLineToHorizontalLine, mDotToProgressAnimation);
    mProgressAnimation = ValueAnimator.ofFloat(0, 360f);
    mProgressAnimation.setStartDelay(500);
    mProgressAnimation.setInterpolator(new LinearInterpolator());
    mProgressAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            mCurrentGlobalProgressValue = (float) valueAnimator.getAnimatedValue();
            if (mOnProgressUpdateListener != null) {
                mOnProgressUpdateListener.onProgressUpdate(mCurrentGlobalProgressValue);
            }
            invalidate();
        }
    });
    mProgressAnimation.addListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animator) {
            mDotToProgressAnimatedValue = 0;
        }

        @Override
        public void onAnimationEnd(Animator animator) {
        }

        @Override
        public void onAnimationCancel(Animator animator) {
        }

        @Override
        public void onAnimationRepeat(Animator animator) {
        }
    });
    mProgressAnimation.setDuration(mProgressDuration);
    mManualProgressAnimation = ValueAnimator.ofFloat(mFromArc, mToArc);
    mManualProgressAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            mCurrentGlobalManualProgressValue = (float) valueAnimator.getAnimatedValue();
            invalidate();
        }
    });
    mManualProgressAnimation.addListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animator) {
            if (mOnProgressUpdateListener != null) {
                mOnProgressUpdateListener.onManualProgressStarted();
            }
            mDotToProgressAnimatedValue = 0;
        }

        @Override
        public void onAnimationEnd(Animator animator) {
            if (mOnProgressUpdateListener != null) {
                mOnProgressUpdateListener.onManualProgressEnded();
            }
            if (mToArc > 359) {
                mCollapseAnimation.start();
            }
        }

        @Override
        public void onAnimationCancel(Animator animator) {
        }

        @Override
        public void onAnimationRepeat(Animator animator) {
        }
    });
    mExpandAnimation = ValueAnimator.ofFloat(0, mRadius / 6);
    mExpandAnimation.setDuration(300);
    mExpandAnimation.setInterpolator(new DecelerateInterpolator());
    mExpandAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mExpandCollapseValue = (float) animation.getAnimatedValue();
            invalidate();
        }
    });
    mCollapseAnimation = ValueAnimator.ofFloat(mRadius / 6, mStrokeWidth / 2);
    mCollapseAnimation.setDuration(300);
    mCollapseAnimation.setStartDelay(300);
    mCollapseAnimation.addListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animator) {
        }

        @Override
        public void onAnimationEnd(Animator animator) {
            if (mState == State.ANIMATING_MANUAL_PROGRESS) {
                if (mResultState == State.ANIMATING_ERROR) {
                    mErrorAnimation.start();
                } else if (mResultState == State.ANIMATING_SUCCESS) {
                    mSuccessAnimation.start();
                }
            }
        }

        @Override
        public void onAnimationCancel(Animator animator) {
        }

        @Override
        public void onAnimationRepeat(Animator animator) {
        }
    });
    mCollapseAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
    mCollapseAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mExpandCollapseValue = (float) animation.getAnimatedValue();
            invalidate();
        }
    });
    mManualProgressAnimationSet = new AnimatorSet();
    mManualProgressAnimationSet.playSequentially(mExpandAnimation, mManualProgressAnimation);
    mProgressAnimationSet = new AnimatorSet();
    mProgressAnimationSet.addListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (mResultState == State.ANIMATING_ERROR) {
                mErrorAnimation.start();
            } else if (mResultState == State.ANIMATING_SUCCESS) {
                mSuccessAnimation.start();
            }
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }
    });
    mProgressAnimationSet.playSequentially(mExpandAnimation, mProgressAnimation, mCollapseAnimation);
    mErrorAnimation = ValueAnimator.ofFloat(0, mRadius / 4);
    mErrorAnimation.setDuration(600);
    mErrorAnimation.setStartDelay(500);
    mErrorAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
    mErrorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            mErrorValue = (float) valueAnimator.getAnimatedValue();
            invalidate();
        }
    });
    mErrorAnimation.addListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animator) {
            mState = State.ANIMATING_ERROR;
            if (mOnProgressUpdateListener != null) {
                mOnProgressUpdateListener.onAnimationError();
            }
        }

        @Override
        public void onAnimationEnd(Animator animator) {
            postDelayed(new Runnable() {

                @Override
                public void run() {
                    if (mOnProgressUpdateListener != null) {
                        mOnProgressUpdateListener.onAnimationEnded();
                    }
                    mState = State.IDLE;
                    resetValues();
                    invalidate();
                }
            }, mResultDuration);
        }

        @Override
        public void onAnimationCancel(Animator animator) {
        }

        @Override
        public void onAnimationRepeat(Animator animator) {
        }
    });
    mSuccessAnimation = ValueAnimator.ofFloat(0, mRadius / 4);
    mSuccessAnimation.setDuration(600);
    mSuccessAnimation.setStartDelay(500);
    mSuccessAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
    mSuccessAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            mSuccessValue = (float) valueAnimator.getAnimatedValue();
            invalidate();
        }
    });
    mSuccessAnimation.addListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animator) {
            mState = State.ANIMATING_SUCCESS;
            if (mOnProgressUpdateListener != null) {
                mOnProgressUpdateListener.onAnimationSuccess();
            }
        }

        @Override
        public void onAnimationEnd(Animator animator) {
            postDelayed(new Runnable() {

                @Override
                public void run() {
                    if (mOnProgressUpdateListener != null) {
                        mOnProgressUpdateListener.onAnimationEnded();
                    }
                    mState = State.IDLE;
                    resetValues();
                    invalidate();
                }
            }, mResultDuration);
        }

        @Override
        public void onAnimationCancel(Animator animator) {
        }

        @Override
        public void onAnimationRepeat(Animator animator) {
        }
    });
}
Also used : AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) OvershootInterpolator(android.view.animation.OvershootInterpolator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) LinearInterpolator(android.view.animation.LinearInterpolator) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) AnimatorSet(android.animation.AnimatorSet) ValueAnimator(android.animation.ValueAnimator)

Example 4 with OvershootInterpolator

use of android.view.animation.OvershootInterpolator in project CompactCalendarView by SundeepK.

the class AnimationHandler method getIndicatorAnimator.

@NonNull
private Animator getIndicatorAnimator(float from, float to) {
    ValueAnimator animIndicator = ValueAnimator.ofFloat(from, to);
    animIndicator.setDuration(INDICATOR_ANIM_DURATION_MILLIS);
    animIndicator.setInterpolator(new OvershootInterpolator());
    animIndicator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            compactCalendarController.setGrowFactorIndicator((Float) animation.getAnimatedValue());
            compactCalendarView.invalidate();
        }
    });
    return animIndicator;
}
Also used : OvershootInterpolator(android.view.animation.OvershootInterpolator) ValueAnimator(android.animation.ValueAnimator) NonNull(android.support.annotation.NonNull)

Example 5 with OvershootInterpolator

use of android.view.animation.OvershootInterpolator in project GSYVideoPlayer by CarGuo.

the class ENDownloadView method endAnim.

private void endAnim() {
    if (mValueAnimator != null) {
        mValueAnimator.removeAllListeners();
        mValueAnimator.removeAllUpdateListeners();
        if (mValueAnimator.isRunning())
            mValueAnimator.cancel();
        mValueAnimator = null;
    }
    mValueAnimator = ValueAnimator.ofFloat(1.f, 100.f);
    mValueAnimator.setDuration(700);
    mValueAnimator.setInterpolator(new OvershootInterpolator());
    mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            mFraction = valueAnimator.getAnimatedFraction();
            invalidate();
        }
    });
    mValueAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mFraction = 0;
            mCurrentState = STATE_RESET;
            if (onDownloadStateListener != null) {
                onDownloadStateListener.onDownloadFinish();
            }
        }
    });
    mValueAnimator.start();
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) OvershootInterpolator(android.view.animation.OvershootInterpolator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ValueAnimator(android.animation.ValueAnimator)

Aggregations

OvershootInterpolator (android.view.animation.OvershootInterpolator)126 ObjectAnimator (android.animation.ObjectAnimator)37 Animator (android.animation.Animator)31 View (android.view.View)30 TextView (android.widget.TextView)20 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)18 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)17 AnimatorSet (android.animation.AnimatorSet)16 ValueAnimator (android.animation.ValueAnimator)16 Handler (android.os.Handler)14 Animation (android.view.animation.Animation)12 LinearInterpolator (android.view.animation.LinearInterpolator)11 RecyclerView (android.support.v7.widget.RecyclerView)10 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)10 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)9 ScaleAnimation (android.view.animation.ScaleAnimation)9 TranslateAnimation (android.view.animation.TranslateAnimation)9 Drawable (android.graphics.drawable.Drawable)8 AnticipateInterpolator (android.view.animation.AnticipateInterpolator)8 PropertyValuesHolder (android.animation.PropertyValuesHolder)6