Search in sources :

Example 11 with PathInterpolator

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

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 12 with PathInterpolator

use of android.view.animation.PathInterpolator in project Android-Material-Examples by saulmm.

the class GUIUtils method configureWindowEnterExitExplodeTransition.

public static void configureWindowEnterExitExplodeTransition(Window w) {
    Fade ex = new Fade();
    ex.setInterpolator(new PathInterpolator(0.4f, 0, 1, 1));
    ex.setDuration(5000);
    w.setExitTransition(ex);
    w.setEnterTransition(ex);
}
Also used : PathInterpolator(android.view.animation.PathInterpolator) Fade(android.transition.Fade)

Aggregations

PathInterpolator (android.view.animation.PathInterpolator)12 Animator (android.animation.Animator)5 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)5 ValueAnimator (android.animation.ValueAnimator)5 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)5 Interpolator (android.view.animation.Interpolator)5 Path (android.graphics.Path)1 Fade (android.transition.Fade)1