mirror of
https://github.com/gedoor/legado.git
synced 2024-07-06 23:47:49 +08:00
优化
This commit is contained in:
parent
9e2dd726ac
commit
7f59d073cf
@ -176,18 +176,8 @@ class EpubFile(var book: Book) {
|
||||
}
|
||||
//title标签中的内容不需要显示在正文中,去除
|
||||
elements.select("title").remove()
|
||||
elements.select("img").forEach {
|
||||
val src = it.attr("src")
|
||||
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)
|
||||
elements.select("img[src=\"cover.jpeg\"]").forEachIndexed { i, it ->
|
||||
if (i > 0) it.remove()
|
||||
}
|
||||
val tag = Book.rubyTag
|
||||
if (book.getDelTag(tag)) {
|
||||
@ -253,12 +243,20 @@ class EpubFile(var book: Book) {
|
||||
//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
|
||||
}
|
||||
|
||||
private fun getImage(href: String): 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
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:padding="12dp"
|
||||
android:importantForAutofill="no"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tool_bar"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user