Search in sources :

Example 56 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project LeafPic by HoraApps.

the class PlayerActivity method changeBackGroundColor.

private void changeBackGroundColor() {
    int colorTo;
    int colorFrom;
    if (fullScreenMode) {
        colorFrom = getBackgroundColor();
        colorTo = (ContextCompat.getColor(PlayerActivity.this, R.color.md_black_1000));
    } else {
        colorFrom = (ContextCompat.getColor(PlayerActivity.this, R.color.md_black_1000));
        colorTo = getBackgroundColor();
    }
    ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
    colorAnimation.setDuration(240);
    colorAnimation.addUpdateListener(animator -> rootView.setBackgroundColor((Integer) animator.getAnimatedValue()));
    colorAnimation.start();
}
Also used : ArgbEvaluator(android.animation.ArgbEvaluator) ValueAnimator(android.animation.ValueAnimator)

Example 57 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project LeafPic by HoraApps.

the class SingleMediaActivity method changeBackGroundColor.

private void changeBackGroundColor() {
    int colorTo;
    int colorFrom;
    if (fullScreenMode) {
        colorFrom = getBackgroundColor();
        colorTo = (ContextCompat.getColor(SingleMediaActivity.this, R.color.md_black_1000));
    } else {
        colorFrom = (ContextCompat.getColor(SingleMediaActivity.this, R.color.md_black_1000));
        colorTo = getBackgroundColor();
    }
    ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
    colorAnimation.setDuration(240);
    colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animator) {
            activityBackground.setBackgroundColor((Integer) animator.getAnimatedValue());
        }
    });
    colorAnimation.start();
}
Also used : ArgbEvaluator(android.animation.ArgbEvaluator) ValueAnimator(android.animation.ValueAnimator)

Example 58 with ArgbEvaluator

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

the class ThemeManager method setColor.

public static void setColor(QKActivity activity, int color) {
    AnalyticsManager.getInstance().sendEvent(AnalyticsManager.CATEGORY_PREFERENCE_CHANGE, SettingsFragment.CATEGORY_THEME, getColorString(color));
    int colorFrom = mActiveColor;
    mColor = color;
    mActiveColor = color;
    mPrefs.edit().putString(SettingsFragment.THEME, "" + color).apply();
    setSentBubbleColored(mPrefs.getBoolean(SettingsFragment.COLOR_SENT, true));
    setReceivedBubbleColored(mPrefs.getBoolean(SettingsFragment.COLOR_RECEIVED, false));
    mTextOnColorPrimary = mResources.getColor(isColorDarkEnough(mColor) ? R.color.theme_dark_text_primary : R.color.theme_light_text_primary);
    mTextOnColorSecondary = mResources.getColor(isColorDarkEnough(mColor) ? R.color.theme_dark_text_secondary : R.color.theme_light_text_secondary);
    ValueAnimator colorAnimation = ValueAnimator.ofObject(new CIELChEvaluator(colorFrom, color), 0);
    colorAnimation.setDuration(TRANSITION_LENGTH);
    colorAnimation.setInterpolator(new DecelerateInterpolator());
    colorAnimation.addUpdateListener(animation -> {
        setActiveColor((Integer) animation.getAnimatedValue());
    });
    colorAnimation.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            WidgetProvider.notifyThemeChanged(mContext);
        }
    });
    colorAnimation.start();
    if (activity.findViewById(R.id.toolbar_title) != null) {
        // final Toolbar toolbar = (Toolbar) mActivity.findViewById(R.id.title);
        final QKTextView title = (QKTextView) activity.findViewById(R.id.toolbar_title);
        if (title.getCurrentTextColor() != mTextOnColorPrimary) {
            ValueAnimator titleColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), title.getCurrentTextColor(), mTextOnColorPrimary);
            titleColorAnimation.setDuration(TRANSITION_LENGTH);
            titleColorAnimation.setInterpolator(new DecelerateInterpolator());
            titleColorAnimation.addUpdateListener(animation -> {
                int color1 = (Integer) animation.getAnimatedValue();
                title.setTextColor(color1);
                activity.colorMenuIcons(activity.getMenu(), color1);
            });
            titleColorAnimation.start();
        }
    }
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) CIELChEvaluator(com.moez.QKSMS.common.CIELChEvaluator) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ArgbEvaluator(android.animation.ArgbEvaluator) ValueAnimator(android.animation.ValueAnimator) QKTextView(com.moez.QKSMS.ui.view.QKTextView)

Example 59 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project Shuttle by timusus.

the class PlayerFragment method animateColors.

void animateColors(int from, int to, UnsafeConsumer<Integer> consumer) {
    ValueAnimator valueAnimator = ValueAnimator.ofInt(from, to);
    valueAnimator.setEvaluator(new ArgbEvaluator());
    valueAnimator.setDuration(450);
    valueAnimator.addUpdateListener(animator -> consumer.accept((Integer) animator.getAnimatedValue()));
    valueAnimator.start();
}
Also used : ArgbEvaluator(android.animation.ArgbEvaluator) ValueAnimator(android.animation.ValueAnimator)

Example 60 with ArgbEvaluator

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

the class AnimationBuilder method backgroundColor.

/**
 * Background color animation builder.
 *
 * @param colors the colors
 * @return the animation builder
 */
public AnimationBuilder backgroundColor(int... colors) {
    for (View view : views) {
        ObjectAnimator objectAnimator = ObjectAnimator.ofInt(view, "backgroundColor", colors);
        objectAnimator.setEvaluator(new ArgbEvaluator());
        this.animatorList.add(objectAnimator);
    }
    return this;
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) ArgbEvaluator(android.animation.ArgbEvaluator) TextView(android.widget.TextView) View(android.view.View)

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