Search in sources :

Example 16 with ValueAnimator

use of android.animation.ValueAnimator in project UltimateRecyclerView by cymcsg.

the class SwipeDismissTouchListener method performDismiss.

private void performDismiss() {
    // Animate the dismissed view to zero-height and then fire the dismiss callback.
    // This triggers layout on each animation frame; in the future we may want to do something
    // smarter and more performant.
    URLogs.d("performDismiss");
    final ViewGroup.LayoutParams lp = mView.getLayoutParams();
    final int originalHeight = mView.getHeight();
    ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime);
    animator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mCallbacks.onDismiss(mView, mToken);
            // Reset view presentation
            mView.setAlpha(1f);
            mView.setTranslationX(0);
            lp.height = originalHeight;
            mView.setLayoutParams(lp);
        }
    });
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            lp.height = (Integer) valueAnimator.getAnimatedValue();
            // if (lp.height > 100)
            mView.setLayoutParams(lp);
        //  mView.setVisibility(View.GONE);
        }
    });
    animator.start();
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) ViewGroup(android.view.ViewGroup) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ValueAnimator(android.animation.ValueAnimator)

Example 17 with ValueAnimator

use of android.animation.ValueAnimator in project UltimateRecyclerView by cymcsg.

the class ViewPagerTabFragmentParentFragment method animateToolbar.

private void animateToolbar(final float toY) {
    float layoutTranslationY = ViewCompat.getTranslationY(mInterceptionLayout);
    if (layoutTranslationY != toY) {
        ValueAnimator animator = ValueAnimator.ofFloat(ViewCompat.getTranslationY(mInterceptionLayout), toY).setDuration(200);
        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                float translationY = (float) animation.getAnimatedValue();
                View tView = adjustmentToolBarView();
                ViewCompat.setTranslationY(mInterceptionLayout, translationY);
                ViewCompat.setTranslationY(tView, translationY);
                if (translationY < 0) {
                    FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mInterceptionLayout.getLayoutParams();
                    lp.height = (int) (-translationY + getScreenHeight());
                    mInterceptionLayout.requestLayout();
                }
            }
        });
        animator.start();
    }
}
Also used : FrameLayout(android.widget.FrameLayout) ValueAnimator(android.animation.ValueAnimator) ImageView(android.widget.ImageView) UltimateRecyclerView(com.marshalchen.ultimaterecyclerview.UltimateRecyclerView) View(android.view.View)

Example 18 with ValueAnimator

use of android.animation.ValueAnimator in project Launcher3 by chislon.

the class Workspace method animateBackgroundGradient.

private void animateBackgroundGradient(float finalAlpha, boolean animated) {
    if (mBackground == null)
        return;
    if (mBackgroundFadeInAnimation != null) {
        mBackgroundFadeInAnimation.cancel();
        mBackgroundFadeInAnimation = null;
    }
    if (mBackgroundFadeOutAnimation != null) {
        mBackgroundFadeOutAnimation.cancel();
        mBackgroundFadeOutAnimation = null;
    }
    float startAlpha = getBackgroundAlpha();
    if (finalAlpha != startAlpha) {
        if (animated) {
            mBackgroundFadeOutAnimation = LauncherAnimUtils.ofFloat(this, startAlpha, finalAlpha);
            mBackgroundFadeOutAnimation.addUpdateListener(new AnimatorUpdateListener() {

                public void onAnimationUpdate(ValueAnimator animation) {
                    setBackgroundAlpha(((Float) animation.getAnimatedValue()).floatValue());
                }
            });
            mBackgroundFadeOutAnimation.setInterpolator(new DecelerateInterpolator(1.5f));
            mBackgroundFadeOutAnimation.setDuration(BACKGROUND_FADE_OUT_DURATION);
            mBackgroundFadeOutAnimation.start();
        } else {
            setBackgroundAlpha(finalAlpha);
        }
    }
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator)

Example 19 with ValueAnimator

use of android.animation.ValueAnimator in project RecyclerRefreshLayout by dinuscxj.

the class MaterialRefreshView method startAnimator.

private void startAnimator() {
    mRotateAnimator = ValueAnimator.ofFloat(0.0f, 1.0f);
    mRotateAnimator.setInterpolator(new LinearInterpolator());
    mRotateAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float rotateProgress = (float) animation.getAnimatedValue();
            setStartDegrees(DEFAULT_START_DEGREES + rotateProgress * 360);
        }
    });
    mRotateAnimator.setRepeatMode(ValueAnimator.RESTART);
    mRotateAnimator.setRepeatCount(ValueAnimator.INFINITE);
    mRotateAnimator.setDuration(ANIMATION_DURATION);
    mRotateAnimator.start();
}
Also used : LinearInterpolator(android.view.animation.LinearInterpolator) ValueAnimator(android.animation.ValueAnimator)

Example 20 with ValueAnimator

use of android.animation.ValueAnimator in project circular-progress-button by dmytrodanylyk.

the class MorphingAnimation method start.

public void start() {
    ValueAnimator widthAnimation = ValueAnimator.ofInt(mFromWidth, mToWidth);
    final GradientDrawable gradientDrawable = mDrawable.getGradientDrawable();
    widthAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            Integer value = (Integer) animation.getAnimatedValue();
            int leftOffset;
            int rightOffset;
            int padding;
            if (mFromWidth > mToWidth) {
                leftOffset = (mFromWidth - value) / 2;
                rightOffset = mFromWidth - leftOffset;
                padding = (int) (mPadding * animation.getAnimatedFraction());
            } else {
                leftOffset = (mToWidth - value) / 2;
                rightOffset = mToWidth - leftOffset;
                padding = (int) (mPadding - mPadding * animation.getAnimatedFraction());
            }
            gradientDrawable.setBounds(leftOffset + padding, padding, rightOffset - padding, mView.getHeight() - padding);
        }
    });
    ObjectAnimator bgColorAnimation = ObjectAnimator.ofInt(gradientDrawable, "color", mFromColor, mToColor);
    bgColorAnimation.setEvaluator(new ArgbEvaluator());
    ObjectAnimator strokeColorAnimation = ObjectAnimator.ofInt(mDrawable, "strokeColor", mFromStrokeColor, mToStrokeColor);
    strokeColorAnimation.setEvaluator(new ArgbEvaluator());
    ObjectAnimator cornerAnimation = ObjectAnimator.ofFloat(gradientDrawable, "cornerRadius", mFromCornerRadius, mToCornerRadius);
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.setDuration(mDuration);
    animatorSet.playTogether(widthAnimation, bgColorAnimation, strokeColorAnimation, cornerAnimation);
    animatorSet.addListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (mListener != null) {
                mListener.onAnimationEnd();
            }
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }
    });
    animatorSet.start();
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) ObjectAnimator(android.animation.ObjectAnimator) ArgbEvaluator(android.animation.ArgbEvaluator) AnimatorSet(android.animation.AnimatorSet) ValueAnimator(android.animation.ValueAnimator) GradientDrawable(android.graphics.drawable.GradientDrawable)

Aggregations

ValueAnimator (android.animation.ValueAnimator)710 Animator (android.animation.Animator)374 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)306 ObjectAnimator (android.animation.ObjectAnimator)141 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)88 ArrayList (java.util.ArrayList)75 Paint (android.graphics.Paint)66 AnimatorSet (android.animation.AnimatorSet)57 LinearInterpolator (android.view.animation.LinearInterpolator)50 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)49 View (android.view.View)47 StackStateAnimator (com.android.systemui.statusbar.stack.StackStateAnimator)40 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)32 PropertyValuesHolder (android.animation.PropertyValuesHolder)31 ViewGroup (android.view.ViewGroup)30 ArgbEvaluator (android.animation.ArgbEvaluator)28 Interpolator (android.view.animation.Interpolator)26 TextView (android.widget.TextView)25 RenderNodeAnimator (android.view.RenderNodeAnimator)20 Rect (android.graphics.Rect)19