From 7a373fb43a2d3f736c032d88b31a4a3bffd8dc5b Mon Sep 17 00:00:00 2001 From: arkon Date: Fri, 12 Feb 2021 12:27:06 -0500 Subject: [PATCH] Minor download icon optimizations --- .../tachiyomi/ui/manga/MangaPresenter.kt | 19 +++++++++++++------ .../ui/recent/updates/UpdatesPresenter.kt | 17 +++++++++++++---- 2 files changed, 26 insertions(+), 10 deletions(-) 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 b3821acdfe..88634881e1 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 @@ -316,19 +316,26 @@ class MangaPresenter( private fun observeDownloads() { observeDownloadsStatusSubscription?.let { remove(it) } observeDownloadsStatusSubscription = downloadManager.queue.getStatusObservable() - .observeOn(AndroidSchedulers.mainThread()) + .observeOn(Schedulers.io()) .onBackpressureLatest() .filter { download -> download.manga.id == manga.id } - .doOnNext { onDownloadStatusChange(it) } - .subscribeLatestCache(MangaController::onChapterDownloadUpdate) { _, error -> - Timber.e(error) - } + .observeOn(AndroidSchedulers.mainThread()) + .subscribeLatestCache( + { view, it -> + onDownloadStatusChange(it) + view.onChapterDownloadUpdate(it) + }, + { _, error -> + Timber.e(error) + } + ) observeDownloadsPageSubscription?.let { remove(it) } observeDownloadsPageSubscription = downloadManager.queue.getProgressObservable() - .observeOn(AndroidSchedulers.mainThread()) + .observeOn(Schedulers.io()) .onBackpressureLatest() .filter { download -> download.manga.id == manga.id } + .observeOn(AndroidSchedulers.mainThread()) .subscribeLatestCache(MangaController::onChapterDownloadUpdate) { _, error -> Timber.e(error) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt index 508be4909b..d44af094cd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt @@ -40,13 +40,22 @@ class UpdatesPresenter( .subscribeLatestCache(UpdatesController::onNextRecentChapters) downloadManager.queue.getStatusObservable() + .observeOn(Schedulers.io()) + .onBackpressureLatest() .observeOn(AndroidSchedulers.mainThread()) - .doOnNext { onDownloadStatusChange(it) } - .subscribeLatestCache(UpdatesController::onChapterDownloadUpdate) { _, error -> - Timber.e(error) - } + .subscribeLatestCache( + { view, it -> + onDownloadStatusChange(it) + view.onChapterDownloadUpdate(it) + }, + { _, error -> + Timber.e(error) + } + ) downloadManager.queue.getProgressObservable() + .observeOn(Schedulers.io()) + .onBackpressureLatest() .observeOn(AndroidSchedulers.mainThread()) .subscribeLatestCache(UpdatesController::onChapterDownloadUpdate) { _, error -> Timber.e(error)