Search in sources :

Example 86 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project NewPipe by TeamNewPipe.

the class AnimationUtils method animateBackgroundColor.

/**
 * Animate the background color of a view
 */
public static void animateBackgroundColor(final View view, long duration, @ColorInt final int colorStart, @ColorInt final int colorEnd) {
    if (DEBUG) {
        Log.d(TAG, "animateBackgroundColor() called with: view = [" + view + "], duration = [" + duration + "], colorStart = [" + colorStart + "], colorEnd = [" + colorEnd + "]");
    }
    final int[][] EMPTY = new int[][] { new int[0] };
    ValueAnimator viewPropertyAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), colorStart, colorEnd);
    viewPropertyAnimator.setInterpolator(new FastOutSlowInInterpolator());
    viewPropertyAnimator.setDuration(duration);
    viewPropertyAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            ViewCompat.setBackgroundTintList(view, new ColorStateList(EMPTY, new int[] { (int) animation.getAnimatedValue() }));
        }
    });
    viewPropertyAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            ViewCompat.setBackgroundTintList(view, new ColorStateList(EMPTY, new int[] { colorEnd }));
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            onAnimationEnd(animation);
        }
    });
    viewPropertyAnimator.start();
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ArgbEvaluator(android.animation.ArgbEvaluator) FastOutSlowInInterpolator(android.support.v4.view.animation.FastOutSlowInInterpolator) ColorStateList(android.content.res.ColorStateList) ValueAnimator(android.animation.ValueAnimator)

Example 87 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project animate by hitherejoe.

the class ForegroundFrame method animateForegroundColor.

private void animateForegroundColor(@ColorInt final int targetColor) {
    ObjectAnimator animator = ObjectAnimator.ofInt(this, FOREGROUND_COLOR, Color.TRANSPARENT, targetColor);
    animator.setEvaluator(new ArgbEvaluator());
    animator.setStartDelay(DELAY_COLOR_CHANGE);
    animator.start();
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) ArgbEvaluator(android.animation.ArgbEvaluator)

Example 88 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project android-app by spark.

the class Pin method getCancelAnimator.

Animator getCancelAnimator() {
    ObjectAnimator backToTransparent1 = (ObjectAnimator) AnimatorInflater.loadAnimator(view.getContext(), R.animator.pin_background_end);
    ObjectAnimator goDark = (ObjectAnimator) AnimatorInflater.loadAnimator(view.getContext(), R.animator.pin_background_go_dark);
    ObjectAnimator backToTransparent2 = (ObjectAnimator) AnimatorInflater.loadAnimator(view.getContext(), R.animator.pin_background_end);
    ViewGroup parent = (ViewGroup) view.getParent();
    ArgbEvaluator evaluator = new ArgbEvaluator();
    for (ObjectAnimator animator : list(backToTransparent1, goDark, backToTransparent2)) {
        animator.setTarget(parent);
        animator.setEvaluator(evaluator);
    }
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.setTarget(parent);
    animatorSet.playSequentially(backToTransparent1, goDark, backToTransparent2);
    return animatorSet;
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) ViewGroup(android.view.ViewGroup) ArgbEvaluator(android.animation.ArgbEvaluator) AnimatorSet(android.animation.AnimatorSet)

Example 89 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project Depth-LIB-Android- by danielzeller.

the class RootActivity method fadeColorTo.

private void fadeColorTo(int newColor, TextView view) {
    ObjectAnimator color = ObjectAnimator.ofObject(view, "TextColor", new ArgbEvaluator(), view.getCurrentTextColor(), newColor);
    color.setDuration(200);
    color.start();
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) ArgbEvaluator(android.animation.ArgbEvaluator)

Example 90 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project Depth-LIB-Android- by danielzeller.

the class ParticleSystem method setColors.

public void setColors(int startColor, int endColor) {
    this.startColor = startColor;
    this.endColor = endColor;
    color = ValueAnimator.ofObject(new ArgbEvaluator(), startColor, endColor, Color.TRANSPARENT).setDuration(DURATION);
}
Also used : ArgbEvaluator(android.animation.ArgbEvaluator)

Aggregations

ArgbEvaluator (android.animation.ArgbEvaluator)107 ValueAnimator (android.animation.ValueAnimator)68 ObjectAnimator (android.animation.ObjectAnimator)29 Animator (android.animation.Animator)23 View (android.view.View)15 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)13 TextView (android.widget.TextView)9 ColorDrawable (android.graphics.drawable.ColorDrawable)8 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)7 AnimatorSet (android.animation.AnimatorSet)6 PropertyValuesHolder (android.animation.PropertyValuesHolder)6 Paint (android.graphics.Paint)6 AnimatorListener (android.animation.Animator.AnimatorListener)5 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)5 TargetApi (android.annotation.TargetApi)4 Handler (android.os.Handler)4 ViewGroup (android.view.ViewGroup)4 SuppressLint (android.annotation.SuppressLint)3 ColorFilter (android.graphics.ColorFilter)3 LightingColorFilter (android.graphics.LightingColorFilter)3