Search in sources :

Example 66 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project android_packages_apps_Dialer by MoKee.

the class PseudoEmergencyAnimator method start.

public void start() {
    if (mPseudoEmergencyColorAnimator == null) {
        Integer colorFrom = Color.BLUE;
        Integer colorTo = Color.RED;
        mPseudoEmergencyColorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
        mPseudoEmergencyColorAnimator.addUpdateListener(new AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animator) {
                try {
                    int color = (int) animator.getAnimatedValue();
                    ColorFilter colorFilter = new LightingColorFilter(Color.BLACK, color);
                    View floatingActionButtonContainer = getView().findViewById(R.id.dialpad_floating_action_button_container);
                    if (floatingActionButtonContainer != null) {
                        floatingActionButtonContainer.getBackground().setColorFilter(colorFilter);
                    }
                } catch (Exception e) {
                    animator.cancel();
                }
            }
        });
        mPseudoEmergencyColorAnimator.addListener(new AnimatorListener() {

            @Override
            public void onAnimationCancel(Animator animation) {
            }

            @Override
            public void onAnimationRepeat(Animator animation) {
                try {
                    vibrate(VIBRATE_LENGTH_MILLIS);
                } catch (Exception e) {
                    animation.cancel();
                }
            }

            @Override
            public void onAnimationStart(Animator animation) {
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                try {
                    View floatingActionButtonContainer = getView().findViewById(R.id.dialpad_floating_action_button_container);
                    if (floatingActionButtonContainer != null) {
                        floatingActionButtonContainer.getBackground().clearColorFilter();
                    }
                    new Handler().postDelayed(new Runnable() {

                        @Override
                        public void run() {
                            try {
                                vibrate(VIBRATE_LENGTH_MILLIS);
                            } catch (Exception e) {
                            // ignored
                            }
                        }
                    }, ITERATION_LENGTH_MILLIS);
                } catch (Exception e) {
                    animation.cancel();
                }
            }
        });
        mPseudoEmergencyColorAnimator.setDuration(VIBRATE_LENGTH_MILLIS);
        mPseudoEmergencyColorAnimator.setRepeatMode(ValueAnimator.REVERSE);
        mPseudoEmergencyColorAnimator.setRepeatCount(ANIMATION_ITERATION_COUNT);
    }
    if (!mPseudoEmergencyColorAnimator.isStarted()) {
        mPseudoEmergencyColorAnimator.start();
    }
}
Also used : ArgbEvaluator(android.animation.ArgbEvaluator) Handler(android.os.Handler) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator) View(android.view.View) AnimatorListener(android.animation.Animator.AnimatorListener) ColorFilter(android.graphics.ColorFilter) LightingColorFilter(android.graphics.LightingColorFilter) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) LightingColorFilter(android.graphics.LightingColorFilter)

Example 67 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project Xposed-Tinted-Status-Bar by MohammadAG.

the class OverlayDrawable method setOverrideColor.

public void setOverrideColor(final int color) {
    int animateFrom;
    final int animateTo;
    if (mOverrideColor != -3) {
        animateFrom = mOverrideColor;
    } else {
        animateFrom = mColor;
    }
    if (color == -3) {
        animateTo = mColor;
    } else {
        animateTo = color;
    }
    if (mAnimator != null && mAnimator.isRunning()) {
        mAnimator.cancel();
        animateFrom = mOverrideColor;
        mAnimator = null;
    }
    mAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), animateFrom, animateTo);
    mAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animator) {
            mOverrideColor = (Integer) animator.getAnimatedValue();
            invalidateSelf();
        }
    });
    mAnimator.addListener(new AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (color == -3) {
                mOverrideColor = -3;
                mColor = animateTo;
                invalidateSelf();
            }
            mAnimator = null;
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }
    });
    mAnimator.start();
}
Also used : AnimatorListener(android.animation.Animator.AnimatorListener) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) ArgbEvaluator(android.animation.ArgbEvaluator) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator) Paint(android.graphics.Paint)

Example 68 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project Xposed-Tinted-Status-Bar by MohammadAG.

the class ColourChangerMod method setStatusBarTint.

@SuppressLint("NewApi")
public void setStatusBarTint(final int tintColor) {
    if (mStatusBarView == null)
        return;
    log("Setting statusbar color to " + tintColor);
    if (mSettingsHelper.animateStatusBarTintChange()) {
        int animateFrom = mLastSetColor == KITKAT_TRANSPARENT_COLOR ? Color.TRANSPARENT : mLastSetColor;
        int animateTo = tintColor == KITKAT_TRANSPARENT_COLOR ? Color.TRANSPARENT : tintColor;
        ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), animateFrom, animateTo);
        colorAnimation.addUpdateListener(new AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animator) {
                mGradientDrawable.setColor((Integer) animator.getAnimatedValue());
            }
        });
        Utils.setViewBackground(mStatusBarView, mGradientDrawable);
        colorAnimation.start();
    } else {
        mStatusBarView.setAlpha(1f);
        if (tintColor == KITKAT_TRANSPARENT_COLOR) {
            Utils.setViewBackground(mStatusBarView, mGradientDrawable);
            mGradientDrawable.setColor(Color.TRANSPARENT);
        } else {
            Utils.setViewBackground(mStatusBarView, mGradientDrawable);
            mGradientDrawable.setColor(tintColor);
        }
    }
    mGradientDrawable.setMode(mSettingsHelper.getOverlayMode(), mSettingsHelper.getSemiTransparentOverlayOpacity());
    mGradientDrawable.setIsTransparentCauseOfKitKatApi(tintColor == KITKAT_TRANSPARENT_COLOR && mSettingsHelper.isLegacyGradientMode());
    mLastSetColor = tintColor;
    if (mSettingsHelper.shouldLinkStatusBarAndNavBar() && !mKeyboardUp) {
        mNavigationBarTint = tintColor;
        setNavigationBarTint(tintColor, true);
    }
}
Also used : ArgbEvaluator(android.animation.ArgbEvaluator) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator) SuppressLint(android.annotation.SuppressLint) Tint(com.mohammadag.colouredstatusbar.SettingsHelper.Tint) SuppressLint(android.annotation.SuppressLint)

Example 69 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project MaterialViewPager by florent37.

the class MaterialViewPagerAnimator method setColor.

/**
 * Change the color of the statusbackground, toolbar, toolbarlayout and pagertitlestrip
 * With a color transition animation
 *
 * @param color    the final color
 * @param duration the transition color animation duration
 */
void setColor(int color, int duration) {
    final ValueAnimator colorAnim = ObjectAnimator.ofInt(mHeader.headerBackground, "backgroundColor", settings.color, color);
    colorAnim.setEvaluator(new ArgbEvaluator());
    colorAnim.setDuration(duration);
    colorAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            final int animatedValue = (Integer) animation.getAnimatedValue();
            int colorAlpha = colorWithAlpha(animatedValue, lastPercent);
            mHeader.headerBackground.setBackgroundColor(colorAlpha);
            mHeader.statusBackground.setBackgroundColor(colorAlpha);
            mHeader.toolbar.setBackgroundColor(colorAlpha);
            mHeader.toolbarLayoutBackground.setBackgroundColor(colorAlpha);
            mHeader.mPagerSlidingTabStrip.setBackgroundColor(colorAlpha);
            // set the new color as MaterialViewPager's color
            settings.color = animatedValue;
        }
    });
    colorAnim.start();
}
Also used : ArgbEvaluator(android.animation.ArgbEvaluator) ValueAnimator(android.animation.ValueAnimator)

Example 70 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project ENViews by codeestX.

the class ENScrollView method unSelect.

public void unSelect() {
    if (mCurrentState == STATE_UNSELECT) {
        return;
    }
    mCurrentState = STATE_UNSELECT;
    ValueAnimator valueAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), mLineColor, mBgLineColor);
    valueAnimator.setDuration(mDuration);
    valueAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            mFraction = 1 - valueAnimator.getAnimatedFraction();
            mCurrentColor = (int) valueAnimator.getAnimatedValue();
            invalidate();
        }
    });
    if (!valueAnimator.isRunning()) {
        valueAnimator.start();
    }
    valueAnimator.start();
}
Also used : ArgbEvaluator(android.animation.ArgbEvaluator) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) 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