From 6ffc857a46968b5d9bd383c13c5b3a7f831ea5eb Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 17 Feb 2022 09:27: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 --- .../main/java/io/legado/app/model/localBook/TextFile.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 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 afe3f1b0a..40659242f 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 @@ -151,12 +151,17 @@ class TextFile(private val book: Book) { val chapterContent = blockContent.substring(seekPos, chapterStart) val chapterLength = chapterContent.toByteArray(charset).size val lastStart = toc.lastOrNull()?.start ?: curOffset - if (curOffset + chapterLength - lastStart > maxLengthWithToc) { + if (book.getSplitLongChapter() && curOffset + chapterLength - lastStart > maxLengthWithToc) { toc.lastOrNull()?.let { it.end = it.start } //章节字数太多进行拆分 - toc.addAll(analyze(lastStart, curOffset + chapterLength)) + toc.addAll( + analyze( + lastStart + matcher.group().length, + curOffset + chapterLength + ) + ) //创建当前章节 val curChapter = BookChapter() curChapter.title = matcher.group()