Search in sources :

Example 91 with ValueAnimator

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

the class KeyguardAffordanceHelper method startUnlockHintAnimationPhase2.

/**
     * Phase 2: Move back.
     */
private void startUnlockHintAnimationPhase2(boolean right, final Runnable onFinishedListener) {
    ValueAnimator animator = getAnimatorToRadius(right, 0);
    animator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mSwipeAnimator = null;
            mTargetedView = null;
            onFinishedListener.run();
        }
    });
    animator.setInterpolator(Interpolators.FAST_OUT_LINEAR_IN);
    animator.setDuration(HINT_PHASE2_DURATION);
    animator.setStartDelay(HINT_CIRCLE_OPEN_DURATION);
    animator.start();
    mSwipeAnimator = animator;
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ValueAnimator(android.animation.ValueAnimator)

Example 92 with ValueAnimator

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

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 93 with ValueAnimator

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

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 94 with ValueAnimator

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

the class SwipeHelper method dismissChild.

/**
     * @param view The view to be dismissed
     * @param velocity The desired pixels/second speed at which the view should move
     * @param endAction The action to perform at the end
     * @param delay The delay after which we should start
     * @param useAccelerateInterpolator Should an accelerating Interpolator be used
     * @param fixedDuration If not 0, this exact duration will be taken
     */
public void dismissChild(final View animView, float velocity, final Runnable endAction, long delay, boolean useAccelerateInterpolator, long fixedDuration, boolean isDismissAll) {
    final boolean canBeDismissed = mCallback.canChildBeDismissed(animView);
    float newPos;
    boolean isLayoutRtl = animView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
    // if we use the Menu to dismiss an item in landscape, animate up
    boolean animateUpForMenu = velocity == 0 && (getTranslation(animView) == 0 || isDismissAll) && mSwipeDirection == Y;
    // if the language is rtl we prefer swiping to the left
    boolean animateLeftForRtl = velocity == 0 && (getTranslation(animView) == 0 || isDismissAll) && isLayoutRtl;
    boolean animateLeft = velocity < 0 || (velocity == 0 && getTranslation(animView) < 0 && !isDismissAll);
    if (animateLeft || animateLeftForRtl || animateUpForMenu) {
        newPos = -getSize(animView);
    } else {
        newPos = getSize(animView);
    }
    long duration;
    if (fixedDuration == 0) {
        duration = MAX_ESCAPE_ANIMATION_DURATION;
        if (velocity != 0) {
            duration = Math.min(duration, (int) (Math.abs(newPos - getTranslation(animView)) * 1000f / Math.abs(velocity)));
        } else {
            duration = DEFAULT_ESCAPE_ANIMATION_DURATION;
        }
    } else {
        duration = fixedDuration;
    }
    if (!mDisableHwLayers) {
        animView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
    }
    AnimatorUpdateListener updateListener = new AnimatorUpdateListener() {

        public void onAnimationUpdate(ValueAnimator animation) {
            onTranslationUpdate(animView, (float) animation.getAnimatedValue(), canBeDismissed);
        }
    };
    Animator anim = getViewTranslationAnimator(animView, newPos, updateListener);
    if (anim == null) {
        return;
    }
    if (useAccelerateInterpolator) {
        anim.setInterpolator(Interpolators.FAST_OUT_LINEAR_IN);
        anim.setDuration(duration);
    } else {
        mFlingAnimationUtils.applyDismissing(anim, getTranslation(animView), newPos, velocity, getSize(animView));
    }
    if (delay > 0) {
        anim.setStartDelay(delay);
    }
    anim.addListener(new AnimatorListenerAdapter() {

        private boolean mCancelled;

        public void onAnimationCancel(Animator animation) {
            mCancelled = true;
        }

        public void onAnimationEnd(Animator animation) {
            updateSwipeProgressFromOffset(animView, canBeDismissed);
            mDismissPendingMap.remove(animView);
            if (!mCancelled) {
                mCallback.onChildDismissed(animView);
            }
            if (endAction != null) {
                endAction.run();
            }
            if (!mDisableHwLayers) {
                animView.setLayerType(View.LAYER_TYPE_NONE, null);
            }
        }
    });
    prepareDismissAnimation(animView, anim);
    mDismissPendingMap.put(animView, anim);
    anim.start();
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator)

Example 95 with ValueAnimator

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

the class SwipeHelper method snapChild.

public void snapChild(final View animView, final float targetLeft, float velocity) {
    final boolean canBeDismissed = mCallback.canChildBeDismissed(animView);
    AnimatorUpdateListener updateListener = new AnimatorUpdateListener() {

        public void onAnimationUpdate(ValueAnimator animation) {
            onTranslationUpdate(animView, (float) animation.getAnimatedValue(), canBeDismissed);
        }
    };
    Animator anim = getViewTranslationAnimator(animView, targetLeft, updateListener);
    if (anim == null) {
        return;
    }
    int duration = SNAP_ANIM_LEN;
    anim.setDuration(duration);
    anim.addListener(new AnimatorListenerAdapter() {

        public void onAnimationEnd(Animator animator) {
            mSnappingChild = false;
            updateSwipeProgressFromOffset(animView, canBeDismissed);
            mCallback.onChildSnappedBack(animView, targetLeft);
        }
    });
    prepareSnapBackAnimation(animView, anim);
    mSnappingChild = true;
    anim.start();
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) 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