mirror of
https://github.com/gedoor/legado.git
synced 2024-08-30 09:23:26 +08:00
fix: fix #2862
This commit is contained in:
parent
1470f6e1bb
commit
aff1f5a886
@ -137,7 +137,8 @@ class EpubFile(var book: Book) {
|
|||||||
}
|
}
|
||||||
/*获取当前章节文本*/
|
/*获取当前章节文本*/
|
||||||
epubBook?.let { epubBook ->
|
epubBook?.let { epubBook ->
|
||||||
val nextUrl = chapter.getVariable("nextUrl")
|
val nextChapterFirstResourceHref = chapter.getVariable("nextUrl").substringBeforeLast("#")
|
||||||
|
val currentChapterFirstResourceHref = chapter.url.substringBeforeLast("#")
|
||||||
val startFragmentId = chapter.startFragmentId
|
val startFragmentId = chapter.startFragmentId
|
||||||
val endFragmentId = chapter.endFragmentId
|
val endFragmentId = chapter.endFragmentId
|
||||||
val elements = Elements()
|
val elements = Elements()
|
||||||
@ -147,20 +148,20 @@ class EpubFile(var book: Book) {
|
|||||||
/*注:这里较大增加了内容加载的时间,所以首次获取内容后可存储到本地cache,减少重复加载*/
|
/*注:这里较大增加了内容加载的时间,所以首次获取内容后可存储到本地cache,减少重复加载*/
|
||||||
for (res in epubBook.contents) {
|
for (res in epubBook.contents) {
|
||||||
if (!findChapterFirstSource) {
|
if (!findChapterFirstSource) {
|
||||||
if (chapter.url == res.href) findChapterFirstSource = true
|
if (currentChapterFirstResourceHref == res.href) findChapterFirstSource = true
|
||||||
// 第一个xhtml文件
|
// 第一个xhtml文件
|
||||||
elements.add(
|
elements.add(
|
||||||
getBody(res, startFragmentId, endFragmentId)
|
getBody(res, startFragmentId, endFragmentId)
|
||||||
)
|
)
|
||||||
if (chapter.url == nextUrl) break
|
if (currentChapterFirstResourceHref == nextChapterFirstResourceHref) break
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if (nextUrl != res.href) {
|
if (nextChapterFirstResourceHref != res.href) {
|
||||||
// 其余部分
|
// 其余部分
|
||||||
elements.add(getBody(res, null, null))
|
elements.add(getBody(res, null, null))
|
||||||
} else {
|
} else {
|
||||||
// 下一章节的第一个xhtml
|
// 下一章节的第一个xhtml
|
||||||
if (!endFragmentId.isNullOrBlank()) {
|
if (includeNextChapterResource) {
|
||||||
//有Fragment 则添加到上一章节
|
//有Fragment 则添加到上一章节
|
||||||
elements.add(getBody(res, null, endFragmentId))
|
elements.add(getBody(res, null, endFragmentId))
|
||||||
}
|
}
|
||||||
@ -360,7 +361,7 @@ class EpubFile(var book: Book) {
|
|||||||
val chapter = BookChapter()
|
val chapter = BookChapter()
|
||||||
chapter.bookUrl = book.bookUrl
|
chapter.bookUrl = book.bookUrl
|
||||||
chapter.title = ref.title
|
chapter.title = ref.title
|
||||||
chapter.url = ref.completeHref.substringBeforeLast("#")
|
chapter.url = ref.completeHref
|
||||||
chapter.startFragmentId = ref.fragmentId
|
chapter.startFragmentId = ref.fragmentId
|
||||||
chapterList.lastOrNull()?.endFragmentId = chapter.startFragmentId
|
chapterList.lastOrNull()?.endFragmentId = chapter.startFragmentId
|
||||||
chapterList.lastOrNull()?.putVariable("nextUrl", chapter.url)
|
chapterList.lastOrNull()?.putVariable("nextUrl", chapter.url)
|
||||||
|
Loading…
Reference in New Issue
Block a user