summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/notification
diff options
context:
space:
mode:
authorTony <twickham@google.com>2017-02-14 10:18:48 -0800
committerTony <twickham@google.com>2017-02-15 16:39:22 -0800
commitffb0b68ae27d4ca2a0beb84ecc07d228f1ad991a (patch)
tree3ac0addd48edcf1c487d359c56d6311fba00d05f /src/com/android/launcher3/notification
parenta59402f98c0d3f85a45344657baa9b208e9eea32 (diff)
downloadandroid_packages_apps_Trebuchet-ffb0b68ae27d4ca2a0beb84ecc07d228f1ad991a.tar.gz
android_packages_apps_Trebuchet-ffb0b68ae27d4ca2a0beb84ecc07d228f1ad991a.tar.bz2
android_packages_apps_Trebuchet-ffb0b68ae27d4ca2a0beb84ecc07d228f1ad991a.zip
Animate notification background color directly
Before we were calling setBackgroundColor() in the update listener, which is less efficient because it creates a new ColorDrawable; now we reuse one throughout. Change-Id: I0cd87e5ee72af41d2dae4375ce3df9fd6e92bd82
Diffstat (limited to 'src/com/android/launcher3/notification')
-rw-r--r--src/com/android/launcher3/notification/NotificationMainView.java21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/com/android/launcher3/notification/NotificationMainView.java b/src/com/android/launcher3/notification/NotificationMainView.java
index 6677c2fa2..a05fef352 100644
--- a/src/com/android/launcher3/notification/NotificationMainView.java
+++ b/src/com/android/launcher3/notification/NotificationMainView.java
@@ -18,8 +18,11 @@ package com.android.launcher3.notification;
import android.animation.Animator;
import android.animation.AnimatorSet;
+import android.animation.ArgbEvaluator;
+import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
+import android.graphics.drawable.ColorDrawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
@@ -39,10 +42,13 @@ import com.android.launcher3.userevent.nano.LauncherLogProto;
*/
public class NotificationMainView extends LinearLayout implements SwipeHelper.Callback {
+ private final ArgbEvaluator mArgbEvaluator = new ArgbEvaluator();
+
private NotificationInfo mNotificationInfo;
private TextView mTitleView;
private TextView mTextView;
private IconPalette mIconPalette;
+ private ColorDrawable mColorBackground;
public NotificationMainView(Context context) {
this(context, null, 0);
@@ -65,7 +71,8 @@ public class NotificationMainView extends LinearLayout implements SwipeHelper.Ca
}
public void applyColors(IconPalette iconPalette) {
- setBackgroundColor(iconPalette.backgroundColor);
+ mColorBackground = new ColorDrawable(iconPalette.backgroundColor);
+ setBackground(mColorBackground);
mIconPalette = iconPalette;
}
@@ -81,7 +88,7 @@ public class NotificationMainView extends LinearLayout implements SwipeHelper.Ca
if (animate) {
mTitleView.setAlpha(0);
mTextView.setAlpha(0);
- setBackgroundColor(mIconPalette.secondaryColor);
+ mColorBackground.setColor(mIconPalette.secondaryColor);
}
mNotificationInfo = mainNotification;
mTitleView.setText(mNotificationInfo.title);
@@ -97,14 +104,8 @@ public class NotificationMainView extends LinearLayout implements SwipeHelper.Ca
AnimatorSet animation = LauncherAnimUtils.createAnimatorSet();
Animator textFade = new LauncherViewPropertyAnimator(mTextView).alpha(1);
Animator titleFade = new LauncherViewPropertyAnimator(mTitleView).alpha(1);
- ValueAnimator colorChange = ValueAnimator.ofArgb(mIconPalette.secondaryColor,
- mIconPalette.backgroundColor);
- colorChange.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator valueAnimator) {
- setBackgroundColor((Integer) valueAnimator.getAnimatedValue());
- }
- });
+ ValueAnimator colorChange = ObjectAnimator.ofObject(mColorBackground, "color",
+ mArgbEvaluator, mIconPalette.secondaryColor, mIconPalette.backgroundColor);
animation.playTogether(textFade, titleFade, colorChange);
animation.setDuration(150);
animation.start();