From 31d96c2bf0a2ae87978bd4c2774eed0cf050e6ec Mon Sep 17 00:00:00 2001 From: Ivan Iskandar <12537387+ivaniskandar@users.noreply.github.com> Date: Tue, 8 Jun 2021 22:18:56 +0700 Subject: [PATCH 1/2] Fix download status not updated properly after starting batch download (#5348) --- .../main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt | 4 ++-- .../kanade/tachiyomi/ui/manga/chapter/ChapterDownloadView.kt | 3 +-- .../eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt | 4 ++-- 3 files changed, 5 insertions(+), 6 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 9ef77d1365..e8b6433948 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 @@ -359,7 +359,7 @@ class MangaPresenter( observeDownloadsStatusSubscription?.let { remove(it) } observeDownloadsStatusSubscription = downloadManager.queue.getStatusObservable() .observeOn(Schedulers.io()) - .onBackpressureLatest() + .onBackpressureBuffer() .filter { download -> download.manga.id == manga.id } .observeOn(AndroidSchedulers.mainThread()) .subscribeLatestCache( @@ -375,7 +375,7 @@ class MangaPresenter( observeDownloadsPageSubscription?.let { remove(it) } observeDownloadsPageSubscription = downloadManager.queue.getProgressObservable() .observeOn(Schedulers.io()) - .onBackpressureLatest() + .onBackpressureBuffer() .filter { download -> download.manga.id == manga.id } .observeOn(AndroidSchedulers.mainThread()) .subscribeLatestCache(MangaController::onChapterDownloadUpdate) { _, 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 e056e0ad81..25049319d2 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 @@ -48,8 +48,6 @@ class ChapterDownloadView @JvmOverloads constructor(context: Context, attrs: Att state == Download.State.NOT_DOWNLOADED || state == Download.State.QUEUE if (shouldBeVisible) { hideAnimationBehavior = BaseProgressIndicator.HIDE_NONE - show() - if (state == Download.State.NOT_DOWNLOADED || state == Download.State.QUEUE) { trackThickness = 2.dpToPx setIndicatorColor(context.getThemeColor(android.R.attr.textColorHint)) @@ -72,6 +70,7 @@ class ChapterDownloadView @JvmOverloads constructor(context: Context, attrs: Att setIndicatorColor(context.getThemeColor(android.R.attr.textColorPrimary)) setProgressCompat(progress, true) } + show() } else { hideAnimationBehavior = BaseProgressIndicator.HIDE_OUTWARD hide() 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 d44af094cd..2ba0c7dfaf 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 @@ -41,7 +41,7 @@ class UpdatesPresenter( downloadManager.queue.getStatusObservable() .observeOn(Schedulers.io()) - .onBackpressureLatest() + .onBackpressureBuffer() .observeOn(AndroidSchedulers.mainThread()) .subscribeLatestCache( { view, it -> @@ -55,7 +55,7 @@ class UpdatesPresenter( downloadManager.queue.getProgressObservable() .observeOn(Schedulers.io()) - .onBackpressureLatest() + .onBackpressureBuffer() .observeOn(AndroidSchedulers.mainThread()) .subscribeLatestCache(UpdatesController::onChapterDownloadUpdate) { _, error -> Timber.e(error) From e26b8d8a3b0bee04c46f7a2feebb508fa1acd866 Mon Sep 17 00:00:00 2001 From: jmir1 Date: Tue, 8 Jun 2021 20:48:06 +0200 Subject: [PATCH 2/2] Fix library settings sheet causing app to crash... ...when the category list is empty --- .../eu/kanade/tachiyomi/ui/library/LibraryController.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index 409c738f36..fe0d33185b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt @@ -262,8 +262,12 @@ class LibraryController( } fun showSettingsSheet() { - adapter?.categories?.get(binding.libraryPager.currentItem)?.let { category -> - settingsSheet?.show(category) + if (adapter?.categories?.isNotEmpty() == true) { + adapter?.categories?.get(binding.libraryPager.currentItem)?.let { category -> + settingsSheet?.show(category) + } + } else { + settingsSheet?.show() } }