Search in sources :

Example 46 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project qksms by moezbhatti.

the class ThemeManager method setNavigationBarTintEnabled.

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void setNavigationBarTintEnabled(QKActivity activity, boolean enabled) {
    int colorFrom = enabled ? mResources.getColor(R.color.black) : mColor;
    int colorTo = enabled ? mColor : mResources.getColor(R.color.black);
    ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
    colorAnimation.setDuration(TRANSITION_LENGTH);
    colorAnimation.addUpdateListener(animation -> {
        activity.getWindow().setNavigationBarColor(ColorUtils.darken((Integer) animation.getAnimatedValue()));
    });
    colorAnimation.start();
}
Also used : ArgbEvaluator(android.animation.ArgbEvaluator) ValueAnimator(android.animation.ValueAnimator) TargetApi(android.annotation.TargetApi)

Example 47 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project qksms by moezbhatti.

the class ThemeManager method setStatusBarTintEnabled.

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void setStatusBarTintEnabled(QKActivity activity, boolean enabled) {
    int colorFrom = enabled ? mResources.getColor(R.color.black) : mColor;
    int colorTo = enabled ? mColor : mResources.getColor(R.color.black);
    ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
    colorAnimation.setDuration(TRANSITION_LENGTH);
    colorAnimation.addUpdateListener(animation -> {
        activity.getWindow().setStatusBarColor(ColorUtils.darken((Integer) animation.getAnimatedValue()));
    });
    colorAnimation.start();
}
Also used : ArgbEvaluator(android.animation.ArgbEvaluator) ValueAnimator(android.animation.ValueAnimator) TargetApi(android.annotation.TargetApi)

Example 48 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project qksms by moezbhatti.

the class WelcomeNightFragment method onClick.

@Override
public void onClick(View v) {
    if (v.getId() == R.id.welcome_night_hint) {
        boolean night = ThemeManager.getTheme() == ThemeManager.Theme.LIGHT;
        int backgroundColor = mContext.getResources().getColor(night ? R.color.grey_light_mega_ultra : R.color.grey_material);
        int newBackgroundColor = mContext.getResources().getColor(night ? R.color.grey_material : R.color.grey_light_mega_ultra);
        ThemeManager.setTheme(night ? ThemeManager.Theme.DARK : ThemeManager.Theme.LIGHT);
        ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), backgroundColor, newBackgroundColor);
        colorAnimation.setDuration(ThemeManager.TRANSITION_LENGTH);
        colorAnimation.setInterpolator(new DecelerateInterpolator());
        colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                int color = (Integer) animation.getAnimatedValue();
                mContext.setColorBackground(color);
                mNightHint.setTextColor(color);
            }
        });
        colorAnimation.start();
        PreferenceManager.getDefaultSharedPreferences(mContext).edit().putString(SettingsFragment.BACKGROUND, night ? ThemeManager.Theme.PREF_GREY : ThemeManager.Theme.PREF_OFFWHITE).commit();
    }
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ArgbEvaluator(android.animation.ArgbEvaluator) ValueAnimator(android.animation.ValueAnimator)

Example 49 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 50 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project MaterialProgressBar by DreaminginCodeZH.

the class ObjectAnimatorCompatBase method ofArgb.

public static ObjectAnimator ofArgb(Object target, String propertyName, int... values) {
    ObjectAnimator animator = ObjectAnimator.ofInt(target, propertyName, values);
    animator.setEvaluator(new ArgbEvaluator());
    return animator;
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) ArgbEvaluator(android.animation.ArgbEvaluator)

Aggregations

ArgbEvaluator (android.animation.ArgbEvaluator)61 ValueAnimator (android.animation.ValueAnimator)30 ObjectAnimator (android.animation.ObjectAnimator)18 Animator (android.animation.Animator)10 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)7 TargetApi (android.annotation.TargetApi)6 View (android.view.View)6 Paint (android.graphics.Paint)5 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)4 ColorDrawable (android.graphics.drawable.ColorDrawable)4 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)4 TextView (android.widget.TextView)4 PropertyValuesHolder (android.animation.PropertyValuesHolder)3 SuppressLint (android.annotation.SuppressLint)3 ViewGroup (android.view.ViewGroup)3 AnimatorListener (android.animation.Animator.AnimatorListener)2 AnimatorSet (android.animation.AnimatorSet)2 Intent (android.content.Intent)2 Drawable (android.graphics.drawable.Drawable)2 Toolbar (android.support.v7.widget.Toolbar)2