fix:txt目录解析时判断空白章节bug
This commit is contained in:
@@ -141,18 +141,17 @@ class TextFile(private val book: Book) {
|
|||||||
qyChapter.title = "前言"
|
qyChapter.title = "前言"
|
||||||
qyChapter.start = curOffset
|
qyChapter.start = curOffset
|
||||||
qyChapter.end = chapterLength.toLong()
|
qyChapter.end = chapterLength.toLong()
|
||||||
qyChapter.isVolume = mChapterContent.substringAfter(qyChapter.title).isBlank()
|
|
||||||
toc.add(qyChapter)
|
toc.add(qyChapter)
|
||||||
}
|
}
|
||||||
//创建当前章节
|
//创建当前章节
|
||||||
val curChapter = BookChapter()
|
val curChapter = BookChapter()
|
||||||
curChapter.title = matcher.group()
|
curChapter.title = matcher.group()
|
||||||
curChapter.start = chapterLength.toLong()
|
curChapter.start = chapterLength.toLong()
|
||||||
curChapter.isVolume = mChapterContent.substringAfter(curChapter.title).isBlank()
|
|
||||||
toc.add(curChapter)
|
toc.add(curChapter)
|
||||||
} else { //否则就block分割之后,上一个章节的剩余内容
|
} else { //否则就block分割之后,上一个章节的剩余内容
|
||||||
//获取上一章节
|
//获取上一章节
|
||||||
val lastChapter = toc.last()
|
val lastChapter = toc.last()
|
||||||
|
toc.last().isVolume = mChapterContent.substringAfter(lastChapter.title).isBlank()
|
||||||
//将当前段落添加上一章去
|
//将当前段落添加上一章去
|
||||||
lastChapter.end =
|
lastChapter.end =
|
||||||
lastChapter.end!! + chapterLength.toLong()
|
lastChapter.end!! + chapterLength.toLong()
|
||||||
@@ -160,27 +159,25 @@ class TextFile(private val book: Book) {
|
|||||||
val curChapter = BookChapter()
|
val curChapter = BookChapter()
|
||||||
curChapter.title = matcher.group()
|
curChapter.title = matcher.group()
|
||||||
curChapter.start = lastChapter.end
|
curChapter.start = lastChapter.end
|
||||||
curChapter.isVolume = mChapterContent.substringAfter(curChapter.title).isBlank()
|
|
||||||
toc.add(curChapter)
|
toc.add(curChapter)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (toc.isNotEmpty()) { //获取章节内容
|
if (toc.isNotEmpty()) { //获取章节内容
|
||||||
//获取上一章节
|
//获取上一章节
|
||||||
val lastChapter = toc.last()
|
val lastChapter = toc.last()
|
||||||
|
toc.last().isVolume = mChapterContent.substringAfter(lastChapter.title).isBlank()
|
||||||
lastChapter.end =
|
lastChapter.end =
|
||||||
lastChapter.start!! + chapterContent.toByteArray(charset).size.toLong()
|
lastChapter.start!! + chapterContent.toByteArray(charset).size.toLong()
|
||||||
//创建当前章节
|
//创建当前章节
|
||||||
val curChapter = BookChapter()
|
val curChapter = BookChapter()
|
||||||
curChapter.title = matcher.group()
|
curChapter.title = matcher.group()
|
||||||
curChapter.start = lastChapter.end
|
curChapter.start = lastChapter.end
|
||||||
curChapter.isVolume = mChapterContent.substringAfter(curChapter.title).isBlank()
|
|
||||||
toc.add(curChapter)
|
toc.add(curChapter)
|
||||||
} else { //如果章节不存在则创建章节
|
} else { //如果章节不存在则创建章节
|
||||||
val curChapter = BookChapter()
|
val curChapter = BookChapter()
|
||||||
curChapter.title = matcher.group()
|
curChapter.title = matcher.group()
|
||||||
curChapter.start = curOffset
|
curChapter.start = curOffset
|
||||||
curChapter.end = curOffset
|
curChapter.end = curOffset
|
||||||
curChapter.isVolume = mChapterContent.substringAfter(curChapter.title).isBlank()
|
|
||||||
toc.add(curChapter)
|
toc.add(curChapter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user