From b120dae740c37e34e8769c04090af8044c734b78 Mon Sep 17 00:00:00 2001 From: Luna712 <142361265+Luna712@users.noreply.github.com> Date: Wed, 31 Jul 2024 12:15:08 -0600 Subject: [PATCH] Add support for progress on header downloads --- .../cloudstream3/ui/download/DownloadAdapter.kt | 11 +++++++++++ app/src/main/res/layout/download_header_episode.xml | 11 +++++++++++ 2 files changed, 22 insertions(+) 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..32eff75a 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 { 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"> + +