mirror of
https://github.com/gedoor/legado.git
synced 2024-08-30 09:23:26 +08:00
优化
This commit is contained in:
parent
416c5a852c
commit
071a348962
@ -14,6 +14,7 @@ import io.legado.app.base.adapter.ItemViewHolder
|
|||||||
import io.legado.app.data.entities.SearchBook
|
import io.legado.app.data.entities.SearchBook
|
||||||
import io.legado.app.databinding.ItemChangeSourceBinding
|
import io.legado.app.databinding.ItemChangeSourceBinding
|
||||||
import io.legado.app.help.config.AppConfig
|
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.getCompatColor
|
||||||
import io.legado.app.utils.gone
|
import io.legado.app.utils.gone
|
||||||
import io.legado.app.utils.invisible
|
import io.legado.app.utils.invisible
|
||||||
@ -82,8 +83,14 @@ class ChangeBookSourceAdapter(
|
|||||||
if (score > 0) {
|
if (score > 0) {
|
||||||
binding.ivBad.gone()
|
binding.ivBad.gone()
|
||||||
binding.ivGood.visible()
|
binding.ivGood.visible()
|
||||||
DrawableCompat.setTint(binding.ivGood.drawable, appCtx.getCompatColor(R.color.md_red_A200))
|
DrawableCompat.setTint(
|
||||||
DrawableCompat.setTint(binding.ivBad.drawable, appCtx.getCompatColor(R.color.md_blue_100))
|
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) {
|
} else if (score < 0) {
|
||||||
binding.ivGood.gone()
|
binding.ivGood.gone()
|
||||||
binding.ivBad.visible()
|
binding.ivBad.visible()
|
||||||
@ -125,13 +132,19 @@ class ChangeBookSourceAdapter(
|
|||||||
override fun registerListener(holder: ItemViewHolder, binding: ItemChangeSourceBinding) {
|
override fun registerListener(holder: ItemViewHolder, binding: ItemChangeSourceBinding) {
|
||||||
binding.ivGood.setOnClickListener {
|
binding.ivGood.setOnClickListener {
|
||||||
if (binding.ivBad.isVisible) {
|
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()
|
binding.ivBad.gone()
|
||||||
getItem(holder.layoutPosition)?.let {
|
getItem(holder.layoutPosition)?.let {
|
||||||
callBack.setBookScore(it, 1)
|
callBack.setBookScore(it, 1)
|
||||||
}
|
}
|
||||||
} else {
|
} 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()
|
binding.ivBad.visible()
|
||||||
getItem(holder.layoutPosition)?.let {
|
getItem(holder.layoutPosition)?.let {
|
||||||
callBack.setBookScore(it, 0)
|
callBack.setBookScore(it, 0)
|
||||||
@ -140,13 +153,19 @@ class ChangeBookSourceAdapter(
|
|||||||
}
|
}
|
||||||
binding.ivBad.setOnClickListener {
|
binding.ivBad.setOnClickListener {
|
||||||
if (binding.ivGood.isVisible) {
|
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()
|
binding.ivGood.gone()
|
||||||
getItem(holder.layoutPosition)?.let {
|
getItem(holder.layoutPosition)?.let {
|
||||||
callBack.setBookScore(it, -1)
|
callBack.setBookScore(it, -1)
|
||||||
}
|
}
|
||||||
} else {
|
} 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()
|
binding.ivGood.visible()
|
||||||
getItem(holder.layoutPosition)?.let {
|
getItem(holder.layoutPosition)?.let {
|
||||||
callBack.setBookScore(it, 0)
|
callBack.setBookScore(it, 0)
|
||||||
@ -174,18 +193,26 @@ class ChangeBookSourceAdapter(
|
|||||||
R.id.menu_top_source -> {
|
R.id.menu_top_source -> {
|
||||||
callBack.topSource(searchBook)
|
callBack.topSource(searchBook)
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.menu_bottom_source -> {
|
R.id.menu_bottom_source -> {
|
||||||
callBack.bottomSource(searchBook)
|
callBack.bottomSource(searchBook)
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.menu_edit_source -> {
|
R.id.menu_edit_source -> {
|
||||||
callBack.editSource(searchBook)
|
callBack.editSource(searchBook)
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.menu_disable_source -> {
|
R.id.menu_disable_source -> {
|
||||||
callBack.disableSource(searchBook)
|
callBack.disableSource(searchBook)
|
||||||
}
|
}
|
||||||
R.id.menu_delete_source -> {
|
|
||||||
callBack.deleteSource(searchBook)
|
R.id.menu_delete_source -> context.alert(R.string.draw) {
|
||||||
updateItems(0, itemCount, listOf<Int>())
|
setMessage(context.getString(R.string.sure_del) + "\n" + searchBook.originName)
|
||||||
|
noButton()
|
||||||
|
yesButton {
|
||||||
|
callBack.deleteSource(searchBook)
|
||||||
|
updateItems(0, itemCount, listOf<Int>())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
|
Loading…
Reference in New Issue
Block a user