Example usage for android.animation ObjectAnimator setEvaluator

List of usage examples for android.animation ObjectAnimator setEvaluator

Introduction

In this page you can find the example usage for android.animation ObjectAnimator setEvaluator.

Prototype

public void setEvaluator(TypeEvaluator value) 

Source Link

Document

The type evaluator to be used when calculating the animated values of this animation.

Usage

From source file:Main.java

public static <T> ObjectAnimator ofArgb(T target, Property<T, Integer> property, int... values) {
    ObjectAnimator animator = ObjectAnimator.ofInt(target, property, values);
    animator.setEvaluator(ARGB_EVALUATOR);
    return animator;
}

From source file:Main.java

public static void animateColorChange(View view, int fromColor, int toColor, int duration,
        Animator.AnimatorListener listener) {
    if (view.getWindowToken() == null) {
        return;/*w  w  w .j av a2  s . c o m*/
    }
    AnimatorSet animation = new AnimatorSet();
    ObjectAnimator colorAnimator = ObjectAnimator.ofInt(view, COLOR_PROPERTY, fromColor, toColor);
    colorAnimator.setEvaluator(new ArgbEvaluator());
    colorAnimator.setDuration(duration);
    if (listener != null)
        animation.addListener(listener);
    animation.play(colorAnimator);
    animation.start();
}

From source file:Main.java

public static void showBackgroundColorAnimation(View view, int preColor, int currColor, int duration) {
    ObjectAnimator animator = ObjectAnimator.ofInt(view, "backgroundColor", new int[] { preColor, currColor });
    animator.setDuration(duration);//from  ww w.  j a va  2s.  c o  m
    animator.setEvaluator(new ArgbEvaluator());
    animator.start();
}

From source file:Main.java

public static void showCardBackgroundColorAnimation(View view, int preColor, int currColor, int duration) {
    ObjectAnimator animator = ObjectAnimator.ofInt(view, "cardBackgroundColor",
            new int[] { preColor, currColor });
    animator.setDuration(duration);//from  w  ww .  ja  v  a  2  s .c om
    animator.setEvaluator(new ArgbEvaluator());
    animator.start();
}

From source file:Main.java

public static void showBackgroundColorAnimation(View view, int preColor, int currColor, int duration) {
    ObjectAnimator localObjectAnimator = ObjectAnimator.ofInt(view, "backgroundColor",
            new int[] { preColor, currColor });
    localObjectAnimator.setDuration(duration);
    localObjectAnimator.setEvaluator(new ArgbEvaluator());
    localObjectAnimator.start();/*from  w  w w  .j  a  v  a 2  s  . c o m*/
}

From source file:com.google.samples.apps.ourstreets.view.ViewUtils.java

/**
 * Create a color change animation over a foreground property of a {@link FrameLayout}.
 *
 * @param target The target view.// w ww. j a va2s .c  o m
 * @param startColorRes The color to start from.
 * @param targetColorRes The color this animation will end with.
 * @param interpolator The interpolator to use.
 * @return The color change animation.
 */
@NonNull
public static ObjectAnimator createColorChange(@NonNull FrameLayout target, @ColorRes int startColorRes,
        @ColorRes int targetColorRes, @NonNull Interpolator interpolator) {
    Context context = target.getContext();
    final int startColor = ContextCompat.getColor(context, startColorRes);
    final int targetColor = ContextCompat.getColor(context, targetColorRes);
    ObjectAnimator colorChange = ObjectAnimator.ofInt(target, ViewUtils.FOREGROUND_COLOR, startColor,
            targetColor);
    colorChange.setEvaluator(new ArgbEvaluator());
    colorChange.setInterpolator(interpolator);
    colorChange.setDuration(context.getResources().getInteger(android.R.integer.config_longAnimTime));
    return colorChange;
}

From source file:com.hippo.android.animator.AnimatorsBase.java

static Animator recolorText(TextView view, int startColor, int endColor) {
    if (startColor != endColor) {
        ObjectAnimator animator = ObjectAnimator.ofInt(view, TEXT_VIEW_COLOR_PROPERTY, startColor, endColor);
        animator.setEvaluator(new ArgbEvaluator());
        return animator;
    }/*from   w w  w  .j a v  a  2  s .co m*/
    return null;
}

From source file:com.hippo.android.animator.AnimatorsBase.java

static Animator recolorBackground(View view, int startColor, int endColor) {
    if (startColor != endColor) {
        Drawable drawable = view.getBackground();
        if (drawable instanceof ColorDrawable) {
            ObjectAnimator animator = ObjectAnimator.ofInt((ColorDrawable) drawable,
                    COLOR_DRAWABLE_COLOR_PROPERTY, startColor, endColor);
            animator.setEvaluator(new ArgbEvaluator());
            return animator;
        }//w  w  w  . j av a2 s  .co  m
    }
    return null;
}

From source file:com.google.samples.apps.topeka.widget.quiz.AbsQuizView.java

private void animateForegroundColor(@ColorInt final int targetColor) {
    ObjectAnimator animator = ObjectAnimator.ofInt(this, ViewUtils.FOREGROUND_COLOR, Color.TRANSPARENT,
            targetColor);/*  w w  w  . jav a 2 s  .c om*/
    animator.setEvaluator(new ArgbEvaluator());
    animator.setStartDelay(FOREGROUND_COLOR_CHANGE_DELAY);
    animator.start();
}

From source file:com.cyanogenmod.eleven.ui.activities.HomeActivity.java

private void updateStatusBarColor(int color) {
    final Window window = getWindow();
    ObjectAnimator animator = ObjectAnimator.ofInt(window, "statusBarColor", window.getStatusBarColor(), color);
    animator.setEvaluator(new ArgbEvaluator());
    animator.setDuration(300);/*from ww w . ja v  a  2  s .c o m*/
    animator.start();
}