Skip to content

Commit

Permalink
fix: show only one screen with all downloadable content (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
dixidroid authored Jul 8, 2024
1 parent 5abf44d commit ba305a0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -388,14 +388,17 @@ class CourseOutlineViewModel(
}
}

fun downloadBlocks(blocksIds: List<String>, fragmentManager: FragmentManager, context: Context) {
fun downloadBlocks(
blocksIds: List<String>,
fragmentManager: FragmentManager,
context: Context
) {
if (blocksIds.find { isBlockDownloading(it) } != null) {
courseRouter.navigateToDownloadQueue(fm = fragmentManager)
return
}
blocksIds.forEach { blockId ->
if (isBlockDownloading(blockId)) {
courseRouter.navigateToDownloadQueue(
fm = fragmentManager,
getDownloadableChildren(blockId) ?: arrayListOf()
)
} else if (isBlockDownloaded(blockId)) {
if (isBlockDownloaded(blockId)) {
removeDownloadModels(blockId)
} else {
saveDownloadModels(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,7 @@ fun OfflineQueueCard(
maxLines = 1
)

val progress = progressValue.toFloat() / progressSize

val progress = if (progressSize == 0L) 0f else progressValue.toFloat() / progressSize
LinearProgressIndicator(
modifier = Modifier
.fillMaxWidth()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,17 @@ class CourseVideoViewModel(
return resultBlocks.toList()
}

fun downloadBlocks(blocksIds: List<String>, fragmentManager: FragmentManager, context: Context) {
fun downloadBlocks(
blocksIds: List<String>,
fragmentManager: FragmentManager,
context: Context
) {
if (blocksIds.find { isBlockDownloading(it) } != null) {
courseRouter.navigateToDownloadQueue(fm = fragmentManager)
return
}
blocksIds.forEach { blockId ->
if (isBlockDownloading(blockId)) {
courseRouter.navigateToDownloadQueue(
fm = fragmentManager,
getDownloadableChildren(blockId) ?: arrayListOf()
)
} else if (isBlockDownloaded(blockId)) {
if (isBlockDownloaded(blockId)) {
removeDownloadModels(blockId)
} else {
saveDownloadModels(
Expand Down

0 comments on commit ba305a0

Please sign in to comment.