fix(LocalBook/EpubFile): skip to load Volume content

pull/1929/head
Xwite 2 years ago
parent 7c1c0ab930
commit 484a3782f1
  1. 11
      app/src/main/java/io/legado/app/model/localBook/EpubFile.kt

@ -121,14 +121,11 @@ class EpubFile(var book: Book) {
}
private fun getContent(chapter: BookChapter): String? {
val nextUrl = chapter.getVariable("nextUrl")
val startFragmentId = chapter.startFragmentId
val endFragmentId = chapter.endFragmentId
/*当前章节resource href 和下一章href相同时 应该视为二级目录 返回空白*/
//fix https://github.com/gedoor/legado/issues/1927 加载全部内容的bug
if (chapter.isVolume) return ""
/*获取当前章节文本*/
epubBook?.let { epubBook ->
val nextUrl = chapter.getVariable("nextUrl")
val startFragmentId = chapter.startFragmentId
val endFragmentId = chapter.endFragmentId
val elements = Elements()
var isChapter = false
/*一些书籍依靠href索引的resource会包含多个章节,需要依靠fragmentId来截取到当前章节的内容*/
@ -137,6 +134,8 @@ class EpubFile(var book: Book) {
if (chapter.url.substringBeforeLast("#") == res.href) {
elements.add(getBody(res, startFragmentId, endFragmentId))
isChapter = true
//fix https://github.com/gedoor/legado/issues/1927 加载全部内容的bug
if (chapter.isVolume) break
} else if (isChapter) {
if (nextUrl.isNullOrBlank() || res.href == nextUrl.substringBeforeLast("#")) {
break

Loading…
Cancel
Save