From e8278c71007359d8714b649411e4c7db0ab6bc03 Mon Sep 17 00:00:00 2001 From: Farhan Arshad <43750646+farhan-arshad-dev@users.noreply.github.com> Date: Mon, 28 Oct 2024 10:14:52 +0500 Subject: [PATCH] fix: crash `current must not be NaN` during bulk download (#63) - Add validation to ensure that the progress value is not NaN. fixes: LEARNER-10248 --- .../org/openedx/course/presentation/ui/CourseVideosUI.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/course/src/main/java/org/openedx/course/presentation/ui/CourseVideosUI.kt b/course/src/main/java/org/openedx/course/presentation/ui/CourseVideosUI.kt index f0686926f..ff20ec55d 100644 --- a/course/src/main/java/org/openedx/course/presentation/ui/CourseVideosUI.kt +++ b/course/src/main/java/org/openedx/course/presentation/ui/CourseVideosUI.kt @@ -543,7 +543,12 @@ private fun AllVideosDownloadItem( ) } if (isDownloadingAllVideos) { - val progress = 1 - downloadModelsSize.remainingSize.toFloat() / downloadModelsSize.allSize + val progress = + if (downloadModelsSize.allSize == 0L) { + 0f + } else { + 1 - downloadModelsSize.remainingSize.toFloat() / downloadModelsSize.allSize + } val animatedProgress by animateFloatAsState( targetValue = progress,