优化
This commit is contained in:
@@ -142,7 +142,7 @@ class EpubFile(var book: Book) {
|
|||||||
return "<img src=\"cover.jpeg\" />"
|
return "<img src=\"cover.jpeg\" />"
|
||||||
}
|
}
|
||||||
/*获取当前章节文本*/
|
/*获取当前章节文本*/
|
||||||
epubBook?.let {
|
val contents = epubBookContents ?: return null
|
||||||
val nextChapterFirstResourceHref = chapter.getVariable("nextUrl")?.substringBeforeLast("#")
|
val nextChapterFirstResourceHref = chapter.getVariable("nextUrl")?.substringBeforeLast("#")
|
||||||
val currentChapterFirstResourceHref = chapter.url.substringBeforeLast("#")
|
val currentChapterFirstResourceHref = chapter.url.substringBeforeLast("#")
|
||||||
val isLastChapter = nextChapterFirstResourceHref.isNullOrBlank()
|
val isLastChapter = nextChapterFirstResourceHref.isNullOrBlank()
|
||||||
@@ -153,7 +153,6 @@ class EpubFile(var book: Book) {
|
|||||||
val includeNextChapterResource = !endFragmentId.isNullOrBlank()
|
val includeNextChapterResource = !endFragmentId.isNullOrBlank()
|
||||||
/*一些书籍依靠href索引的resource会包含多个章节,需要依靠fragmentId来截取到当前章节的内容*/
|
/*一些书籍依靠href索引的resource会包含多个章节,需要依靠fragmentId来截取到当前章节的内容*/
|
||||||
/*注:这里较大增加了内容加载的时间,所以首次获取内容后可存储到本地cache,减少重复加载*/
|
/*注:这里较大增加了内容加载的时间,所以首次获取内容后可存储到本地cache,减少重复加载*/
|
||||||
val contents = epubBookContents ?: return null
|
|
||||||
for (res in contents) {
|
for (res in contents) {
|
||||||
if (!findChapterFirstSource) {
|
if (!findChapterFirstSource) {
|
||||||
if (currentChapterFirstResourceHref != res.href) continue
|
if (currentChapterFirstResourceHref != res.href) continue
|
||||||
@@ -197,8 +196,6 @@ class EpubFile(var book: Book) {
|
|||||||
}
|
}
|
||||||
return HtmlFormatter.formatKeepImg(html)
|
return HtmlFormatter.formatKeepImg(html)
|
||||||
}
|
}
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getBody(res: Resource, startFragmentId: String?, endFragmentId: String?): Element {
|
private fun getBody(res: Resource, startFragmentId: String?, endFragmentId: String?): Element {
|
||||||
// Jsoup可能会修复不规范的xhtml文件 解析处理后再获取
|
// Jsoup可能会修复不规范的xhtml文件 解析处理后再获取
|
||||||
|
|||||||
Reference in New Issue
Block a user