Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -134,16 +134,6 @@ class EpubFile(var book: Book) {
|
||||
}
|
||||
|
||||
private fun getContent(chapter: BookChapter): String? {
|
||||
/**
|
||||
* <image width="1038" height="670" xlink:href="..."/>
|
||||
* ...titlepage.xhtml
|
||||
* 大多数epub文件的封面页都会带有cover,可以一定程度上解决封面读取问题
|
||||
*/
|
||||
if (chapter.url.contains("titlepage.xhtml") ||
|
||||
chapter.url.contains("cover")
|
||||
) {
|
||||
return "<img src=\"cover.jpeg\" />"
|
||||
}
|
||||
/*获取当前章节文本*/
|
||||
val contents = epubBookContents ?: return null
|
||||
val nextChapterFirstResourceHref = chapter.getVariable("nextUrl").substringBeforeLast("#")
|
||||
@@ -201,6 +191,17 @@ class EpubFile(var book: Book) {
|
||||
}
|
||||
|
||||
private fun getBody(res: Resource, startFragmentId: String?, endFragmentId: String?): Element {
|
||||
/**
|
||||
* <image width="1038" height="670" xlink:href="..."/>
|
||||
* ...titlepage.xhtml
|
||||
* 大多数epub文件的封面页都会带有cover,可以一定程度上解决封面读取问题
|
||||
*/
|
||||
if (res.href.contains("titlepage.xhtml") ||
|
||||
res.href.contains("cover")
|
||||
) {
|
||||
return Jsoup.parseBodyFragment("<img src=\"cover.jpeg\" />")
|
||||
}
|
||||
|
||||
// Jsoup可能会修复不规范的xhtml文件 解析处理后再获取
|
||||
var bodyElement = Jsoup.parse(String(res.data, mCharset)).body()
|
||||
bodyElement.children().run {
|
||||
|
||||
@@ -14,6 +14,7 @@ import io.legado.app.base.adapter.ItemViewHolder
|
||||
import io.legado.app.data.entities.SearchBook
|
||||
import io.legado.app.databinding.ItemChangeSourceBinding
|
||||
import io.legado.app.help.config.AppConfig
|
||||
import io.legado.app.lib.dialogs.alert
|
||||
import io.legado.app.utils.getCompatColor
|
||||
import io.legado.app.utils.gone
|
||||
import io.legado.app.utils.invisible
|
||||
@@ -82,8 +83,14 @@ class ChangeBookSourceAdapter(
|
||||
if (score > 0) {
|
||||
binding.ivBad.gone()
|
||||
binding.ivGood.visible()
|
||||
DrawableCompat.setTint(binding.ivGood.drawable, appCtx.getCompatColor(R.color.md_red_A200))
|
||||
DrawableCompat.setTint(binding.ivBad.drawable, appCtx.getCompatColor(R.color.md_blue_100))
|
||||
DrawableCompat.setTint(
|
||||
binding.ivGood.drawable,
|
||||
appCtx.getCompatColor(R.color.md_red_A200)
|
||||
)
|
||||
DrawableCompat.setTint(
|
||||
binding.ivBad.drawable,
|
||||
appCtx.getCompatColor(R.color.md_blue_100)
|
||||
)
|
||||
} else if (score < 0) {
|
||||
binding.ivGood.gone()
|
||||
binding.ivBad.visible()
|
||||
@@ -125,13 +132,19 @@ class ChangeBookSourceAdapter(
|
||||
override fun registerListener(holder: ItemViewHolder, binding: ItemChangeSourceBinding) {
|
||||
binding.ivGood.setOnClickListener {
|
||||
if (binding.ivBad.isVisible) {
|
||||
DrawableCompat.setTint(binding.ivGood.drawable, appCtx.getCompatColor(R.color.md_red_A200))
|
||||
DrawableCompat.setTint(
|
||||
binding.ivGood.drawable,
|
||||
appCtx.getCompatColor(R.color.md_red_A200)
|
||||
)
|
||||
binding.ivBad.gone()
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
callBack.setBookScore(it, 1)
|
||||
}
|
||||
} else {
|
||||
DrawableCompat.setTint(binding.ivGood.drawable, appCtx.getCompatColor(R.color.md_red_100))
|
||||
DrawableCompat.setTint(
|
||||
binding.ivGood.drawable,
|
||||
appCtx.getCompatColor(R.color.md_red_100)
|
||||
)
|
||||
binding.ivBad.visible()
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
callBack.setBookScore(it, 0)
|
||||
@@ -140,13 +153,19 @@ class ChangeBookSourceAdapter(
|
||||
}
|
||||
binding.ivBad.setOnClickListener {
|
||||
if (binding.ivGood.isVisible) {
|
||||
DrawableCompat.setTint(binding.ivBad.drawable, appCtx.getCompatColor(R.color.md_blue_A200))
|
||||
DrawableCompat.setTint(
|
||||
binding.ivBad.drawable,
|
||||
appCtx.getCompatColor(R.color.md_blue_A200)
|
||||
)
|
||||
binding.ivGood.gone()
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
callBack.setBookScore(it, -1)
|
||||
}
|
||||
} else {
|
||||
DrawableCompat.setTint(binding.ivBad.drawable, appCtx.getCompatColor(R.color.md_blue_100))
|
||||
DrawableCompat.setTint(
|
||||
binding.ivBad.drawable,
|
||||
appCtx.getCompatColor(R.color.md_blue_100)
|
||||
)
|
||||
binding.ivGood.visible()
|
||||
getItem(holder.layoutPosition)?.let {
|
||||
callBack.setBookScore(it, 0)
|
||||
@@ -174,18 +193,26 @@ class ChangeBookSourceAdapter(
|
||||
R.id.menu_top_source -> {
|
||||
callBack.topSource(searchBook)
|
||||
}
|
||||
|
||||
R.id.menu_bottom_source -> {
|
||||
callBack.bottomSource(searchBook)
|
||||
}
|
||||
|
||||
R.id.menu_edit_source -> {
|
||||
callBack.editSource(searchBook)
|
||||
}
|
||||
|
||||
R.id.menu_disable_source -> {
|
||||
callBack.disableSource(searchBook)
|
||||
}
|
||||
R.id.menu_delete_source -> {
|
||||
callBack.deleteSource(searchBook)
|
||||
updateItems(0, itemCount, listOf<Int>())
|
||||
|
||||
R.id.menu_delete_source -> context.alert(R.string.draw) {
|
||||
setMessage(context.getString(R.string.sure_del) + "\n" + searchBook.originName)
|
||||
noButton()
|
||||
yesButton {
|
||||
callBack.deleteSource(searchBook)
|
||||
updateItems(0, itemCount, listOf<Int>())
|
||||
}
|
||||
}
|
||||
}
|
||||
true
|
||||
|
||||
Reference in New Issue
Block a user