From 0fc7f2b32923ea14f1620426aa71284ca0871c37 Mon Sep 17 00:00:00 2001 From: Horis <8674809+821938089@users.noreply.github.com> Date: Sun, 27 Jul 2025 18:54:26 +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 --- .../main/java/io/legado/app/model/ReadBook.kt | 30 +++++++++++-------- .../java/io/legado/app/model/ReadManga.kt | 30 +++++++++++-------- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/ReadBook.kt b/app/src/main/java/io/legado/app/model/ReadBook.kt index 14cab7ce3..18a5a9335 100644 --- a/app/src/main/java/io/legado/app/model/ReadBook.kt +++ b/app/src/main/java/io/legado/app/model/ReadBook.kt @@ -858,21 +858,25 @@ object ReadBook : CoroutineScope by MainScope() { fun saveRead(pageChanged: Boolean = false) { executor.execute { - val book = book ?: return@execute - book.lastCheckCount = 0 - book.durChapterTime = System.currentTimeMillis() - val chapterChanged = book.durChapterIndex != durChapterIndex - book.durChapterIndex = durChapterIndex - book.durChapterPos = durChapterPos - if (!pageChanged || chapterChanged) { - appDb.bookChapterDao.getChapter(book.bookUrl, durChapterIndex)?.let { - book.durChapterTitle = it.getDisplayTitle( - ContentProcessor.get(book.name, book.origin).getTitleReplaceRules(), - book.getUseReplaceRule() - ) + kotlin.runCatching { + val book = book ?: return@execute + book.lastCheckCount = 0 + book.durChapterTime = System.currentTimeMillis() + val chapterChanged = book.durChapterIndex != durChapterIndex + book.durChapterIndex = durChapterIndex + book.durChapterPos = durChapterPos + if (!pageChanged || chapterChanged) { + appDb.bookChapterDao.getChapter(book.bookUrl, durChapterIndex)?.let { + book.durChapterTitle = it.getDisplayTitle( + ContentProcessor.get(book.name, book.origin).getTitleReplaceRules(), + book.getUseReplaceRule() + ) + } } + appDb.bookDao.update(book) + }.onFailure { + AppLog.put("保存书籍阅读进度信息出错\n$it", it) } - appDb.bookDao.update(book) } } diff --git a/app/src/main/java/io/legado/app/model/ReadManga.kt b/app/src/main/java/io/legado/app/model/ReadManga.kt index 6483559aa..07153a936 100644 --- a/app/src/main/java/io/legado/app/model/ReadManga.kt +++ b/app/src/main/java/io/legado/app/model/ReadManga.kt @@ -327,21 +327,25 @@ object ReadManga : CoroutineScope by MainScope() { fun saveRead(pageChanged: Boolean = false) { executor.execute { - val book = book ?: return@execute - book.lastCheckCount = 0 - book.durChapterTime = System.currentTimeMillis() - val chapterChanged = book.durChapterIndex != durChapterIndex - book.durChapterIndex = durChapterIndex - book.durChapterPos = durChapterPos - if (!pageChanged || chapterChanged) { - appDb.bookChapterDao.getChapter(book.bookUrl, durChapterIndex)?.let { - book.durChapterTitle = it.getDisplayTitle( - ContentProcessor.get(book.name, book.origin).getTitleReplaceRules(), - book.getUseReplaceRule() - ) + kotlin.runCatching { + val book = book ?: return@execute + book.lastCheckCount = 0 + book.durChapterTime = System.currentTimeMillis() + val chapterChanged = book.durChapterIndex != durChapterIndex + book.durChapterIndex = durChapterIndex + book.durChapterPos = durChapterPos + if (!pageChanged || chapterChanged) { + appDb.bookChapterDao.getChapter(book.bookUrl, durChapterIndex)?.let { + book.durChapterTitle = it.getDisplayTitle( + ContentProcessor.get(book.name, book.origin).getTitleReplaceRules(), + book.getUseReplaceRule() + ) + } } + appDb.bookDao.update(book) + }.onFailure { + AppLog.put("保存漫画阅读进度信息出错\n$it", it) } - appDb.bookDao.update(book) } }