Example usage for android.animation ValueAnimator getDuration

List of usage examples for android.animation ValueAnimator getDuration

Introduction

In this page you can find the example usage for android.animation ValueAnimator getDuration.

Prototype

@Override
public long getDuration() 

Source Link

Document

Gets the length of the animation.

Usage

From source file:Main.java

public static float getAnimatedFraction(ValueAnimator animator) {
    float fraction = animator.getDuration() > 0L
            ? (float) animator.getCurrentPlayTime() / (float) animator.getDuration()
            : 0.0F;//from  www.j a va 2 s.c om
    fraction = Math.min(fraction, 1.0F);
    fraction = animator.getInterpolator().getInterpolation(fraction);
    return fraction;
}

From source file:Main.java

static float getAnimatedFraction(ValueAnimator animator) {
    float fraction = animator.getDuration() > 0L
            ? (float) animator.getCurrentPlayTime() / (float) animator.getDuration()
            : 0.0F;//  w w w  . java2s  .com

    fraction = Math.min(fraction, 1.0F);
    fraction = animator.getInterpolator().getInterpolation(fraction);
    return fraction;
}

From source file:Main.java

static float getAnimatedFraction(ValueAnimator animator) {
    float fraction = animator.getDuration() > 0
            ? ((float) animator.getCurrentPlayTime()) / animator.getDuration()
            : 1f;/*ww w.ja va 2  s .  com*/

    fraction %= 1f;
    fraction = min(fraction, 1f);
    fraction = animator.getInterpolator().getInterpolation(fraction);
    return fraction;
}

From source file:Main.java

static float getAnimatedFraction(ValueAnimator animator) {
    float fraction = animator.getDuration() > 0
            ? ((float) animator.getCurrentPlayTime()) / animator.getDuration()
            : 0f;/*from   ww w.j  av  a 2s.  com*/

    fraction = min(fraction, 1f);
    fraction = animator.getInterpolator().getInterpolation(fraction);
    return fraction;
}

From source file:Main.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SuppressLint("NewApi")
static float getAnimatedFraction(ValueAnimator animator) {
    float fraction = animator.getDuration() > 0
            ? ((float) animator.getCurrentPlayTime()) / animator.getDuration()
            : 0f;//  www .  j a  va  2  s  .c  om

    fraction = min(fraction, 1f);
    fraction = animator.getInterpolator().getInterpolation(fraction);
    return fraction;
}

From source file:Main.java

public static float getAnimatedFraction(ValueAnimator animator) {
    float fraction = ((float) animator.getCurrentPlayTime()) / animator.getDuration();
    fraction = Math.min(fraction, 1f);
    fraction = animator.getInterpolator().getInterpolation(fraction);
    return fraction;
}

From source file:android.support.v17.leanback.app.PlaybackSupportFragment.java

private static ValueAnimator loadAnimator(Context context, int resId) {
    ValueAnimator animator = (ValueAnimator) AnimatorInflater.loadAnimator(context, resId);
    animator.setDuration(animator.getDuration() * ANIMATION_MULTIPLIER);
    return animator;
}

From source file:com.android.deskclock.AnimatorUtils.java

public static void setAnimatedFraction(ValueAnimator animator, float fraction) {
    if (Utils.isLMR1OrLater()) {
        animator.setCurrentFraction(fraction);
        return;//from   ww w.  j  av a2 s  .  c o m
    }

    if (sTryAnimateValue) {
        // try to set the animated fraction directly so that it isn't affected by the
        // internal animator scale or time (b/17938711)
        try {
            if (sAnimateValue == null) {
                sAnimateValue = ValueAnimator.class.getDeclaredMethod("animateValue", float.class);
                sAnimateValue.setAccessible(true);
            }

            sAnimateValue.invoke(animator, fraction);
            return;
        } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
            // something went wrong, don't try that again
            LogUtils.e("Unable to use animateValue directly", e);
            sTryAnimateValue = false;
        }
    }

    // if that doesn't work then just fall back to setting the current play time
    animator.setCurrentPlayTime(Math.round(fraction * animator.getDuration()));
}

From source file:com.android.clear.reminder.AnimatorUtils.java

public static void setAnimatedFraction(ValueAnimator animator, float fraction) {
    if (Utils.isLMR1OrLater()) {
        animator.setCurrentFraction(fraction);
        return;/*  ww  w.  j a  va2 s.c o m*/
    }

    if (sTryAnimateValue) {
        // try to set the animated fraction directly so that it isn't affected by the
        // internal animator scale or time (b/17938711)
        try {
            if (sAnimateValue == null) {
                sAnimateValue = ValueAnimator.class.getDeclaredMethod("animateValue", float.class);
                sAnimateValue.setAccessible(true);
            }

            sAnimateValue.invoke(animator, fraction);
            return;
        } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
            // something went wrong, don't try that again
            L.e("Unable to use animateValue directly", e);
            sTryAnimateValue = false;
        }
    }

    // if that doesn't work then just fall back to setting the current play time
    animator.setCurrentPlayTime(Math.round(fraction * animator.getDuration()));
}

From source file:ch.berta.fabio.fabprogress.FabProgress.java

private float getAnimatedFraction(@NonNull ValueAnimator animator) {
    float fraction = ((float) animator.getCurrentPlayTime()) / animator.getDuration();
    fraction = Math.min(fraction, 1f);
    fraction = animator.getInterpolator().getInterpolation(fraction);
    return fraction;
}