From b4670db98792df348b9023cba5032087627f7de6 Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 23 Sep 2021 23:18:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/constant/AppConst.kt | 8 ++++---- .../main/java/io/legado/app/service/DownloadService.kt | 8 ++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/legado/app/constant/AppConst.kt b/app/src/main/java/io/legado/app/constant/AppConst.kt index f7b2289c9..8acd03c03 100644 --- a/app/src/main/java/io/legado/app/constant/AppConst.kt +++ b/app/src/main/java/io/legado/app/constant/AppConst.kt @@ -51,10 +51,10 @@ object AppConst { const val bookGroupAudioId = -3L const val bookGroupNoneId = -4L - const val notificationIdRead = 1144771 - const val notificationIdAudio = 1144772 - const val notificationIdWeb = 1144773 - const val notificationIdDownload = 1144774 + const val notificationIdRead = -1144771 + const val notificationIdAudio = -1144772 + const val notificationIdWeb = -1144773 + const val notificationIdDownload = -1144774 val urlOption: String by lazy { """ diff --git a/app/src/main/java/io/legado/app/service/DownloadService.kt b/app/src/main/java/io/legado/app/service/DownloadService.kt index 8da603db5..e457b9904 100644 --- a/app/src/main/java/io/legado/app/service/DownloadService.kt +++ b/app/src/main/java/io/legado/app/service/DownloadService.kt @@ -8,7 +8,6 @@ import android.content.IntentFilter import android.net.Uri import android.os.Build import androidx.core.app.NotificationCompat -import androidx.core.app.NotificationManagerCompat import androidx.core.content.FileProvider import io.legado.app.R import io.legado.app.base.BaseService @@ -30,7 +29,6 @@ import java.io.File class DownloadService : BaseService() { private val groupKey = "${appCtx.packageName}.download" - private val summaryId = 745893 private val downloads = hashMapOf() private val completeDownloads = hashSetOf() private var upStateJob: Job? = null @@ -167,7 +165,7 @@ class DownloadService : BaseService() { .setGroup(groupKey) .setGroupSummary(true) val notification = notificationBuilder.build() - startForeground(summaryId, notification) + startForeground(AppConst.notificationIdDownload, notification) } /** @@ -199,9 +197,7 @@ class DownloadService : BaseService() { .setProgress(max, progress, false) .setGroup(groupKey) val notification = notificationBuilder.build() - NotificationManagerCompat.from(this).apply { - notify(downloadId.toInt(), notification) - } + notificationManager.notify(downloadId.toInt(), notification) } } \ No newline at end of file