优化 #5186
This commit is contained in:
@@ -3,6 +3,7 @@ package io.legado.app.help.book
|
||||
import android.graphics.BitmapFactory
|
||||
import android.os.ParcelFileDescriptor
|
||||
import androidx.documentfile.provider.DocumentFile
|
||||
import com.script.rhino.runScriptWithContext
|
||||
import io.legado.app.constant.AppLog
|
||||
import io.legado.app.constant.AppPattern
|
||||
import io.legado.app.constant.EventBus
|
||||
@@ -28,7 +29,6 @@ import io.legado.app.utils.getFile
|
||||
import io.legado.app.utils.isContentScheme
|
||||
import io.legado.app.utils.onEachParallel
|
||||
import io.legado.app.utils.postEvent
|
||||
import com.script.rhino.runScriptWithContext
|
||||
import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.ensureActive
|
||||
@@ -404,7 +404,11 @@ object BookHelp {
|
||||
bookChapter.getFileName()
|
||||
)
|
||||
if (file.exists()) {
|
||||
return file.readText()
|
||||
val string = file.readText()
|
||||
if (string.isEmpty()) {
|
||||
return null
|
||||
}
|
||||
return string
|
||||
}
|
||||
if (book.isLocal) {
|
||||
val string = LocalBook.getContent(book, bookChapter)
|
||||
|
||||
@@ -144,6 +144,9 @@ object LocalBook {
|
||||
val list = ArrayList(LinkedHashSet(chapters))
|
||||
list.forEachIndexed { index, bookChapter ->
|
||||
bookChapter.index = index
|
||||
if (bookChapter.title.isEmpty()) {
|
||||
bookChapter.title = "无标题章节"
|
||||
}
|
||||
}
|
||||
val replaceRules = ContentProcessor.get(book).getTitleReplaceRules()
|
||||
book.durChapterTitle = list.getOrElse(book.durChapterIndex) { list.last() }
|
||||
@@ -191,6 +194,11 @@ object LocalBook {
|
||||
return StringEscapeUtils.unescapeHtml4(content)
|
||||
}
|
||||
}
|
||||
|
||||
if (content.isNullOrEmpty()) {
|
||||
return null
|
||||
}
|
||||
|
||||
return content
|
||||
}
|
||||
|
||||
|
||||
@@ -214,9 +214,9 @@ class TextChapterLayout(
|
||||
emptyContent = contents.isEmpty(),
|
||||
isVolumeTitle = bookChapter.isVolume
|
||||
)
|
||||
pendingTextPage.lines.last().isParagraphEnd = true
|
||||
stringBuilder.append("\n")
|
||||
}
|
||||
pendingTextPage.lines.last().isParagraphEnd = true
|
||||
stringBuilder.append("\n")
|
||||
durY += titleBottomSpacing
|
||||
|
||||
// 如果是单图模式且当前页有内容,强制分页
|
||||
|
||||
Reference in New Issue
Block a user