From 9068c96ab3b166782f7931b9d319b562c668f1bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hakk=C4=B1=20Kaan=20=C3=87al=C4=B1=C5=9Fkan?= Date: Mon, 22 Jun 2020 20:58:14 +0300 Subject: [PATCH] don't animate unnecessarily Fixes #11672, #11727: Empty default tab text and add padding to infinite character Fixes #11739: Fix flicker Update TabCounter.kt make lint happy don't animate unnecessarily don't animate unnecessarily Fixes #11739: Fix flicker Update TabCounter.kt squash commits don't animate unnecessarily Fixes #11672, #11727: Empty default tab text and add padding to infinite character Fixes #11739: Fix flicker Update TabCounter.kt make lint happy don't animate unnecessarily --- .../fenix/components/toolbar/TabCounter.kt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/components/toolbar/TabCounter.kt b/app/src/main/java/org/mozilla/fenix/components/toolbar/TabCounter.kt index 3677d6cde..84dbdf9ef 100644 --- a/app/src/main/java/org/mozilla/fenix/components/toolbar/TabCounter.kt +++ b/app/src/main/java/org/mozilla/fenix/components/toolbar/TabCounter.kt @@ -43,14 +43,19 @@ class TabCounter @JvmOverloads constructor( } fun setCountWithAnimation(count: Int) { - setCount(count) - // No need to animate on these cases. when { - INTERNAL_COUNT == 0 -> return // Initial state. - INTERNAL_COUNT == count -> return // There isn't any tab added or removed. - INTERNAL_COUNT > MAX_VISIBLE_TABS -> return // There are still over MAX_VISIBLE_TABS tabs open. + count == INTERNAL_COUNT -> return // There isn't any tab added or removed. + INTERNAL_COUNT == 0 -> { + setCount(count) + return + } // Initial state. + count > MAX_VISIBLE_TABS && INTERNAL_COUNT > MAX_VISIBLE_TABS -> { + INTERNAL_COUNT = count + return + } // There are still over MAX_VISIBLE_TABS tabs open. } + setCount(count) // Cancel previous animations if necessary. if (animationSet.isRunning) {