This commit is contained in:
Horis
2023-11-29 09:55:00 +08:00
parent 1dc6bc1307
commit df909e0cb5
@@ -140,7 +140,7 @@ class ExportBookService : BaseService() {
startForeground(NotificationId.ExportBookService, notification.build()) startForeground(NotificationId.ExportBookService, notification.build())
} }
private fun upExportNotification() { private fun upExportNotification(finish: Boolean = false) {
val notification = NotificationCompat.Builder(this, AppConst.channelIdDownload) val notification = NotificationCompat.Builder(this, AppConst.channelIdDownload)
.setSmallIcon(R.drawable.ic_export) .setSmallIcon(R.drawable.ic_export)
.setSubText(getString(R.string.export_book)) .setSubText(getString(R.string.export_book))
@@ -149,7 +149,7 @@ class ExportBookService : BaseService() {
.setContentText(notificationContentText) .setContentText(notificationContentText)
.setDeleteIntent(servicePendingIntent<ExportBookService>(IntentAction.stop)) .setDeleteIntent(servicePendingIntent<ExportBookService>(IntentAction.stop))
.setGroup(groupKey) .setGroup(groupKey)
if (exportJob?.isActive == true) { if (!finish) {
notification.setOngoing(true) notification.setOngoing(true)
notification.addAction( notification.addAction(
R.drawable.ic_stop_black_24dp, R.drawable.ic_stop_black_24dp,
@@ -168,7 +168,7 @@ class ExportBookService : BaseService() {
while (true) { while (true) {
val (bookUrl, exportConfig) = waitExportBooks.entries.firstOrNull() ?: let { val (bookUrl, exportConfig) = waitExportBooks.entries.firstOrNull() ?: let {
notificationContentText = "导出完成" notificationContentText = "导出完成"
upExportNotification() upExportNotification(true)
return@launch return@launch
} }
exportProgress[bookUrl] = 0 exportProgress[bookUrl] = 0