Example usage for android.animation ValueAnimator getInterpolator

List of usage examples for android.animation ValueAnimator getInterpolator

Introduction

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

Prototype

@Override
public TimeInterpolator getInterpolator() 

Source Link

Document

Returns the timing interpolator that this ValueAnimator uses.

Usage

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:Main.java

public static float getAnimatedFraction(ValueAnimator animator) {
    float fraction = animator.getDuration() > 0L
            ? (float) animator.getCurrentPlayTime() / (float) animator.getDuration()
            : 0.0F;/* www .java 2 s.co m*/
    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()
            : 0f;//from   ww w.  ja v  a 2s. co m

    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() > 0L
            ? (float) animator.getCurrentPlayTime() / (float) animator.getDuration()
            : 0.0F;/*from   ww w  . ja v a  2 s  .c o m*/

    fraction = Math.min(fraction, 1.0F);
    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;//from  www.jav  a  2s  .c o  m

    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()
            : 1f;//from   w w  w .j  a v a  2  s.  c  o  m

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

From source file:com.taobao.weex.ui.animation.DimensionUpdateListener.java

@Override
public void onAnimationUpdate(ValueAnimator animation) {
    if (view.getLayoutParams() != null) {
        ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
        TimeInterpolator interpolator = animation.getInterpolator();
        float fraction = animation.getAnimatedFraction();
        int preWidth = layoutParams.width;
        int preHeight = layoutParams.height;
        if (width != null) {
            layoutParams.width = intEvaluator.evaluate(interpolator.getInterpolation(fraction), width.first,
                    width.second);/*  w w w  .  ja v  a 2 s  . c om*/
        }
        if (height != null) {
            layoutParams.height = intEvaluator.evaluate(interpolator.getInterpolation(fraction), height.first,
                    height.second);
        }
        if (preHeight != layoutParams.height || preWidth != layoutParams.width) {
            view.requestLayout();
        }
    }
}

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;
}

From source file:com.justplay1.shoppist.features.search.widget.FloatingSearchView.java

private void fadeIn(boolean enter) {
    ValueAnimator backgroundAnim;

    if (Build.VERSION.SDK_INT >= 19) {
        backgroundAnim = ObjectAnimator.ofInt(backgroundDrawable, "alpha", enter ? 255 : 0);
    } else {/*  w w w .  j ava 2  s . c o m*/
        backgroundAnim = ValueAnimator.ofInt(enter ? 0 : 255, enter ? 255 : 0);
        backgroundAnim.addUpdateListener(animation -> {
            int value = (Integer) animation.getAnimatedValue();
            backgroundDrawable.setAlpha(value);
        });
    }

    backgroundAnim.setDuration(enter ? DEFAULT_DURATION_ENTER : DEFAULT_DURATION_EXIT);
    backgroundAnim.setInterpolator(enter ? DECELERATE : ACCELERATE);
    backgroundAnim.start();

    Drawable icon = unwrap(getIcon());

    if (icon != null) {
        ObjectAnimator iconAnim = ObjectAnimator.ofFloat(icon, "progress", enter ? 1 : 0);
        iconAnim.setDuration(backgroundAnim.getDuration());
        iconAnim.setInterpolator(backgroundAnim.getInterpolator());
        iconAnim.start();
    }
}