Search in sources :

Example 46 with ValueAnimator

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

the class AssistInteractionSession method playAssistAnimation.

private void playAssistAnimation() {
    Interpolator linearOutSlowIn = AnimationUtils.loadInterpolator(mBackground.getContext(), android.R.interpolator.linear_out_slow_in);
    Interpolator fastOutSlowIn = AnimationUtils.loadInterpolator(mBackground.getContext(), android.R.interpolator.fast_out_slow_in);
    mScrim.setAlpha(0f);
    mScrim.animate().alpha(1f).setStartDelay(100).setDuration(500);
    mBackground.setTranslationY(50 * mDensity);
    mBackground.animate().translationY(0).setDuration(300).setInterpolator(linearOutSlowIn);
    int centerX = mBackground.getWidth() / 2;
    int centerY = (int) (mBackground.getHeight() / 5 * 3.8f);
    int radius = (int) Math.sqrt(centerX * centerX + centerY * centerY) + 1;
    Animator animator = ViewAnimationUtils.createCircularReveal(mBackground, centerX, centerY, 0, radius);
    animator.setDuration(300);
    animator.setInterpolator(fastOutSlowIn);
    animator.start();
    ValueAnimator colorAnim = ValueAnimator.ofArgb(Color.WHITE, 0xffe0e0e0);
    colorAnim.setDuration(300);
    colorAnim.setInterpolator(fastOutSlowIn);
    colorAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mBackground.setBackgroundColor((Integer) animation.getAnimatedValue());
        }
    });
    colorAnim.start();
    mCard1.setY(mBackground.getHeight());
    mCard2.setTranslationY(mCard1.getTranslationY());
    mCard1.animate().translationY(0).setDuration(500).setInterpolator(linearOutSlowIn).setStartDelay(100);
    mCard2.animate().translationY(0).setInterpolator(linearOutSlowIn).setStartDelay(150).setDuration(500);
    mNavbarScrim.setAlpha(0f);
    mNavbarScrim.animate().alpha(1f).setDuration(500).setStartDelay(100);
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) Interpolator(android.view.animation.Interpolator) ValueAnimator(android.animation.ValueAnimator)

Example 47 with ValueAnimator

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

the class BatteryMeterDrawable method animateSolidBattery.

public void animateSolidBattery(int level, boolean pluggedIn, boolean charging) {
    if (charging) {
        if (mAnimator != null)
            mAnimator.cancel();
        final int defaultAlpha = mLevelDrawable.getAlpha();
        mAnimator = ValueAnimator.ofInt(defaultAlpha, 0, defaultAlpha);
        mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                mLevelDrawable.setAlpha((int) animation.getAnimatedValue());
                invalidateSelf();
            }
        });
        mAnimator.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationCancel(Animator animation) {
                mLevelDrawable.setAlpha(defaultAlpha);
                mAnimator = null;
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                mLevelDrawable.setAlpha(defaultAlpha);
                mAnimator = null;
            }
        });
        mAnimator.setDuration(2000);
        mAnimator.start();
    }
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ValueAnimator(android.animation.ValueAnimator) Paint(android.graphics.Paint)

Example 48 with ValueAnimator

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

the class BatteryMeterDrawable method animateCircleBattery.

public void animateCircleBattery(int level, boolean pluggedIn, boolean charging) {
    if (charging) {
        if (mAnimator != null)
            mAnimator.cancel();
        final int defaultAlpha = mLevelDrawable.getAlpha();
        mAnimator = ValueAnimator.ofInt(defaultAlpha, 0, defaultAlpha);
        mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                mLevelDrawable.setAlpha((int) animation.getAnimatedValue());
                invalidateSelf();
            }
        });
        mAnimator.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationCancel(Animator animation) {
                mLevelDrawable.setAlpha(defaultAlpha);
                mAnimator = null;
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                mLevelDrawable.setAlpha(defaultAlpha);
                mAnimator = null;
            }
        });
        mAnimator.setDuration(2000);
        mAnimator.start();
    }
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ValueAnimator(android.animation.ValueAnimator) Paint(android.graphics.Paint)

Example 49 with ValueAnimator

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

the class KeyguardAffordanceView method setImageScale.

/**
     * Sets the scale of the containing image
     *
     * @param imageScale The new Scale.
     * @param animate Should an animation be performed
     * @param duration If animate, whats the duration? When -1 we take the default duration
     * @param interpolator If animate, whats the interpolator? When null we take the default
     *                     interpolator.
     */
public void setImageScale(float imageScale, boolean animate, long duration, Interpolator interpolator) {
    cancelAnimator(mScaleAnimator);
    if (!animate) {
        mImageScale = imageScale;
        invalidate();
    } else {
        ValueAnimator animator = ValueAnimator.ofFloat(mImageScale, imageScale);
        mScaleAnimator = animator;
        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                mImageScale = (float) animation.getAnimatedValue();
                invalidate();
            }
        });
        animator.addListener(mScaleEndListener);
        if (interpolator == null) {
            interpolator = imageScale == 0.0f ? Interpolators.FAST_OUT_LINEAR_IN : Interpolators.LINEAR_OUT_SLOW_IN;
        }
        animator.setInterpolator(interpolator);
        if (duration == -1) {
            float durationFactor = Math.abs(mImageScale - imageScale) / (1.0f - MIN_ICON_SCALE_AMOUNT);
            durationFactor = Math.min(1.0f, durationFactor);
            duration = (long) (NORMAL_ANIMATION_DURATION * durationFactor);
        }
        animator.setDuration(duration);
        animator.start();
    }
}
Also used : ValueAnimator(android.animation.ValueAnimator)

Example 50 with ValueAnimator

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

the class KeyguardAffordanceView method setCircleRadius.

private void setCircleRadius(float circleRadius, boolean slowAnimation, boolean noAnimation) {
    // Check if we need a new animation
    boolean radiusHidden = (mCircleAnimator != null && mCircleWillBeHidden) || (mCircleAnimator == null && mCircleRadius == 0.0f);
    boolean nowHidden = circleRadius == 0.0f;
    boolean radiusNeedsAnimation = (radiusHidden != nowHidden) && !noAnimation;
    if (!radiusNeedsAnimation) {
        if (mCircleAnimator == null) {
            mCircleRadius = circleRadius;
            updateIconColor();
            invalidate();
            if (nowHidden) {
                if (mPreviewView != null) {
                    mPreviewView.setVisibility(View.INVISIBLE);
                }
            }
        } else if (!mCircleWillBeHidden) {
            // We just update the end value
            float diff = circleRadius - mMinBackgroundRadius;
            PropertyValuesHolder[] values = mCircleAnimator.getValues();
            values[0].setFloatValues(mCircleStartValue + diff, circleRadius);
            mCircleAnimator.setCurrentPlayTime(mCircleAnimator.getCurrentPlayTime());
        }
    } else {
        cancelAnimator(mCircleAnimator);
        cancelAnimator(mPreviewClipper);
        ValueAnimator animator = getAnimatorToRadius(circleRadius);
        Interpolator interpolator = circleRadius == 0.0f ? Interpolators.FAST_OUT_LINEAR_IN : Interpolators.LINEAR_OUT_SLOW_IN;
        animator.setInterpolator(interpolator);
        long duration = 250;
        if (!slowAnimation) {
            float durationFactor = Math.abs(mCircleRadius - circleRadius) / (float) mMinBackgroundRadius;
            duration = (long) (CIRCLE_APPEAR_DURATION * durationFactor);
            duration = Math.min(duration, CIRCLE_DISAPPEAR_MAX_DURATION);
        }
        animator.setDuration(duration);
        animator.start();
        if (mPreviewView != null && mPreviewView.getVisibility() == View.VISIBLE) {
            mPreviewView.setVisibility(View.VISIBLE);
            mPreviewClipper = ViewAnimationUtils.createCircularReveal(mPreviewView, getLeft() + mCenterX, getTop() + mCenterY, mCircleRadius, circleRadius);
            mPreviewClipper.setInterpolator(interpolator);
            mPreviewClipper.setDuration(duration);
            mPreviewClipper.addListener(mClipEndListener);
            mPreviewClipper.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    mPreviewView.setVisibility(View.INVISIBLE);
                }
            });
            mPreviewClipper.start();
        }
    }
}
Also used : Animator(android.animation.Animator) RenderNodeAnimator(android.view.RenderNodeAnimator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) Interpolator(android.view.animation.Interpolator) 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