Search in sources :

Example 51 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project android_frameworks_base by ParanoidAndroid.

the class PhoneStatusBar method setAreThereNotifications.

@Override
protected void setAreThereNotifications() {
    final boolean any = mNotificationData.size() > 0;
    final boolean clearable = any && mNotificationData.hasClearableItems();
    if (DEBUG) {
        Slog.d(TAG, "setAreThereNotifications: N=" + mNotificationData.size() + " any=" + any + " clearable=" + clearable);
    }
    if (mHasFlipSettings && mFlipSettingsView != null && mFlipSettingsView.getVisibility() == View.VISIBLE && mScrollView.getVisibility() != View.VISIBLE) {
        // the flip settings panel is unequivocally showing; we should not be shown
        mClearButton.setVisibility(View.GONE);
    } else if (mClearButton.isShown()) {
        if (clearable != (mClearButton.getAlpha() == 1.0f)) {
            ObjectAnimator clearAnimation = ObjectAnimator.ofFloat(mClearButton, "alpha", clearable ? 1.0f : 0.0f).setDuration(250);
            clearAnimation.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    if (mClearButton.getAlpha() <= 0.0f) {
                        mClearButton.setVisibility(View.GONE);
                    }
                }

                @Override
                public void onAnimationStart(Animator animation) {
                    if (mClearButton.getAlpha() <= 0.0f) {
                        mClearButton.setVisibility(View.VISIBLE);
                    }
                }
            });
            clearAnimation.start();
        }
    } else {
        mClearButton.setAlpha(clearable ? 1.0f : 0.0f);
        mClearButton.setVisibility(clearable ? View.VISIBLE : View.GONE);
    }
    mClearButton.setEnabled(clearable);
    final View nlo = mStatusBarView.findViewById(R.id.notification_lights_out);
    final boolean showDot = (any && !areLightsOn());
    if (showDot != (nlo.getAlpha() == 1.0f)) {
        if (showDot) {
            nlo.setAlpha(0f);
            nlo.setVisibility(View.VISIBLE);
        }
        nlo.animate().alpha(showDot ? 1 : 0).setDuration(showDot ? 750 : 250).setInterpolator(new AccelerateInterpolator(2.0f)).setListener(showDot ? null : new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator _a) {
                nlo.setVisibility(View.GONE);
            }
        }).start();
    }
    updateCarrierLabelVisibility(false);
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ViewPropertyAnimator(android.view.ViewPropertyAnimator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) IntruderAlertView(com.android.systemui.statusbar.policy.IntruderAlertView) ImageView(android.widget.ImageView) DateView(com.android.systemui.statusbar.policy.DateView) View(android.view.View) TextView(android.widget.TextView) SignalClusterView(com.android.systemui.statusbar.SignalClusterView) StatusBarIconView(com.android.systemui.statusbar.StatusBarIconView) ScrollView(android.widget.ScrollView)

Example 52 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project FlexibleAdapter by davideas.

the class FromTopItemAnimator method animateRemoveImpl.

@Override
protected ViewPropertyAnimatorCompat animateRemoveImpl(ViewHolder holder) {
    Point screen = Utils.getScreenDimensions(holder.itemView.getContext());
    int top = holder.itemView.getTop();
    return ViewCompat.animate(holder.itemView).rotation(80).translationY(screen.y - top).setInterpolator(new AccelerateInterpolator());
}
Also used : AccelerateInterpolator(android.view.animation.AccelerateInterpolator) Point(android.graphics.Point) Point(android.graphics.Point)

Example 53 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project SogoLoading by dengshiwei.

the class SoGouBrowserLoading method playAnimator.

//动画执行
private void playAnimator() {
    //我们只需要取Y轴方向上的变化即可
    ValueAnimator valueAnimator = ValueAnimator.ofInt(startY, endY);
    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            currentY = (Integer) animation.getAnimatedValue();
            invalidate();
        }
    });
    valueAnimator.setInterpolator(new AccelerateInterpolator(1.2f));
    valueAnimator.setRepeatCount(-1);
    valueAnimator.setRepeatMode(2);
    valueAnimator.setDuration(500);
    valueAnimator.start();
}
Also used : AccelerateInterpolator(android.view.animation.AccelerateInterpolator) ValueAnimator(android.animation.ValueAnimator)

Example 54 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project ArcMenu by daCapricorn.

the class RayLayout method bindChildAnimation.

private void bindChildAnimation(final View child, final int index, final long duration) {
    final boolean expanded = mExpanded;
    final int childCount = getChildCount();
    Rect frame = computeChildFrame(!expanded, mLeftHolderWidth, index, mChildGap, mChildSize);
    final int toXDelta = frame.left - child.getLeft();
    final int toYDelta = frame.top - child.getTop();
    Interpolator interpolator = mExpanded ? new AccelerateInterpolator() : new OvershootInterpolator(1.5f);
    final long startOffset = computeStartOffset(childCount, mExpanded, index, 0.1f, duration, interpolator);
    Animation animation = mExpanded ? createShrinkAnimation(0, toXDelta, 0, toYDelta, startOffset, duration, interpolator) : createExpandAnimation(0, toXDelta, 0, toYDelta, startOffset, duration, interpolator);
    final boolean isLast = getTransformedIndex(expanded, childCount, index) == childCount - 1;
    animation.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            if (isLast) {
                postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        onAllAnimationsEnd();
                    }
                }, 0);
            }
        }
    });
    child.setAnimation(animation);
}
Also used : Rect(android.graphics.Rect) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) OvershootInterpolator(android.view.animation.OvershootInterpolator) RotateAnimation(android.view.animation.RotateAnimation) Animation(android.view.animation.Animation) Interpolator(android.view.animation.Interpolator) LinearInterpolator(android.view.animation.LinearInterpolator) OvershootInterpolator(android.view.animation.OvershootInterpolator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) AnimationListener(android.view.animation.Animation.AnimationListener)

Example 55 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator 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)

Aggregations

AccelerateInterpolator (android.view.animation.AccelerateInterpolator)186 Animator (android.animation.Animator)62 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)54 View (android.view.View)52 ObjectAnimator (android.animation.ObjectAnimator)41 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)40 ImageView (android.widget.ImageView)26 AnimatorSet (android.animation.AnimatorSet)24 TextView (android.widget.TextView)23 Animation (android.view.animation.Animation)21 ValueAnimator (android.animation.ValueAnimator)17 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)14 LinearInterpolator (android.view.animation.LinearInterpolator)14 TranslateAnimation (android.view.animation.TranslateAnimation)14 OvershootInterpolator (android.view.animation.OvershootInterpolator)13 Point (android.graphics.Point)12 Paint (android.graphics.Paint)10 Interpolator (android.view.animation.Interpolator)9 AlphaAnimation (android.view.animation.AlphaAnimation)8 AnticipateOvershootInterpolator (android.view.animation.AnticipateOvershootInterpolator)8