From 3fb42e9edd6c4e53f178e060ffdce7376ff36633 Mon Sep 17 00:00:00 2001 From: Jing-wei Wu Date: Mon, 28 Aug 2017 15:04:39 +0800 Subject: [PATCH] Bug 1388490 - Cancel animation set if necessary before re-start it. r=walkingice MozReview-Commit-ID: F1pDOxZp1SI --HG-- extra : rebase_source : f7f5a1cdcef5ee91c519f2c3c1c5414bbfb793a7 --- .../java/org/mozilla/gecko/toolbar/TabCounter.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mobile/android/app/src/photon/java/org/mozilla/gecko/toolbar/TabCounter.java b/mobile/android/app/src/photon/java/org/mozilla/gecko/toolbar/TabCounter.java index a3d3827f7cde..1fc3afbd7187 100644 --- a/mobile/android/app/src/photon/java/org/mozilla/gecko/toolbar/TabCounter.java +++ b/mobile/android/app/src/photon/java/org/mozilla/gecko/toolbar/TabCounter.java @@ -160,7 +160,7 @@ public class TabCounter extends ThemedRelativeLayout { } void setCountWithAnimation(final int count) { - // Don't animate from initial state + // Don't animate from initial state. if (this.count == 0) { setCount(count); return; @@ -170,7 +170,7 @@ public class TabCounter extends ThemedRelativeLayout { return; } - // don't animate if there are still over MAX_VISIBLE_TABS tabs open + // Don't animate if there are still over MAX_VISIBLE_TABS tabs open. if (this.count > MAX_VISIBLE_TABS && count > MAX_VISIBLE_TABS) { this.count = count; return; @@ -181,7 +181,11 @@ public class TabCounter extends ThemedRelativeLayout { text.setText(formatForDisplay(count)); this.count = count; - // Trigger animation + // Cancel previous animations if necessary. + if (animationSet.isRunning()) { + animationSet.cancel(); + } + // Trigger animations. animationSet.start(); }