diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt index 0ab619f20..b3821acdf 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt @@ -317,6 +317,7 @@ class MangaPresenter( observeDownloadsStatusSubscription?.let { remove(it) } observeDownloadsStatusSubscription = downloadManager.queue.getStatusObservable() .observeOn(AndroidSchedulers.mainThread()) + .onBackpressureLatest() .filter { download -> download.manga.id == manga.id } .doOnNext { onDownloadStatusChange(it) } .subscribeLatestCache(MangaController::onChapterDownloadUpdate) { _, error -> @@ -326,6 +327,7 @@ class MangaPresenter( observeDownloadsPageSubscription?.let { remove(it) } observeDownloadsPageSubscription = downloadManager.queue.getProgressObservable() .observeOn(AndroidSchedulers.mainThread()) + .onBackpressureLatest() .filter { download -> download.manga.id == manga.id } .subscribeLatestCache(MangaController::onChapterDownloadUpdate) { _, error -> Timber.e(error) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterDownloadView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterDownloadView.kt index d66d0910e..533deaa09 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterDownloadView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterDownloadView.kt @@ -14,6 +14,9 @@ class ChapterDownloadView @JvmOverloads constructor(context: Context, attrs: Att private val binding: ChapterDownloadViewBinding + private var state = Download.State.NOT_DOWNLOADED + private var progress = 0 + private var downloadIconAnimator: ObjectAnimator? = null private var isAnimating = false @@ -23,6 +26,17 @@ class ChapterDownloadView @JvmOverloads constructor(context: Context, attrs: Att } fun setState(state: Download.State, progress: Int = 0) { + val isDirty = this.state.value != state.value || this.progress != progress + + this.state = state + this.progress = progress + + if (isDirty) { + updateLayout() + } + } + + private fun updateLayout() { binding.downloadIconBorder.isVisible = state == Download.State.NOT_DOWNLOADED binding.downloadIcon.isVisible = state == Download.State.NOT_DOWNLOADED || state == Download.State.DOWNLOADING