From e98f90b0992af1eb99c2aca4bbe7b26cdb9a231b Mon Sep 17 00:00:00 2001 From: Platiplus Date: Thu, 7 Oct 2021 23:13:35 -0300 Subject: [PATCH] [6059] - Pending downloads count on Download queue screen (#6064) * Updating the download queue label to account for pending downloads even on paused state * changing separator * Created observer to update the TitleBar of the controller to reflect pending downloads * Reverting changes from MoreController that were made in an another commit * Refactoring updateTitle method --- .../ui/download/DownloadController.kt | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadController.kt index dd861f8a2..b65cca6de 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadController.kt @@ -36,7 +36,6 @@ class DownloadController : * Adapter containing the active downloads. */ private var adapter: DownloadAdapter? = null - private var actionFab: ExtendedFloatingActionButton? = null private var actionFabScrollListener: RecyclerView.OnScrollListener? = null @@ -100,6 +99,12 @@ class DownloadController : presenter.getDownloadProgressObservable() .observeOn(AndroidSchedulers.mainThread()) .subscribeUntilDestroy { onUpdateDownloadedPages(it) } + + presenter.downloadQueue.getUpdatedObservable() + .observeOn(AndroidSchedulers.mainThread()) + .subscribeUntilDestroy { + updateTitle(it.size) + } } override fun configureFab(fab: ExtendedFloatingActionButton) { @@ -290,6 +295,7 @@ class DownloadController : if (presenter.downloadQueue.isEmpty()) { binding.emptyView.show(R.string.information_no_downloads) actionFab?.isVisible = false + updateTitle() } else { binding.emptyView.hide() actionFab?.apply { @@ -368,4 +374,14 @@ class DownloadController : } } } + + private fun updateTitle(queueSize: Int = 0) { + val defaultTitle = getTitle() + + if (queueSize == 0) { + setTitle(defaultTitle) + } else { + setTitle("$defaultTitle ($queueSize)") + } + } }