Add support for progress on header downloads (#1238)

This commit is contained in:
Luna712 2024-08-05 12:57:51 -06:00 committed by GitHub
parent f6a65f38db
commit 77dc9f7484
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 1 deletions

View file

@ -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)
}

View file

@ -14,6 +14,17 @@
app:cardBackgroundColor="?attr/boxItemBackground"
app:cardCornerRadius="@dimen/rounded_image_radius">
<androidx.core.widget.ContentLoadingProgressBar
android:id="@+id/download_header_episode_progress"
style="@android:style/Widget.Material.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="5dp"
android:layout_gravity="bottom"
android:layout_marginBottom="-1.5dp"
android:progressBackgroundTint="?attr/colorPrimary"
android:progressTint="?attr/colorPrimary"
tools:progress="50" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"