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