Bug 1388490 - Cancel animation set if necessary before re-start it. r=walkingice

MozReview-Commit-ID: F1pDOxZp1SI

--HG--
extra : rebase_source : f7f5a1cdcef5ee91c519f2c3c1c5414bbfb793a7
This commit is contained in:
Jing-wei Wu 2017-08-28 15:04:39 +08:00
Родитель 1400981514
Коммит 3fb42e9edd
1 изменённых файлов: 7 добавлений и 3 удалений

Просмотреть файл

@ -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();
}