Search in sources :

Example 96 with ArgbEvaluator

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

the class AHHelper method updateTextColor.

/**
 * Update text color with animation
 */
public static void updateTextColor(final TextView textView, @ColorInt int fromColor, @ColorInt int toColor) {
    ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), fromColor, toColor);
    colorAnimation.setDuration(150);
    colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

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

Example 97 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project packages_apps_Contacts by AOKP.

the class QuickContactActivity method updateStatusBarColor.

private void updateStatusBarColor() {
    if (mScroller == null || !CompatUtils.isLollipopCompatible()) {
        return;
    }
    final int desiredStatusBarColor;
    // Only use a custom status bar color if QuickContacts touches the top of the viewport.
    if (mScroller.getScrollNeededToBeFullScreen() <= 0) {
        desiredStatusBarColor = mStatusBarColor;
    } else {
        desiredStatusBarColor = Color.TRANSPARENT;
    }
    // Animate to the new color.
    final ObjectAnimator animation = ObjectAnimator.ofInt(getWindow(), "statusBarColor", getWindow().getStatusBarColor(), desiredStatusBarColor);
    animation.setDuration(ANIMATION_STATUS_BAR_COLOR_CHANGE_DURATION);
    animation.setEvaluator(new ArgbEvaluator());
    animation.start();
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) ArgbEvaluator(android.animation.ArgbEvaluator)

Example 98 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project SMSBlocker by sagarpawardev.

the class RVThreadAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final SMSViewHolder holder, int position) {
    final String methodName = "onBindViewHolder()";
    log.justEntered(methodName);
    // Adi changes Start
    Typeface myFont = Typeface.createFromAsset(context.getAssets(), "fonts/VarelaRound-Regular.ttf");
    holder.tvBody.setTypeface(myFont);
    holder.tvTime.setTypeface(myFont);
    // Adi changes End
    SMS sms = smses.get(position);
    String body = sms.getBody();
    long time = sms.getDateTime();
    long type = sms.getType();
    boolean isRead = sms.isRead();
    String socialDate = DateUtilSingleton.getInstance().socialFormat(time);
    boolean isReplySupported = sms.isReplySupported();
    if (type == SMS.TYPE_QUEUED) {
        holder.tvSending.setVisibility(View.VISIBLE);
    } else {
        holder.tvSending.setVisibility(View.GONE);
    }
    // If SMS is among saved SMS
    log.debug(methodName, "Checking Saved SMS: " + sms.isSaved() + " id: " + sms.getId());
    if (sms.isSaved()) {
        holder.btnStar.setVisibility(View.VISIBLE);
        // If marked for Unstar
        if (markedForUnstar.contains(position)) {
            holder.btnStar.setLiked(false);
        } else {
            holder.btnStar.setLiked(true);
        }
    } else {
        holder.btnStar.setVisibility(View.GONE);
    }
    // If SMS is selected in RecyclerView
    boolean isSelected = selectedSMSes.contains(sms);
    setViewSelected(holder, isSelected);
    holder.tvBody.setText(body);
    holder.tvTime.setText(socialDate);
    if (!replyNotSupportedTold && type == SMS.TYPE_RECEIVED && !isReplySupported) {
        callback.onReplyNotSupported();
    }
    // Highlight Item if required
    if (highlightPosition == position) {
        int colorFrom = context.getResources().getColor(R.color.orangeA200, null);
        int colorTo = context.getResources().getColor(R.color.transparent_light_grey, null);
        ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
        // milliseconds
        colorAnimation.setDuration(HIGHLIGHT_DURATION);
        colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animator) {
                holder.llParent.setBackgroundColor((int) animator.getAnimatedValue());
            }
        });
        colorAnimation.addListener(new Animator.AnimatorListener() {

            @Override
            public void onAnimationStart(Animator animator) {
                final String methodName = "onAnimationStart()";
                log.justEntered(methodName);
                // Nothing here
                log.returning(methodName);
            }

            @Override
            public void onAnimationEnd(Animator animator) {
                final String methodName = "onAnimationEnd()";
                log.justEntered(methodName);
                log.info(methodName, "Resetting Highlight animation");
                resetHighlight();
                log.returning(methodName);
            }

            @Override
            public void onAnimationCancel(Animator animator) {
                final String methodName = "onAnimationCancel()";
                log.justEntered(methodName);
                // Nothing here
                log.returning(methodName);
            }

            @Override
            public void onAnimationRepeat(Animator animator) {
                final String methodName = "onAnimationRepeat()";
                log.justEntered(methodName);
                // Nothing here
                log.returning(methodName);
            }
        });
        colorAnimation.start();
    }
    log.returning(methodName);
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) Typeface(android.graphics.Typeface) ArgbEvaluator(android.animation.ArgbEvaluator) SMS(dev.sagar.smsblocker.tech.beans.SMS) ValueAnimator(android.animation.ValueAnimator)

Example 99 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project Transitions-Everywhere by andkulikov.

the class Recolor method createAnimator.

@Nullable
@Override
public Animator createAnimator(@NonNull ViewGroup sceneRoot, @Nullable TransitionValues startValues, @Nullable TransitionValues endValues) {
    if (startValues == null || endValues == null) {
        return null;
    }
    final View view = endValues.view;
    Drawable startBackground = (Drawable) startValues.values.get(PROPNAME_BACKGROUND);
    Drawable endBackground = (Drawable) endValues.values.get(PROPNAME_BACKGROUND);
    ObjectAnimator bgAnimator = null;
    if (startBackground instanceof ColorDrawable && endBackground instanceof ColorDrawable) {
        ColorDrawable startColor = (ColorDrawable) startBackground;
        ColorDrawable endColor = (ColorDrawable) endBackground;
        if (startColor.getColor() != endColor.getColor()) {
            final int finalColor = endColor.getColor();
            endColor = (ColorDrawable) endColor.mutate();
            endColor.setColor(startColor.getColor());
            bgAnimator = ObjectAnimator.ofInt(endColor, COLORDRAWABLE_COLOR, startColor.getColor(), finalColor);
            bgAnimator.setEvaluator(new ArgbEvaluator());
        }
    }
    ObjectAnimator textColorAnimator = null;
    if (view instanceof TextView) {
        TextView textView = (TextView) view;
        int start = (Integer) startValues.values.get(PROPNAME_TEXT_COLOR);
        int end = (Integer) endValues.values.get(PROPNAME_TEXT_COLOR);
        if (start != end) {
            textView.setTextColor(end);
            textColorAnimator = ObjectAnimator.ofInt(textView, TEXTVIEW_TEXT_COLOR, start, end);
            textColorAnimator.setEvaluator(new ArgbEvaluator());
        }
    }
    return TransitionUtils.mergeAnimators(bgAnimator, textColorAnimator);
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) ObjectAnimator(android.animation.ObjectAnimator) ArgbEvaluator(android.animation.ArgbEvaluator) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) Nullable(androidx.annotation.Nullable)

Example 100 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project samourai-wallet-android by Samourai-Wallet.

the class TransactionProgressView method offlineMode.

public void offlineMode(int duration) {
    int colorFrom = getResources().getColor(R.color.tx_broadcast_normal_bg);
    int colorTo = getResources().getColor(R.color.tx_broadcast_offline_bg);
    ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
    // milliseconds
    colorAnimation.setDuration(duration);
    colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animator) {
            mTransactionProgressContainer.setBackgroundColor((int) animator.getAnimatedValue());
        }
    });
    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