Search in sources :

Example 26 with ValueAnimator

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

the class GlobalScreenshot method createScreenshotDropInAnimation.

private ValueAnimator createScreenshotDropInAnimation() {
    final float flashPeakDurationPct = ((float) (SCREENSHOT_FLASH_TO_PEAK_DURATION) / SCREENSHOT_DROP_IN_DURATION);
    final float flashDurationPct = 2f * flashPeakDurationPct;
    final Interpolator flashAlphaInterpolator = new Interpolator() {

        @Override
        public float getInterpolation(float x) {
            // Flash the flash view in and out quickly
            if (x <= flashDurationPct) {
                return (float) Math.sin(Math.PI * (x / flashDurationPct));
            }
            return 0;
        }
    };
    final Interpolator scaleInterpolator = new Interpolator() {

        @Override
        public float getInterpolation(float x) {
            // We start scaling when the flash is at it's peak
            if (x < flashPeakDurationPct) {
                return 0;
            }
            return (x - flashDurationPct) / (1f - flashDurationPct);
        }
    };
    ValueAnimator anim = ValueAnimator.ofFloat(0f, 1f);
    anim.setDuration(SCREENSHOT_DROP_IN_DURATION);
    anim.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationStart(Animator animation) {
            mBackgroundView.setAlpha(0f);
            mBackgroundView.setVisibility(View.VISIBLE);
            mScreenshotView.setAlpha(0f);
            mScreenshotView.setTranslationX(0f);
            mScreenshotView.setTranslationY(0f);
            mScreenshotView.setScaleX(SCREENSHOT_SCALE + mBgPaddingScale);
            mScreenshotView.setScaleY(SCREENSHOT_SCALE + mBgPaddingScale);
            mScreenshotView.setVisibility(View.VISIBLE);
            mScreenshotFlash.setAlpha(0f);
            mScreenshotFlash.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAnimationEnd(android.animation.Animator animation) {
            mScreenshotFlash.setVisibility(View.GONE);
        }
    });
    anim.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float t = (Float) animation.getAnimatedValue();
            float scaleT = (SCREENSHOT_SCALE + mBgPaddingScale) - scaleInterpolator.getInterpolation(t) * (SCREENSHOT_SCALE - SCREENSHOT_DROP_IN_MIN_SCALE);
            mBackgroundView.setAlpha(scaleInterpolator.getInterpolation(t) * BACKGROUND_ALPHA);
            mScreenshotView.setAlpha(t);
            mScreenshotView.setScaleX(scaleT);
            mScreenshotView.setScaleY(scaleT);
            mScreenshotFlash.setAlpha(flashAlphaInterpolator.getInterpolation(t));
        }
    });
    return anim;
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) Interpolator(android.view.animation.Interpolator) Animator(android.animation.Animator) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator)

Example 27 with ValueAnimator

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

the class KeyguardMultiUserAvatar method updateVisualsForActive.

void updateVisualsForActive(boolean active, boolean animate, int duration, final Runnable onComplete) {
    final float finalAlpha = active ? mActiveAlpha : mInactiveAlpha;
    final float initAlpha = active ? mInactiveAlpha : mActiveAlpha;
    final float finalScale = active ? 1f : 1f / mActiveScale;
    final float initScale = mFramed.getScale();
    final int finalTextAlpha = active ? (int) (mActiveTextAlpha * 255) : (int) (mInactiveTextAlpha * 255);
    final int initTextAlpha = active ? (int) (mInactiveTextAlpha * 255) : (int) (mActiveTextAlpha * 255);
    int textColor = mTextColor;
    mUserName.setTextColor(textColor);
    if (animate && mTouched) {
        ValueAnimator va = ValueAnimator.ofFloat(0f, 1f);
        va.addUpdateListener(new AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                float r = animation.getAnimatedFraction();
                float scale = (1 - r) * initScale + r * finalScale;
                float alpha = (1 - r) * initAlpha + r * finalAlpha;
                int textAlpha = (int) ((1 - r) * initTextAlpha + r * finalTextAlpha);
                mFramed.setScale(scale);
                mUserImage.setAlpha(alpha);
                mUserName.setTextColor(Color.argb(textAlpha, 255, 255, 255));
                mUserImage.invalidate();
            }
        });
        va.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                if (onComplete != null) {
                    onComplete.run();
                }
            }
        });
        va.setDuration(duration);
        va.start();
    } else {
        mFramed.setScale(finalScale);
        mUserImage.setAlpha(finalAlpha);
        mUserName.setTextColor(Color.argb(finalTextAlpha, 255, 255, 255));
        if (onComplete != null) {
            post(onComplete);
        }
    }
    mTouched = true;
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator)

Example 28 with ValueAnimator

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

the class KeyguardGlowStripView method makeEmGo.

public void makeEmGo() {
    if (mAnimator != null) {
        mAnimator.cancel();
    }
    float from = mLeftToRight ? 0f : 1f;
    float to = mLeftToRight ? 1f : 0f;
    mAnimator = ValueAnimator.ofFloat(from, to);
    mAnimator.setDuration(DURATION);
    mAnimator.setInterpolator(new LinearInterpolator());
    mAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mDrawDots = false;
            // make sure we draw one frame at the end with everything gone.
            invalidate();
        }

        @Override
        public void onAnimationStart(Animator animation) {
            mDrawDots = true;
        }
    });
    mAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mAnimationProgress = (Float) animation.getAnimatedValue();
            invalidate();
        }
    });
    mAnimator.start();
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) LinearInterpolator(android.view.animation.LinearInterpolator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator)

Example 29 with ValueAnimator

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

the class GLTextureViewActivity method onSurfaceTextureAvailable.

@Override
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
    mRenderThread = new RenderThread(getResources(), surface);
    mRenderThread.start();
    mTextureView.setCameraDistance(5000);
    ObjectAnimator animator = ObjectAnimator.ofFloat(mTextureView, "rotationY", 0.0f, 360.0f);
    animator.setRepeatMode(ObjectAnimator.REVERSE);
    animator.setRepeatCount(ObjectAnimator.INFINITE);
    animator.setDuration(4000);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mTextureView.invalidate();
        }
    });
    animator.start();
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator)

Example 30 with ValueAnimator

use of android.animation.ValueAnimator in project MPAndroidChart by PhilJay.

the class PieRadarChartBase method spin.

/**
     * ################ ################ ################ ################
     */
/** CODE BELOW THIS RELATED TO ANIMATION */
/**
     * Applys a spin animation to the Chart.
     *
     * @param durationmillis
     * @param fromangle
     * @param toangle
     */
@SuppressLint("NewApi")
public void spin(int durationmillis, float fromangle, float toangle, Easing.EasingOption easing) {
    if (android.os.Build.VERSION.SDK_INT < 11)
        return;
    setRotationAngle(fromangle);
    ObjectAnimator spinAnimator = ObjectAnimator.ofFloat(this, "rotationAngle", fromangle, toangle);
    spinAnimator.setDuration(durationmillis);
    spinAnimator.setInterpolator(Easing.getEasingFunctionFromOption(easing));
    spinAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            postInvalidate();
        }
    });
    spinAnimator.start();
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator) SuppressLint(android.annotation.SuppressLint)

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