Bug 1388490 - Cancel animation set if necessary before re-start it. r?walkingice
MozReview-Commit-ID: F1pDOxZp1SI
--- 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
@@ -155,38 +155,42 @@ public class TabCounter extends ThemedRe
animatorSet.play(firstAnimator).with(fadeOut);
animatorSet.play(fadeOut).before(fadeIn);
animatorSet.play(fadeIn).with(moveDown);
animatorSet.play(moveDown).before(moveUp);
}
void setCountWithAnimation(final int count) {
- // Don't animate from initial state
+ // Don't animate from initial state.
if (this.count == 0) {
setCount(count);
return;
}
if (this.count == count) {
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;
}
adjustTextSize(count);
text.setText(formatForDisplay(count));
this.count = count;
- // Trigger animation
+ // Cancel previous animations if necessary.
+ if (animationSet.isRunning()) {
+ animationSet.cancel();
+ }
+ // Trigger animations.
animationSet.start();
}
private String formatForDisplay(int count) {
if (count > MAX_VISIBLE_TABS) {
return SO_MANY_TABS_OPEN;
}
return String.valueOf(count);