From 4eaccc966eba26a47ed3e6d645dcccf8a4edf8ea Mon Sep 17 00:00:00 2001 From: Ivan Iskandar <12537387+ivaniskandar@users.noreply.github.com> Date: Fri, 20 Aug 2021 05:12:31 +0700 Subject: [PATCH] Hide reader progress indicator right away (#5750) The image will be drawn over it so the animation won't be visible anyway --- .../reader/viewer/ReaderProgressIndicator.kt | 25 +++---------------- .../ui/reader/viewer/pager/PagerPageHolder.kt | 2 +- .../viewer/webtoon/WebtoonPageHolder.kt | 2 +- 3 files changed, 5 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderProgressIndicator.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderProgressIndicator.kt index 2d17a4d95..bc9f796dc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderProgressIndicator.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderProgressIndicator.kt @@ -8,7 +8,6 @@ import android.view.animation.LinearInterpolator import android.view.animation.RotateAnimation import android.widget.FrameLayout import androidx.annotation.IntRange -import androidx.dynamicanimation.animation.DynamicAnimation import com.google.android.material.progressindicator.CircularProgressIndicator /** @@ -84,27 +83,9 @@ class ReaderProgressIndicator @JvmOverloads constructor( updateRotateAnimation() } - fun setCompleteProgressAndHide() { - val listener = object : DynamicAnimation.OnAnimationEndListener { - override fun onAnimationEnd( - animation: DynamicAnimation<*>?, - canceled: Boolean, - value: Float, - velocity: Float - ) { - hide() - indicator.progressDrawable?.removeSpringAnimationEndListener(this) - } - } - - indicator.progressDrawable?.addSpringAnimationEndListener(listener) - indicator.setProgressCompat(100, true) - updateRotateAnimation(forceRotate = true) - } - - private fun updateRotateAnimation(forceRotate: Boolean = false) { - if (forceRotate || (indicator.isShown && !indicator.isIndeterminate)) { - if (animation == null && isAttachedToWindow) { + private fun updateRotateAnimation() { + if (isAttachedToWindow && indicator.isShown && !indicator.isIndeterminate) { + if (animation == null) { startAnimation(rotateAnimation) } } else { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt index 6d3d32e11..d0a56eaa9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt @@ -252,7 +252,7 @@ class PagerPageHolder( * Called when the page is ready. */ private fun setImage() { - progressIndicator.setCompleteProgressAndHide() + progressIndicator.hide() retryButton?.isVisible = false decodeErrorLayout?.isVisible = false diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt index 2fd37402f..009b36b18 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt @@ -265,7 +265,7 @@ class WebtoonPageHolder( * Called when the page is ready. */ private fun setImage() { - progressIndicator.setCompleteProgressAndHide() + progressIndicator.hide() retryContainer?.isVisible = false removeDecodeErrorLayout()