Browse Source

[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
Platiplus 3 years ago
parent
commit
e98f90b099

+ 17 - 1
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)")
+        }
+    }
 }