优化
This commit is contained in:
@@ -176,18 +176,8 @@ class EpubFile(var book: Book) {
|
|||||||
}
|
}
|
||||||
//title标签中的内容不需要显示在正文中,去除
|
//title标签中的内容不需要显示在正文中,去除
|
||||||
elements.select("title").remove()
|
elements.select("title").remove()
|
||||||
elements.select("img").forEach {
|
elements.select("img[src=\"cover.jpeg\"]").forEachIndexed { i, it ->
|
||||||
val src = it.attr("src")
|
if (i > 0) it.remove()
|
||||||
if (src == "cover.jpeg") {
|
|
||||||
return@forEach
|
|
||||||
}
|
|
||||||
val path = chapter.url.substringBeforeLast("/", "")
|
|
||||||
val absSrc = if (path.isEmpty()) {
|
|
||||||
src
|
|
||||||
} else {
|
|
||||||
StringUtil.collapsePathDots("$path/$src")
|
|
||||||
}
|
|
||||||
it.attr("src", absSrc)
|
|
||||||
}
|
}
|
||||||
val tag = Book.rubyTag
|
val tag = Book.rubyTag
|
||||||
if (book.getDelTag(tag)) {
|
if (book.getDelTag(tag)) {
|
||||||
@@ -253,12 +243,20 @@ class EpubFile(var book: Book) {
|
|||||||
//getElementsMatchingOwnText(chapter.title)?.remove()
|
//getElementsMatchingOwnText(chapter.title)?.remove()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bodyElement.select("img").forEach {
|
||||||
|
val src = it.attr("src")
|
||||||
|
val path = res.href.substringBeforeLast("/", "")
|
||||||
|
if (path.isNotEmpty()) {
|
||||||
|
val absSrc = StringUtil.collapsePathDots("$path/$src")
|
||||||
|
it.attr("src", absSrc)
|
||||||
|
}
|
||||||
|
}
|
||||||
return bodyElement
|
return bodyElement
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getImage(href: String): InputStream? {
|
private fun getImage(href: String): InputStream? {
|
||||||
if (href == "cover.jpeg") return epubBook?.coverImage?.inputStream
|
if (href == "cover.jpeg") return epubBook?.coverImage?.inputStream
|
||||||
val abHref = URLDecoder.decode(href.replace("../", ""), "UTF-8")
|
val abHref = URLDecoder.decode(href, "UTF-8")
|
||||||
return epubBook?.resources?.getByHref(abHref)?.inputStream
|
return epubBook?.resources?.getByHref(abHref)?.inputStream
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:padding="12dp"
|
android:padding="12dp"
|
||||||
|
android:importantForAutofill="no"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/tool_bar"
|
app:layout_constraintTop_toBottomOf="@+id/tool_bar"
|
||||||
app:layout_constraintBottom_toBottomOf="parent" />
|
app:layout_constraintBottom_toBottomOf="parent" />
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user