From 2b8c17208bca05df76a4249425046beb539a49a5 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 9 Jan 2022 22:12:43 +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 | 16 +++++++++++----- 1 file changed, 11 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 3da94538f..bf759fb28 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 @@ -269,11 +269,17 @@ class TextFile(private val book: Book) { curOffset += length.toLong() } //设置结尾章节 - val chapter = BookChapter() - chapter.title = "第${blockPos}章(${chapterPos + 1})" - chapter.start = toc.lastOrNull()?.end ?: curOffset - chapter.end = chapter.start!! + bufferStart - toc.add(chapter) + if (bufferStart > 100) { + val chapter = BookChapter() + chapter.title = "第${blockPos}章(${chapterPos + 1})" + chapter.start = toc.lastOrNull()?.end ?: curOffset + chapter.end = chapter.start!! + bufferStart + toc.add(chapter) + } else { + toc.lastOrNull()?.let { + it.end = it.end!! + bufferStart + } + } } if (toc.isEmpty()) { return analyze()