summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/Hotseat.java
diff options
context:
space:
mode:
authorTony Wickham <twickham@google.com>2016-08-22 23:23:09 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-08-22 23:23:09 +0000
commit5f2ea1e9ce0dd7b9f40b8198381ebecdac11fcda (patch)
treed0a98cf1c2f8c86c695a9473c5272cf3b81a4acf /src/com/android/launcher3/Hotseat.java
parent8f90dcff37f13bbbc3f875f1c9521cbc9745c673 (diff)
parentef0c537925369192cd84b0c4e3df29691c455d83 (diff)
downloadandroid_packages_apps_Trebuchet-5f2ea1e9ce0dd7b9f40b8198381ebecdac11fcda.tar.gz
android_packages_apps_Trebuchet-5f2ea1e9ce0dd7b9f40b8198381ebecdac11fcda.tar.bz2
android_packages_apps_Trebuchet-5f2ea1e9ce0dd7b9f40b8198381ebecdac11fcda.zip
Cancel hotseat color animator before setting a new color.
am: ef0c537925 Change-Id: I1aea3e288d7e54e788ad95b8599e6d909458b220
Diffstat (limited to 'src/com/android/launcher3/Hotseat.java')
-rw-r--r--src/com/android/launcher3/Hotseat.java20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index ceaedef2a..c738480fe 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -16,6 +16,8 @@
package com.android.launcher3;
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
import android.animation.ArgbEvaluator;
import android.animation.ValueAnimator;
import android.content.Context;
@@ -52,6 +54,7 @@ public class Hotseat extends FrameLayout
private int mBackgroundColor;
@ViewDebug.ExportedProperty(category = "launcher")
private ColorDrawable mBackground;
+ private ValueAnimator mBackgroundColorAnimator;
public Hotseat(Context context) {
this(context, null);
@@ -177,18 +180,27 @@ public class Hotseat extends FrameLayout
public void updateColor(ExtractedColors extractedColors, boolean animate) {
if (!mHasVerticalHotseat) {
int color = extractedColors.getColor(ExtractedColors.HOTSEAT_INDEX, Color.TRANSPARENT);
+ if (mBackgroundColorAnimator != null) {
+ mBackgroundColorAnimator.cancel();
+ }
if (!animate) {
setBackgroundColor(color);
} else {
- ValueAnimator animator = ValueAnimator.ofInt(mBackgroundColor, color);
- animator.setEvaluator(new ArgbEvaluator());
- animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+ mBackgroundColorAnimator = ValueAnimator.ofInt(mBackgroundColor, color);
+ mBackgroundColorAnimator.setEvaluator(new ArgbEvaluator());
+ mBackgroundColorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mBackground.setColor((Integer) animation.getAnimatedValue());
}
});
- animator.start();
+ mBackgroundColorAnimator.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mBackgroundColorAnimator = null;
+ }
+ });
+ mBackgroundColorAnimator.start();
}
mBackgroundColor = color;
}