From 8b221c03c9868141b9a07efa87f5a700804958b3 Mon Sep 17 00:00:00 2001 From: HapeLee <1321903405@qq.com> Date: Sun, 19 Oct 2025 13:55:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=E4=B8=8B=E8=BD=BD=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=BF=9B=E5=BA=A6=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legato/kazusa/model/CacheBook.kt | 14 ++++++++++++++ .../legato/kazusa/service/CacheBookService.kt | 17 ++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legato/kazusa/model/CacheBook.kt b/app/src/main/java/io/legato/kazusa/model/CacheBook.kt index 91423ae66..dd54ba5a5 100644 --- a/app/src/main/java/io/legato/kazusa/model/CacheBook.kt +++ b/app/src/main/java/io/legato/kazusa/model/CacheBook.kt @@ -30,6 +30,20 @@ object CacheBook { val cacheBookMap = ConcurrentHashMap() + val totalCount: Int + get() { + var total = 0 + cacheBookMap.forEach { (_, model) -> + total += model.waitCount + model.onDownloadCount + } + total += successDownloadSet.size + total += errorDownloadMap.size + return total + } + + val completedCount: Int + get() = successDownloadSet.size + errorDownloadMap.size + @Synchronized fun getOrCreate(bookUrl: String): CacheBookModel? { val book = appDb.bookDao.getBook(bookUrl) ?: return null diff --git a/app/src/main/java/io/legato/kazusa/service/CacheBookService.kt b/app/src/main/java/io/legato/kazusa/service/CacheBookService.kt index 64078e6bb..31242dacf 100644 --- a/app/src/main/java/io/legato/kazusa/service/CacheBookService.kt +++ b/app/src/main/java/io/legato/kazusa/service/CacheBookService.kt @@ -210,9 +210,20 @@ class CacheBookService : BaseService() { } private fun upCacheBookNotification() { - notificationBuilder.setContentText(notificationContent) - val notification = notificationBuilder.build() - notificationManager.notify(NotificationId.CacheBookService, notification) + val total = CacheBook.totalCount + val progress = CacheBook.completedCount + val summary = CacheBook.downloadSummary + + notificationBuilder.apply { + setContentText(summary) + if (total > 0) { + setProgress(total, progress, false) + } else { + setProgress(0, 0, true) + } + } + + notificationManager.notify(NotificationId.CacheBookService, notificationBuilder.build()) } /**