diff --git a/app/src/main/java/com/aurora/store/data/work/DownloadWorker.kt b/app/src/main/java/com/aurora/store/data/work/DownloadWorker.kt index 4d0af1959..2ba64aee4 100644 --- a/app/src/main/java/com/aurora/store/data/work/DownloadWorker.kt +++ b/app/src/main/java/com/aurora/store/data/work/DownloadWorker.kt @@ -193,7 +193,7 @@ class DownloadWorker @AssistedInject constructor( } private suspend fun onProgress(downloadInfo: DownloadInfo) { - if (!isStopped) { + if (!isStopped && !download.isFinished) { val progress = ((downloadedBytes + downloadInfo.bytesCopied) * 100 / totalBytes).toInt() // Individual file progress can be negligible in contrast to total progress @@ -236,7 +236,10 @@ class DownloadWorker @AssistedInject constructor( private suspend fun notifyStatus(status: DownloadStatus, dID: Int = -1) { // Update database for all status except downloading which is handled onProgress if (status != DownloadStatus.DOWNLOADING) { - download.status = status + download.apply { + this.status = status + if (download.status == DownloadStatus.COMPLETED) this.progress = 100 + } downloadDao.update(download) } diff --git a/app/src/main/java/com/aurora/store/util/NotificationUtil.kt b/app/src/main/java/com/aurora/store/util/NotificationUtil.kt index a08d97b46..2583cca3b 100644 --- a/app/src/main/java/com/aurora/store/util/NotificationUtil.kt +++ b/app/src/main/java/com/aurora/store/util/NotificationUtil.kt @@ -247,7 +247,7 @@ object NotificationUtil { builder.setCategory(Notification.CATEGORY_ERROR) } - DownloadStatus.COMPLETED -> if (download.progress == 100) { + DownloadStatus.COMPLETED -> { builder.setSmallIcon(android.R.drawable.stat_sys_download_done) builder.setContentText(context.getString(R.string.download_completed)) builder.setAutoCancel(true)