From 77dc9f74840ddd8f5cb72ad0e8d78c7ec8c72845 Mon Sep 17 00:00:00 2001 From: Luna712 <142361265+Luna712@users.noreply.github.com> Date: Mon, 5 Aug 2024 12:57:51 -0600 Subject: [PATCH] Add support for progress on header downloads (#1238) --- .../cloudstream3/ui/download/DownloadAdapter.kt | 13 ++++++++++++- app/src/main/res/layout/download_header_episode.xml | 11 +++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadAdapter.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadAdapter.kt index 20458429..d211cb87 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadAdapter.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadAdapter.kt @@ -156,6 +156,16 @@ class DownloadAdapter( card.child ?: return downloadHeaderGotoChild.isVisible = false + val posDur = getViewPos(card.data.id) + downloadHeaderEpisodeProgress.apply { + isVisible = posDur != null + posDur?.let { + val visualPos = it.fixVisual() + max = (visualPos.duration / 1000).toInt() + progress = (visualPos.position / 1000).toInt() + } + } + val status = downloadButton.getStatus(card.child.id, card.currentBytes, card.totalBytes) if (status == DownloadStatusTell.IsDone) { // We do this here instead if we are finished downloading @@ -205,6 +215,7 @@ class DownloadAdapter( formattedSize: String ) { downloadButton.isVisible = false + downloadHeaderEpisodeProgress.isVisible = false downloadHeaderGotoChild.isVisible = !isMultiDeleteState try { @@ -218,7 +229,7 @@ class DownloadAdapter( formattedSize ) } catch (e: Exception) { - downloadHeaderInfo.text = "" + downloadHeaderInfo.text = null logError(e) } diff --git a/app/src/main/res/layout/download_header_episode.xml b/app/src/main/res/layout/download_header_episode.xml index 957869d4..385fb2e0 100644 --- a/app/src/main/res/layout/download_header_episode.xml +++ b/app/src/main/res/layout/download_header_episode.xml @@ -14,6 +14,17 @@ app:cardBackgroundColor="?attr/boxItemBackground" app:cardCornerRadius="@dimen/rounded_image_radius"> + +