Search in sources :

Example 66 with ValueAnimator

use of android.animation.ValueAnimator in project android_frameworks_base by DirtyUnicorns.

the class NotificationPanelView method startQsSizeChangeAnimation.

private void startQsSizeChangeAnimation(int oldHeight, final int newHeight) {
    if (mQsSizeChangeAnimator != null) {
        oldHeight = (int) mQsSizeChangeAnimator.getAnimatedValue();
        mQsSizeChangeAnimator.cancel();
    }
    mQsSizeChangeAnimator = ValueAnimator.ofInt(oldHeight, newHeight);
    mQsSizeChangeAnimator.setDuration(300);
    mQsSizeChangeAnimator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
    mQsSizeChangeAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            requestScrollerTopPaddingUpdate(false);
            requestPanelHeightUpdate();
            int height = (int) mQsSizeChangeAnimator.getAnimatedValue();
            mQsContainer.setHeightOverride(height);
        }
    });
    mQsSizeChangeAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mQsSizeChangeAnimator = null;
        }
    });
    mQsSizeChangeAnimator.start();
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) StackStateAnimator(com.android.systemui.statusbar.stack.StackStateAnimator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ValueAnimator(android.animation.ValueAnimator)

Example 67 with ValueAnimator

use of android.animation.ValueAnimator in project android_frameworks_base by DirtyUnicorns.

the class StopMotionVectorDrawable method setCurrentFraction.

/**
     * {@see android.animation.ValueAnimator#setCurrentFraction}
     * @param fraction The fraction to which the animation is advanced or rewound. Values outside
     *                 the range of 0 to the maximum fraction for the animator will be clamped to
     *                 the correct range.
     */
public void setCurrentFraction(float fraction) {
    if (mDrawable == null || mAnimatorSet == null)
        return;
    ArrayList<Animator> animators = mAnimatorSet.getChildAnimations();
    for (Animator animator : animators) {
        if (animator instanceof ValueAnimator) {
            ((ValueAnimator) animator).setCurrentFraction(fraction);
        }
    }
    mDrawable.invalidateSelf();
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) ValueAnimator(android.animation.ValueAnimator)

Example 68 with ValueAnimator

use of android.animation.ValueAnimator in project android_frameworks_base by DirtyUnicorns.

the class KeyguardAffordanceHelper method fling.

private void fling(float vel, final boolean snapBack, boolean right) {
    float target = right ? -mCallback.getMaxTranslationDistance() : mCallback.getMaxTranslationDistance();
    target = snapBack ? 0 : target;
    ValueAnimator animator = ValueAnimator.ofFloat(mTranslation, target);
    mFlingAnimationUtils.apply(animator, mTranslation, target, vel);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mTranslation = (float) animation.getAnimatedValue();
        }
    });
    animator.addListener(mFlingEndListener);
    if (!snapBack) {
        startFinishingCircleAnimation(vel * 0.375f, mAnimationEndRunnable, right);
        mCallback.onAnimationToSideStarted(right, mTranslation, vel);
    } else {
        reset(true);
    }
    animator.start();
    mSwipeAnimator = animator;
    if (snapBack) {
        mCallback.onSwipingAborted();
    }
}
Also used : ValueAnimator(android.animation.ValueAnimator)

Example 69 with ValueAnimator

use of android.animation.ValueAnimator in project android_frameworks_base by DirtyUnicorns.

the class ViewTransformationHelper method transformTo.

@Override
public void transformTo(final TransformableView notification, final Runnable endRunnable) {
    if (mViewTransformationAnimation != null) {
        mViewTransformationAnimation.cancel();
    }
    mViewTransformationAnimation = ValueAnimator.ofFloat(0.0f, 1.0f);
    mViewTransformationAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            transformTo(notification, animation.getAnimatedFraction());
        }
    });
    mViewTransformationAnimation.setInterpolator(Interpolators.LINEAR);
    mViewTransformationAnimation.setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD);
    mViewTransformationAnimation.addListener(new AnimatorListenerAdapter() {

        public boolean mCancelled;

        @Override
        public void onAnimationEnd(Animator animation) {
            if (!mCancelled) {
                if (endRunnable != null) {
                    endRunnable.run();
                }
                setVisible(false);
            } else {
                abortTransformations();
            }
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            mCancelled = true;
        }
    });
    mViewTransformationAnimation.start();
}
Also used : StackStateAnimator(com.android.systemui.statusbar.stack.StackStateAnimator) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ValueAnimator(android.animation.ValueAnimator)

Example 70 with ValueAnimator

use of android.animation.ValueAnimator in project android_frameworks_base by DirtyUnicorns.

the class NotificationSettingsIconRow method fadeInSettings.

public void fadeInSettings(final boolean fromLeft, final float transX, final float notiThreshold) {
    if (mDismissing || mAnimating) {
        return;
    }
    if (isIconLocationChange(transX)) {
        setGearAlpha(0f);
    }
    setIconLocation(transX > 0);
    mFadeAnimator = ValueAnimator.ofFloat(mGearIcon.getAlpha(), 1);
    mFadeAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            final float absTrans = Math.abs(transX);
            boolean pastGear = (fromLeft && transX <= notiThreshold) || (!fromLeft && absTrans <= notiThreshold);
            if (pastGear && !mSettingsFadedIn) {
                setGearAlpha((float) animation.getAnimatedValue());
            }
        }
    });
    mFadeAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationStart(Animator animation) {
            mAnimating = true;
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            // TODO should animate back to 0f from current alpha
            mGearIcon.setAlpha(0f);
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            mAnimating = false;
            mSettingsFadedIn = mGearIcon.getAlpha() == 1;
        }
    });
    mFadeAnimator.setInterpolator(Interpolators.ALPHA_IN);
    mFadeAnimator.setDuration(GEAR_ALPHA_ANIM_DURATION);
    mFadeAnimator.start();
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ValueAnimator(android.animation.ValueAnimator)

Aggregations

ValueAnimator (android.animation.ValueAnimator)1224 Animator (android.animation.Animator)625 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)455 ObjectAnimator (android.animation.ObjectAnimator)187 ArrayList (java.util.ArrayList)128 Paint (android.graphics.Paint)124 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)111 LinearInterpolator (android.view.animation.LinearInterpolator)102 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)91 View (android.view.View)90 AnimatorSet (android.animation.AnimatorSet)87 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)74 ArgbEvaluator (android.animation.ArgbEvaluator)57 ViewGroup (android.view.ViewGroup)44 TextView (android.widget.TextView)44 StackStateAnimator (com.android.systemui.statusbar.stack.StackStateAnimator)40 PropertyValuesHolder (android.animation.PropertyValuesHolder)36 ImageView (android.widget.ImageView)34 Interpolator (android.view.animation.Interpolator)31 SuppressLint (android.annotation.SuppressLint)25