From b96179be53643e5ebdb066699e66885471ccdac5 Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 28 Oct 2021 01:52:07 +0300 Subject: [PATCH] Updated on 2026-08-14 --- .../toggleWidget/RefreshBalanceWidget.kt | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/com/tangem/tap/common/toggleWidget/RefreshBalanceWidget.kt b/app/src/main/java/com/tangem/tap/common/toggleWidget/RefreshBalanceWidget.kt index e7ef08e026..277f839c05 100644 --- a/app/src/main/java/com/tangem/tap/common/toggleWidget/RefreshBalanceWidget.kt +++ b/app/src/main/java/com/tangem/tap/common/toggleWidget/RefreshBalanceWidget.kt @@ -41,30 +41,31 @@ class RefreshBalanceWidget( val progressState = state as? ProgressState ?: return val currentStateByView = getState() - - if (progressState == currentStateByView) return + when { + currentStateByView == progressState -> return + currentStateByView == ProgressState.Done -> if (progressState == ProgressState.Error) return + } animateState(progressState) viewSwitcher.showNext() - } private fun animateState(state: ProgressState) { when (state) { ProgressState.Done, ProgressState.Error -> { progressViewAnimation?.cancel() + progressViewAnimation = null } ProgressState.Loading -> { - val animation = RotateAnimation( - 0f, 360f, - Animation.RELATIVE_TO_SELF, 0.5f, - Animation.RELATIVE_TO_SELF, 0.5f + progressViewAnimation = RotateAnimation( + 0f, 360f, + Animation.RELATIVE_TO_SELF, 0.5f, + Animation.RELATIVE_TO_SELF, 0.5f ) - animation.duration = 700 - animation.interpolator = AccelerateInterpolator() - animation.repeatCount = -1 - arrowView.startAnimation(animation) - progressViewAnimation = animation + progressViewAnimation?.duration = 700 + progressViewAnimation?.interpolator = AccelerateInterpolator() + progressViewAnimation?.repeatCount = -1 + progressViewAnimation?.let { arrowView.startAnimation(it) } } } } @@ -88,10 +89,10 @@ class RefreshBalanceWidget( class ShowAnimation : AnimationSet(true) { init { addAnimation(ScaleAnimation( - 0f, 1f, - 0f, 1f, - Animation.RELATIVE_TO_SELF, 0.5f, - Animation.RELATIVE_TO_SELF, 0.5f) + 0f, 1f, + 0f, 1f, + Animation.RELATIVE_TO_SELF, 0.5f, + Animation.RELATIVE_TO_SELF, 0.5f) ) addAnimation(AlphaAnimation(0f, 1f)) duration = 300