Skip to content

Commit

Permalink
Add support for progress on header downloads (#1238)
Browse files Browse the repository at this point in the history
  • Loading branch information
Luna712 authored Aug 5, 2024
1 parent f6a65f3 commit 77dc9f7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -205,6 +215,7 @@ class DownloadAdapter(
formattedSize: String
) {
downloadButton.isVisible = false
downloadHeaderEpisodeProgress.isVisible = false
downloadHeaderGotoChild.isVisible = !isMultiDeleteState

try {
Expand All @@ -218,7 +229,7 @@ class DownloadAdapter(
formattedSize
)
} catch (e: Exception) {
downloadHeaderInfo.text = ""
downloadHeaderInfo.text = null
logError(e)
}

Expand Down
11 changes: 11 additions & 0 deletions app/src/main/res/layout/download_header_episode.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 77dc9f7

Please sign in to comment.