[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
This commit is contained in:
Platiplus 2021-10-07 23:13:35 -03:00 committed by GitHub
parent 2e127dff1f
commit e98f90b099
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,7 +36,6 @@ class DownloadController :
* Adapter containing the active downloads. * Adapter containing the active downloads.
*/ */
private var adapter: DownloadAdapter? = null private var adapter: DownloadAdapter? = null
private var actionFab: ExtendedFloatingActionButton? = null private var actionFab: ExtendedFloatingActionButton? = null
private var actionFabScrollListener: RecyclerView.OnScrollListener? = null private var actionFabScrollListener: RecyclerView.OnScrollListener? = null
@ -100,6 +99,12 @@ class DownloadController :
presenter.getDownloadProgressObservable() presenter.getDownloadProgressObservable()
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribeUntilDestroy { onUpdateDownloadedPages(it) } .subscribeUntilDestroy { onUpdateDownloadedPages(it) }
presenter.downloadQueue.getUpdatedObservable()
.observeOn(AndroidSchedulers.mainThread())
.subscribeUntilDestroy {
updateTitle(it.size)
}
} }
override fun configureFab(fab: ExtendedFloatingActionButton) { override fun configureFab(fab: ExtendedFloatingActionButton) {
@ -290,6 +295,7 @@ class DownloadController :
if (presenter.downloadQueue.isEmpty()) { if (presenter.downloadQueue.isEmpty()) {
binding.emptyView.show(R.string.information_no_downloads) binding.emptyView.show(R.string.information_no_downloads)
actionFab?.isVisible = false actionFab?.isVisible = false
updateTitle()
} else { } else {
binding.emptyView.hide() binding.emptyView.hide()
actionFab?.apply { 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)")
}
}
} }