Loading app/src/main/java/foundation/e/apps/data/install/AppManagerWrapper.kt +20 −17 Original line number Diff line number Diff line Loading @@ -143,23 +143,26 @@ class AppManagerWrapper @Inject constructor( progress: DownloadProgress ): Int { val downloadIds = appInstall.downloadIdMap.keys var percent = 0 if (downloadIds.isEmpty()) { return 0 } if (downloadIds.isNotEmpty()) { val totalSizeBytes = progress.totalSizeBytes .filterKeys { downloadIds.contains(it) } .values .sum() if (totalSizeBytes > 0) { val downloadedSoFar = progress.bytesDownloadedSoFar .filterKeys { downloadIds.contains(it) } .values .sum() percent = ((downloadedSoFar / totalSizeBytes.toDouble()) * PERCENTAGE_MULTIPLIER) val percent = if (totalSizeBytes > 0) { ((downloadedSoFar / totalSizeBytes.toDouble()) * PERCENTAGE_MULTIPLIER) .toInt() .coerceIn(0, PERCENTAGE_MULTIPLIER) } } else { 0 } return percent Loading Loading
app/src/main/java/foundation/e/apps/data/install/AppManagerWrapper.kt +20 −17 Original line number Diff line number Diff line Loading @@ -143,23 +143,26 @@ class AppManagerWrapper @Inject constructor( progress: DownloadProgress ): Int { val downloadIds = appInstall.downloadIdMap.keys var percent = 0 if (downloadIds.isEmpty()) { return 0 } if (downloadIds.isNotEmpty()) { val totalSizeBytes = progress.totalSizeBytes .filterKeys { downloadIds.contains(it) } .values .sum() if (totalSizeBytes > 0) { val downloadedSoFar = progress.bytesDownloadedSoFar .filterKeys { downloadIds.contains(it) } .values .sum() percent = ((downloadedSoFar / totalSizeBytes.toDouble()) * PERCENTAGE_MULTIPLIER) val percent = if (totalSizeBytes > 0) { ((downloadedSoFar / totalSizeBytes.toDouble()) * PERCENTAGE_MULTIPLIER) .toInt() .coerceIn(0, PERCENTAGE_MULTIPLIER) } } else { 0 } return percent Loading