pull/1649/head
kunfei 3 years ago
parent 175cef81b7
commit a0d181a90b
  1. 5
      app/src/main/java/io/legado/app/model/localBook/TextFile.kt

@ -91,6 +91,9 @@ class TextFile(private val book: Book) {
* 按规则解析目录
*/
private fun analyze(pattern: Pattern?): ArrayList<BookChapter> {
if (pattern?.pattern().isNullOrEmpty()) {
return analyze()
}
pattern ?: return analyze()
val toc = arrayListOf<BookChapter>()
LocalBook.getBookInputStream(book).use { bis ->
@ -310,7 +313,7 @@ class TextFile(private val book: Book) {
curOffset += length.toLong()
}
//设置结尾章节
if (bufferStart > 100) {
if (bufferStart > 100 || toc.isEmpty()) {
val chapter = BookChapter()
chapter.title = "${blockPos}章(${chapterPos})"
chapter.start = toc.lastOrNull()?.end ?: curOffset

Loading…
Cancel
Save