Search in sources :

Example 91 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project welcome-coordinator by txusballesteros.

the class MainActivity method initializeBackgroundTransitions.

private void initializeBackgroundTransitions() {
    final Resources resources = getResources();
    final int colorPage1 = ResourcesCompat.getColor(resources, R.color.page1, getTheme());
    final int colorPage2 = ResourcesCompat.getColor(resources, R.color.page2, getTheme());
    final int colorPage3 = ResourcesCompat.getColor(resources, R.color.page3, getTheme());
    final int colorPage4 = ResourcesCompat.getColor(resources, R.color.page4, getTheme());
    backgroundAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), colorPage1, colorPage2, colorPage3, colorPage4);
    backgroundAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            coordinatorLayout.setBackgroundColor((int) animation.getAnimatedValue());
        }
    });
}
Also used : ArgbEvaluator(android.animation.ArgbEvaluator) Resources(android.content.res.Resources) ValueAnimator(android.animation.ValueAnimator)

Example 92 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project MusicLake by caiyonglong.

the class TransitionAnimationUtils method startColorAnimation.

/**
 * 颜色渐变动画
 */
public static void startColorAnimation(View mView, int newColor) {
    int olderColor = ((ColorDrawable) mView.getBackground()).getColor();
    ObjectAnimator objectAnimator;
    objectAnimator = ObjectAnimator.ofInt(mView, "backgroundColor", olderColor, newColor).setDuration(800);
    objectAnimator.setEvaluator(new ArgbEvaluator());
    objectAnimator.start();
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) ObjectAnimator(android.animation.ObjectAnimator) ArgbEvaluator(android.animation.ArgbEvaluator)

Example 93 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class HighlightablePreferenceGroupAdapter method removeHighlightBackground.

private void removeHighlightBackground(View v, boolean animate) {
    if (!animate) {
        v.setTag(R.id.preference_highlighted, false);
        v.setBackgroundResource(mNormalBackgroundRes);
        Log.d(TAG, "RemoveHighlight: No animation requested - setting normal background");
        return;
    }
    if (!Boolean.TRUE.equals(v.getTag(R.id.preference_highlighted))) {
        // Not highlighted, no-op
        Log.d(TAG, "RemoveHighlight: Not highlighted - skipping");
        return;
    }
    int colorFrom = mHighlightColor;
    int colorTo = Color.WHITE;
    v.setTag(R.id.preference_highlighted, false);
    final ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
    colorAnimation.setDuration(HIGHLIGHT_FADE_OUT_DURATION);
    colorAnimation.addUpdateListener(animator -> v.setBackgroundColor((int) animator.getAnimatedValue()));
    colorAnimation.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            // Animation complete - the background is now white. Change to mNormalBackgroundRes
            // so it is white and has ripple on touch.
            v.setBackgroundResource(mNormalBackgroundRes);
        }
    });
    colorAnimation.start();
    Log.d(TAG, "Starting fade out animation");
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ArgbEvaluator(android.animation.ArgbEvaluator) ValueAnimator(android.animation.ValueAnimator)

Example 94 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class HighlightablePreferenceGroupAdapter method addHighlightBackground.

private void addHighlightBackground(View v, boolean animate) {
    v.setTag(R.id.preference_highlighted, true);
    if (!animate) {
        v.setBackgroundColor(mHighlightColor);
        Log.d(TAG, "AddHighlight: Not animation requested - setting highlight background");
        requestRemoveHighlightDelayed(v);
        return;
    }
    mFadeInAnimated = true;
    final int colorFrom = Color.WHITE;
    final int colorTo = mHighlightColor;
    final ValueAnimator fadeInLoop = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
    fadeInLoop.setDuration(HIGHLIGHT_FADE_IN_DURATION);
    fadeInLoop.addUpdateListener(animator -> v.setBackgroundColor((int) animator.getAnimatedValue()));
    fadeInLoop.setRepeatMode(ValueAnimator.REVERSE);
    fadeInLoop.setRepeatCount(4);
    fadeInLoop.start();
    Log.d(TAG, "AddHighlight: starting fade in animation");
    requestRemoveHighlightDelayed(v);
}
Also used : ArgbEvaluator(android.animation.ArgbEvaluator) ValueAnimator(android.animation.ValueAnimator)

Example 95 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project ahbottomnavigation by aurelhubert.

the class AHHelper method updateDrawableColor.

/**
 * Update image view color with animation
 */
public static void updateDrawableColor(final Context context, final Drawable drawable, final ImageView imageView, @ColorInt int fromColor, @ColorInt int toColor, final boolean forceTint) {
    if (forceTint) {
        ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), fromColor, toColor);
        colorAnimation.setDuration(150);
        colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animator) {
                imageView.setImageDrawable(AHHelper.getTintDrawable(drawable, (Integer) animator.getAnimatedValue(), forceTint));
                imageView.requestLayout();
            }
        });
        colorAnimation.start();
    }
}
Also used : ArgbEvaluator(android.animation.ArgbEvaluator) ValueAnimator(android.animation.ValueAnimator)

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