Search in sources :

Example 1 with PathInterpolator

use of android.view.animation.PathInterpolator in project android_frameworks_base by ResurrectionRemix.

the class VolumeDialogMotion method startShowAnimation.

private void startShowAnimation() {
    if (D.BUG)
        Log.d(TAG, "startShowAnimation");
    mDialogView.animate().translationY(0).setDuration(scaledDuration(300)).setInterpolator(new LogDecelerateInterpolator()).setListener(null).setUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            if (mChevronPositionAnimator == null)
                return;
            // reposition chevron
            final float v = (Float) mChevronPositionAnimator.getAnimatedValue();
            final int posY = chevronPosY();
            mChevron.setTranslationY(posY + v + -mDialogView.getTranslationY());
        }
    }).start();
    mContentsPositionAnimator = ValueAnimator.ofFloat(-chevronDistance(), 0).setDuration(scaledDuration(400));
    mContentsPositionAnimator.addListener(new AnimatorListenerAdapter() {

        private boolean mCancelled;

        @Override
        public void onAnimationEnd(Animator animation) {
            if (mCancelled)
                return;
            if (D.BUG)
                Log.d(TAG, "show.onAnimationEnd");
            setShowing(false);
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            if (D.BUG)
                Log.d(TAG, "show.onAnimationCancel");
            mCancelled = true;
        }
    });
    mContentsPositionAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float v = (Float) animation.getAnimatedValue();
            mContents.setTranslationY(v + -mDialogView.getTranslationY());
        }
    });
    mContentsPositionAnimator.setInterpolator(new LogDecelerateInterpolator());
    mContentsPositionAnimator.start();
    mContents.setAlpha(0);
    mContents.animate().alpha(1).setDuration(scaledDuration(150)).setInterpolator(new PathInterpolator(0f, 0f, .2f, 1f)).start();
    mChevronPositionAnimator = ValueAnimator.ofFloat(-chevronDistance(), 0).setDuration(scaledDuration(250));
    mChevronPositionAnimator.setInterpolator(new PathInterpolator(.4f, 0f, .2f, 1f));
    mChevronPositionAnimator.start();
    mChevron.setAlpha(0);
    mChevron.animate().alpha(1).setStartDelay(scaledDuration(50)).setDuration(scaledDuration(150)).setInterpolator(new PathInterpolator(.4f, 0f, 1f, 1f)).start();
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator) PathInterpolator(android.view.animation.PathInterpolator)

Example 2 with PathInterpolator

use of android.view.animation.PathInterpolator in project android_frameworks_base by ResurrectionRemix.

the class FlingAnimationUtils method getDismissingProperties.

private AnimatorProperties getDismissingProperties(float currValue, float endValue, float velocity, float maxDistance) {
    float maxLengthSeconds = (float) (mMaxLengthSeconds * Math.pow(Math.abs(endValue - currValue) / maxDistance, 0.5f));
    float diff = Math.abs(endValue - currValue);
    float velAbs = Math.abs(velocity);
    float y2 = calculateLinearOutFasterInY2(velAbs);
    float startGradient = y2 / LINEAR_OUT_FASTER_IN_X2;
    Interpolator mLinearOutFasterIn = new PathInterpolator(0, 0, LINEAR_OUT_FASTER_IN_X2, y2);
    float durationSeconds = startGradient * diff / velAbs;
    if (durationSeconds <= maxLengthSeconds) {
        mAnimatorProperties.interpolator = mLinearOutFasterIn;
    } else if (velAbs >= mMinVelocityPxPerSecond) {
        // Cross fade between linear-out-faster-in and linear interpolator with current
        // velocity.
        durationSeconds = maxLengthSeconds;
        VelocityInterpolator velocityInterpolator = new VelocityInterpolator(durationSeconds, velAbs, diff);
        InterpolatorInterpolator superInterpolator = new InterpolatorInterpolator(velocityInterpolator, mLinearOutFasterIn, mLinearOutSlowIn);
        mAnimatorProperties.interpolator = superInterpolator;
    } else {
        // Just use a normal interpolator which doesn't take the velocity into account.
        durationSeconds = maxLengthSeconds;
        mAnimatorProperties.interpolator = Interpolators.FAST_OUT_LINEAR_IN;
    }
    mAnimatorProperties.duration = (long) (durationSeconds * 1000);
    return mAnimatorProperties;
}
Also used : PathInterpolator(android.view.animation.PathInterpolator) Interpolator(android.view.animation.Interpolator) PathInterpolator(android.view.animation.PathInterpolator)

Example 3 with PathInterpolator

use of android.view.animation.PathInterpolator in project android_frameworks_base by DirtyUnicorns.

the class VolumeDialogMotion method startShowAnimation.

private void startShowAnimation() {
    if (D.BUG)
        Log.d(TAG, "startShowAnimation");
    mDialogView.animate().translationY(0).setDuration(scaledDuration(300)).setInterpolator(new LogDecelerateInterpolator()).setListener(null).setUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            if (mChevronPositionAnimator == null)
                return;
            // reposition chevron
            final float v = (Float) mChevronPositionAnimator.getAnimatedValue();
            final int posY = chevronPosY();
            mChevron.setTranslationY(posY + v + -mDialogView.getTranslationY());
        }
    }).start();
    mContentsPositionAnimator = ValueAnimator.ofFloat(-chevronDistance(), 0).setDuration(scaledDuration(400));
    mContentsPositionAnimator.addListener(new AnimatorListenerAdapter() {

        private boolean mCancelled;

        @Override
        public void onAnimationEnd(Animator animation) {
            if (mCancelled)
                return;
            if (D.BUG)
                Log.d(TAG, "show.onAnimationEnd");
            setShowing(false);
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            if (D.BUG)
                Log.d(TAG, "show.onAnimationCancel");
            mCancelled = true;
        }
    });
    mContentsPositionAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float v = (Float) animation.getAnimatedValue();
            mContents.setTranslationY(v + -mDialogView.getTranslationY());
        }
    });
    mContentsPositionAnimator.setInterpolator(new LogDecelerateInterpolator());
    mContentsPositionAnimator.start();
    mContents.setAlpha(0);
    mContents.animate().alpha(1).setDuration(scaledDuration(150)).setInterpolator(new PathInterpolator(0f, 0f, .2f, 1f)).start();
    mChevronPositionAnimator = ValueAnimator.ofFloat(-chevronDistance(), 0).setDuration(scaledDuration(250));
    mChevronPositionAnimator.setInterpolator(new PathInterpolator(.4f, 0f, .2f, 1f));
    mChevronPositionAnimator.start();
    mChevron.setAlpha(0);
    mChevron.animate().alpha(1).setStartDelay(scaledDuration(50)).setDuration(scaledDuration(150)).setInterpolator(new PathInterpolator(.4f, 0f, 1f, 1f)).start();
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator) PathInterpolator(android.view.animation.PathInterpolator)

Example 4 with PathInterpolator

use of android.view.animation.PathInterpolator in project android_frameworks_base by AOSPA.

the class FlingAnimationUtils method getDismissingProperties.

private AnimatorProperties getDismissingProperties(float currValue, float endValue, float velocity, float maxDistance) {
    float maxLengthSeconds = (float) (mMaxLengthSeconds * Math.pow(Math.abs(endValue - currValue) / maxDistance, 0.5f));
    float diff = Math.abs(endValue - currValue);
    float velAbs = Math.abs(velocity);
    float y2 = calculateLinearOutFasterInY2(velAbs);
    float startGradient = y2 / LINEAR_OUT_FASTER_IN_X2;
    Interpolator mLinearOutFasterIn = new PathInterpolator(0, 0, LINEAR_OUT_FASTER_IN_X2, y2);
    float durationSeconds = startGradient * diff / velAbs;
    if (durationSeconds <= maxLengthSeconds) {
        mAnimatorProperties.interpolator = mLinearOutFasterIn;
    } else if (velAbs >= mMinVelocityPxPerSecond) {
        // Cross fade between linear-out-faster-in and linear interpolator with current
        // velocity.
        durationSeconds = maxLengthSeconds;
        VelocityInterpolator velocityInterpolator = new VelocityInterpolator(durationSeconds, velAbs, diff);
        InterpolatorInterpolator superInterpolator = new InterpolatorInterpolator(velocityInterpolator, mLinearOutFasterIn, mLinearOutSlowIn);
        mAnimatorProperties.interpolator = superInterpolator;
    } else {
        // Just use a normal interpolator which doesn't take the velocity into account.
        durationSeconds = maxLengthSeconds;
        mAnimatorProperties.interpolator = Interpolators.FAST_OUT_LINEAR_IN;
    }
    mAnimatorProperties.duration = (long) (durationSeconds * 1000);
    return mAnimatorProperties;
}
Also used : PathInterpolator(android.view.animation.PathInterpolator) Interpolator(android.view.animation.Interpolator) PathInterpolator(android.view.animation.PathInterpolator)

Example 5 with PathInterpolator

use of android.view.animation.PathInterpolator in project platform_frameworks_base by android.

the class FlingAnimationUtils method getDismissingProperties.

private AnimatorProperties getDismissingProperties(float currValue, float endValue, float velocity, float maxDistance) {
    float maxLengthSeconds = (float) (mMaxLengthSeconds * Math.pow(Math.abs(endValue - currValue) / maxDistance, 0.5f));
    float diff = Math.abs(endValue - currValue);
    float velAbs = Math.abs(velocity);
    float y2 = calculateLinearOutFasterInY2(velAbs);
    float startGradient = y2 / LINEAR_OUT_FASTER_IN_X2;
    Interpolator mLinearOutFasterIn = new PathInterpolator(0, 0, LINEAR_OUT_FASTER_IN_X2, y2);
    float durationSeconds = startGradient * diff / velAbs;
    if (durationSeconds <= maxLengthSeconds) {
        mAnimatorProperties.interpolator = mLinearOutFasterIn;
    } else if (velAbs >= mMinVelocityPxPerSecond) {
        // Cross fade between linear-out-faster-in and linear interpolator with current
        // velocity.
        durationSeconds = maxLengthSeconds;
        VelocityInterpolator velocityInterpolator = new VelocityInterpolator(durationSeconds, velAbs, diff);
        InterpolatorInterpolator superInterpolator = new InterpolatorInterpolator(velocityInterpolator, mLinearOutFasterIn, mLinearOutSlowIn);
        mAnimatorProperties.interpolator = superInterpolator;
    } else {
        // Just use a normal interpolator which doesn't take the velocity into account.
        durationSeconds = maxLengthSeconds;
        mAnimatorProperties.interpolator = Interpolators.FAST_OUT_LINEAR_IN;
    }
    mAnimatorProperties.duration = (long) (durationSeconds * 1000);
    return mAnimatorProperties;
}
Also used : PathInterpolator(android.view.animation.PathInterpolator) Interpolator(android.view.animation.Interpolator) PathInterpolator(android.view.animation.PathInterpolator)

Aggregations

PathInterpolator (android.view.animation.PathInterpolator)15 Interpolator (android.view.animation.Interpolator)6 Animator (android.animation.Animator)5 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)5 ValueAnimator (android.animation.ValueAnimator)5 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)5 ArgbEvaluator (android.animation.ArgbEvaluator)1 ObjectAnimator (android.animation.ObjectAnimator)1 Path (android.graphics.Path)1 Fade (android.transition.Fade)1