Search in sources :

Example 61 with ValueAnimator

use of android.animation.ValueAnimator in project bilibili-android-client by HotBitmapGG.

the class LoveLikeLayout method getBezierAnimtor.

/**
   * 爱心运动轨迹的动画实现
   */
private ValueAnimator getBezierAnimtor(final View target) {
    BezierEvaluator evaluator = new BezierEvaluator(getPoint(2), getPoint(1));
    ValueAnimator animator = ValueAnimator.ofObject(evaluator, new PointF((measuredWidth - drawableWidth) / 2, measuredHeight - drawableHeight), new PointF(mRandom.nextInt(getWidth()), 0));
    animator.setDuration(3000);
    animator.setTarget(target);
    animator.addUpdateListener(valueAnimator -> {
        PointF animatedValue = (PointF) valueAnimator.getAnimatedValue();
        target.setX(animatedValue.x);
        target.setY(animatedValue.y);
        target.setAlpha(1 - valueAnimator.getAnimatedFraction());
    });
    return animator;
}
Also used : PointF(android.graphics.PointF) ValueAnimator(android.animation.ValueAnimator)

Example 62 with ValueAnimator

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

the class Sample2Activity method simulateErrorProgress.

private void simulateErrorProgress(final CircularProgressButton button) {
    ValueAnimator widthAnimation = ValueAnimator.ofInt(1, 99);
    widthAnimation.setDuration(1500);
    widthAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
    widthAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            Integer value = (Integer) animation.getAnimatedValue();
            button.setProgress(value);
            if (value == 99) {
                button.setProgress(-1);
            }
        }
    });
    widthAnimation.start();
}
Also used : AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) ValueAnimator(android.animation.ValueAnimator)

Example 63 with ValueAnimator

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

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)) * 500f / 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 64 with ValueAnimator

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

the class NotificationPanelView method flingSettings.

private void flingSettings(float vel, boolean expand, final Runnable onFinishRunnable, boolean isClick) {
    float target = expand ? mQsMaxExpansionHeight : mQsMinExpansionHeight;
    if (target == mQsExpansionHeight) {
        if (onFinishRunnable != null) {
            onFinishRunnable.run();
        }
        return;
    }
    boolean belowFalsingThreshold = isFalseTouch();
    if (belowFalsingThreshold) {
        vel = 0;
    }
    ValueAnimator animator = ValueAnimator.ofFloat(mQsExpansionHeight, target);
    if (isClick) {
        animator.setInterpolator(Interpolators.TOUCH_RESPONSE);
        animator.setDuration(368);
    } else {
        mFlingAnimationUtils.apply(animator, mQsExpansionHeight, target, vel);
    }
    if (belowFalsingThreshold) {
        animator.setDuration(350);
    }
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            setQsExpansion((Float) animation.getAnimatedValue());
        }
    });
    animator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mQsExpansionAnimator = null;
            if (onFinishRunnable != null) {
                onFinishRunnable.run();
            }
        }
    });
    animator.start();
    mQsExpansionAnimator = animator;
    mQsAnimatorExpand = expand;
}
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 65 with ValueAnimator

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

the class NotificationPanelView method animateKeyguardStatusBarOut.

private void animateKeyguardStatusBarOut() {
    ValueAnimator anim = ValueAnimator.ofFloat(mKeyguardStatusBar.getAlpha(), 0f);
    anim.addUpdateListener(mStatusBarAnimateAlphaListener);
    anim.setStartDelay(mStatusBar.isKeyguardFadingAway() ? mStatusBar.getKeyguardFadingAwayDelay() : 0);
    anim.setDuration(mStatusBar.isKeyguardFadingAway() ? mStatusBar.getKeyguardFadingAwayDuration() / 2 : StackStateAnimator.ANIMATION_DURATION_STANDARD);
    anim.setInterpolator(Interpolators.LINEAR_OUT_SLOW_IN);
    anim.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mAnimateKeyguardStatusBarInvisibleEndRunnable.run();
        }
    });
    anim.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)

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