From d46249be0d1698c5f4328d88ff1d8fa27f3d26e1 Mon Sep 17 00:00:00 2001 From: Horis <8674809+821938089@users.noreply.github.com> Date: Fri, 23 May 2025 22:00:18 +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 --- .../io/legado/app/model/localBook/TextFile.kt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/localBook/TextFile.kt b/app/src/main/java/io/legado/app/model/localBook/TextFile.kt index c07b1d1b4..fca8878e4 100644 --- a/app/src/main/java/io/legado/app/model/localBook/TextFile.kt +++ b/app/src/main/java/io/legado/app/model/localBook/TextFile.kt @@ -7,6 +7,7 @@ import io.legado.app.data.entities.BookChapter import io.legado.app.data.entities.TxtTocRule import io.legado.app.exception.EmptyFileException import io.legado.app.help.DefaultData +import io.legado.app.help.book.isLocalModified import io.legado.app.utils.EncodingDetect import io.legado.app.utils.MD5Utils import io.legado.app.utils.StringUtils @@ -28,7 +29,7 @@ class TextFile(private var book: Book) { @Synchronized private fun getTextFile(book: Book): TextFile { - if (textFile == null || textFile?.book?.bookUrl != book.bookUrl) { + if (textFile == null || textFile?.book?.bookUrl != book.bookUrl || book.isLocalModified()) { textFile = TextFile(book) return textFile!! } @@ -227,7 +228,8 @@ class TextFile(private var book: Book) { qyChapter.title = "前言" qyChapter.start = curOffset qyChapter.end = curOffset + chapterLength - qyChapter.wordCount = StringUtils.wordCountFormat(chapterContent.length) + qyChapter.wordCount = + StringUtils.wordCountFormat(chapterContent.length) toc.add(qyChapter) book.intro = if (chapterContent.length <= 500) { chapterContent @@ -248,7 +250,8 @@ class TextFile(private var book: Book) { //将当前段落添加上一章去 lastChapter.end = lastChapter.end!! + chapterLength lastChapterWordCount += chapterContent.length - lastChapter.wordCount = StringUtils.wordCountFormat(lastChapterWordCount) + lastChapter.wordCount = + StringUtils.wordCountFormat(lastChapterWordCount) //创建当前章节 val curChapter = BookChapter() curChapter.title = matcher.group() @@ -265,7 +268,8 @@ class TextFile(private var book: Book) { chapterContent.substringAfter(lastChapter.title).isBlank() lastChapter.end = lastChapter.start!! + chapterLength - lastChapter.wordCount = StringUtils.wordCountFormat(chapterContent.length) + lastChapter.wordCount = + StringUtils.wordCountFormat(chapterContent.length) //创建当前章节 val curChapter = BookChapter() curChapter.title = matcher.group() @@ -276,7 +280,8 @@ class TextFile(private var book: Book) { curChapter.title = matcher.group() curChapter.start = curOffset curChapter.end = curOffset - curChapter.wordCount = StringUtils.wordCountFormat(chapterContent.length) + curChapter.wordCount = + StringUtils.wordCountFormat(chapterContent.length) toc.add(curChapter) } bookWordCount += chapterContent.length