优化
This commit is contained in:
@@ -53,9 +53,8 @@ class ChangeBookSourceAdapter(
|
||||
item: SearchBook,
|
||||
payloads: MutableList<Any>
|
||||
) {
|
||||
val bundle = payloads.getOrNull(0) as? Bundle
|
||||
binding.apply {
|
||||
if (bundle == null) {
|
||||
if (payloads.isEmpty()) {
|
||||
tvOrigin.text = item.originName
|
||||
tvAuthor.text = item.author
|
||||
tvLast.text = item.getDisplayLastChapterTitle()
|
||||
@@ -67,6 +66,8 @@ class ChangeBookSourceAdapter(
|
||||
ivChecked.invisible()
|
||||
}
|
||||
} else {
|
||||
for (i in payloads.indices) {
|
||||
val bundle = payloads[i] as Bundle
|
||||
bundle.keySet().map {
|
||||
when (it) {
|
||||
"name" -> tvOrigin.text = item.originName
|
||||
@@ -79,6 +80,7 @@ class ChangeBookSourceAdapter(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
val score = callBack.getBookScore(item)
|
||||
if (score > 0) {
|
||||
binding.ivBad.gone()
|
||||
|
||||
@@ -50,9 +50,8 @@ class ChangeChapterSourceAdapter(
|
||||
item: SearchBook,
|
||||
payloads: MutableList<Any>
|
||||
) {
|
||||
val bundle = payloads.getOrNull(0) as? Bundle
|
||||
binding.apply {
|
||||
if (bundle == null) {
|
||||
if (payloads.isEmpty()) {
|
||||
tvOrigin.text = item.originName
|
||||
tvAuthor.text = item.author
|
||||
tvLast.text = item.getDisplayLastChapterTitle()
|
||||
@@ -64,6 +63,8 @@ class ChangeChapterSourceAdapter(
|
||||
ivChecked.invisible()
|
||||
}
|
||||
} else {
|
||||
for (i in payloads.indices) {
|
||||
val bundle = payloads[i] as Bundle
|
||||
bundle.keySet().map {
|
||||
when (it) {
|
||||
"name" -> tvOrigin.text = item.originName
|
||||
@@ -76,6 +77,7 @@ class ChangeChapterSourceAdapter(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
val score = callBack.getBookScore(item)
|
||||
if (score > 0) {
|
||||
binding.ivBad.gone()
|
||||
|
||||
@@ -28,12 +28,14 @@ class ExploreShowAdapter(context: Context, val callBack: CallBack) :
|
||||
item: SearchBook,
|
||||
payloads: MutableList<Any>
|
||||
) {
|
||||
val bundle = payloads.getOrNull(0) as? Bundle
|
||||
if (bundle == null) {
|
||||
if (payloads.isEmpty()) {
|
||||
bind(binding, item)
|
||||
} else {
|
||||
for (i in payloads.indices) {
|
||||
val bundle = payloads[i] as Bundle
|
||||
bindChange(binding, item, bundle)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -59,13 +59,15 @@ class SearchAdapter(context: Context, val callBack: CallBack) :
|
||||
item: SearchBook,
|
||||
payloads: MutableList<Any>
|
||||
) {
|
||||
val bundle = payloads.getOrNull(0) as? Bundle
|
||||
if (bundle == null) {
|
||||
if (payloads.isEmpty()) {
|
||||
bind(binding, item)
|
||||
} else {
|
||||
for (i in payloads.indices) {
|
||||
val bundle = payloads[i] as Bundle
|
||||
bindChange(binding, item, bundle)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun registerListener(holder: ItemViewHolder, binding: ItemSearchBinding) {
|
||||
binding.root.setOnClickListener {
|
||||
|
||||
@@ -89,8 +89,7 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) :
|
||||
payloads: MutableList<Any>
|
||||
) {
|
||||
binding.run {
|
||||
val payload = payloads.getOrNull(0) as? Bundle
|
||||
if (payload == null) {
|
||||
if (payloads.isEmpty()) {
|
||||
root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f))
|
||||
cbBookSource.text = item.getDisPlayNameGroup()
|
||||
swtEnabled.isChecked = item.enabled
|
||||
@@ -98,9 +97,11 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) :
|
||||
upCheckSourceMessage(binding, item)
|
||||
upShowExplore(ivExplore, item)
|
||||
} else {
|
||||
payload.keySet().map {
|
||||
for (i in payloads.indices) {
|
||||
val bundle = payloads[i] as Bundle
|
||||
bundle.keySet().map {
|
||||
when (it) {
|
||||
"enabled" -> swtEnabled.isChecked = payload.getBoolean("enabled")
|
||||
"enabled" -> swtEnabled.isChecked = bundle.getBoolean("enabled")
|
||||
"upName" -> cbBookSource.text = item.getDisPlayNameGroup()
|
||||
"upExplore" -> upShowExplore(ivExplore, item)
|
||||
"selected" -> cbBookSource.isChecked = selected.contains(item)
|
||||
@@ -110,6 +111,7 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) :
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun registerListener(holder: ItemViewHolder, binding: ItemBookSourceBinding) {
|
||||
binding.apply {
|
||||
|
||||
@@ -77,14 +77,15 @@ class TxtTocRuleAdapter(context: Context, private val callBack: CallBack) :
|
||||
payloads: MutableList<Any>
|
||||
) {
|
||||
binding.run {
|
||||
val bundle = payloads.getOrNull(0) as? Bundle
|
||||
if (bundle == null) {
|
||||
if (payloads.isEmpty()) {
|
||||
root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f))
|
||||
cbSource.text = item.name
|
||||
swtEnabled.isChecked = item.enable
|
||||
cbSource.isChecked = selected.contains(item)
|
||||
titleExample.text = item.example
|
||||
} else {
|
||||
for (i in payloads.indices) {
|
||||
val bundle = payloads[i] as Bundle
|
||||
bundle.keySet().map {
|
||||
when (it) {
|
||||
"selected" -> cbSource.isChecked = selected.contains(item)
|
||||
@@ -96,6 +97,7 @@ class TxtTocRuleAdapter(context: Context, private val callBack: CallBack) :
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun registerListener(holder: ItemViewHolder, binding: ItemTxtTocRuleBinding) {
|
||||
binding.cbSource.setOnCheckedChangeListener { buttonView, isChecked ->
|
||||
|
||||
@@ -249,14 +249,15 @@ class TxtTocRuleDialog() : BaseDialogFragment(R.layout.dialog_toc_regex),
|
||||
payloads: MutableList<Any>
|
||||
) {
|
||||
binding.apply {
|
||||
val bundle = payloads.getOrNull(0) as? Bundle
|
||||
if (bundle == null) {
|
||||
if (payloads.isEmpty()) {
|
||||
root.setBackgroundColor(context.backgroundColor)
|
||||
rbRegexName.text = item.name
|
||||
titleExample.text = item.example
|
||||
rbRegexName.isChecked = item.name == selectedName
|
||||
swtEnabled.isChecked = item.enable
|
||||
} else {
|
||||
for (i in payloads.indices) {
|
||||
val bundle = payloads[i] as Bundle
|
||||
bundle.keySet().map {
|
||||
when (it) {
|
||||
"upName" -> rbRegexName.text = item.name
|
||||
@@ -268,6 +269,7 @@ class TxtTocRuleDialog() : BaseDialogFragment(R.layout.dialog_toc_regex),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun registerListener(holder: ItemViewHolder, binding: ItemTocRegexBinding) {
|
||||
binding.apply {
|
||||
|
||||
@@ -95,13 +95,14 @@ class DictRuleAdapter(context: Context, var callBack: CallBack) :
|
||||
payloads: MutableList<Any>
|
||||
) {
|
||||
binding.run {
|
||||
val bundle = payloads.getOrNull(0) as? Bundle
|
||||
if (bundle == null) {
|
||||
if (payloads.isEmpty()) {
|
||||
root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f))
|
||||
cbName.text = item.name
|
||||
swtEnabled.isChecked = item.enabled
|
||||
cbName.isChecked = selected.contains(item)
|
||||
} else {
|
||||
for (i in payloads.indices) {
|
||||
val bundle = payloads[i] as Bundle
|
||||
bundle.keySet().map {
|
||||
when (it) {
|
||||
"selected" -> cbName.isChecked = selected.contains(item)
|
||||
@@ -112,6 +113,7 @@ class DictRuleAdapter(context: Context, var callBack: CallBack) :
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun registerListener(holder: ItemViewHolder, binding: ItemDictRuleBinding) {
|
||||
binding.apply {
|
||||
|
||||
@@ -24,12 +24,13 @@ class BooksAdapterGrid(context: Context, private val callBack: CallBack) :
|
||||
item: Book,
|
||||
payloads: MutableList<Any>
|
||||
) = binding.run {
|
||||
val bundle = payloads.getOrNull(0) as? Bundle
|
||||
if (bundle == null) {
|
||||
if (payloads.isEmpty()) {
|
||||
tvName.text = item.name
|
||||
ivCover.load(item.getDisplayCover(), item.name, item.author, false, item.origin)
|
||||
upRefresh(binding, item)
|
||||
} else {
|
||||
for (i in payloads.indices) {
|
||||
val bundle = payloads[i] as Bundle
|
||||
bundle.keySet().forEach {
|
||||
when (it) {
|
||||
"name" -> tvName.text = item.name
|
||||
@@ -39,6 +40,7 @@ class BooksAdapterGrid(context: Context, private val callBack: CallBack) :
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun upRefresh(binding: ItemBookshelfGridBinding, item: Book) {
|
||||
if (!item.isLocal && callBack.isUpdate(item.bookUrl)) {
|
||||
|
||||
@@ -30,8 +30,7 @@ class BooksAdapterList(
|
||||
item: Book,
|
||||
payloads: MutableList<Any>
|
||||
) = binding.run {
|
||||
val bundle = payloads.getOrNull(0) as? Bundle
|
||||
if (bundle == null) {
|
||||
if (payloads.isEmpty()) {
|
||||
tvName.text = item.name
|
||||
tvAuthor.text = item.author
|
||||
tvRead.text = item.durChapterTitle
|
||||
@@ -40,6 +39,8 @@ class BooksAdapterList(
|
||||
upRefresh(binding, item)
|
||||
upLastUpdateTime(binding, item)
|
||||
} else {
|
||||
for (i in payloads.indices) {
|
||||
val bundle = payloads[i] as Bundle
|
||||
bundle.keySet().forEach {
|
||||
when (it) {
|
||||
"name" -> tvName.text = item.name
|
||||
@@ -61,6 +62,7 @@ class BooksAdapterList(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun upRefresh(binding: ItemBookshelfListBinding, item: Book) {
|
||||
if (!item.isLocal && callBack.isUpdate(item.bookUrl)) {
|
||||
|
||||
@@ -103,13 +103,14 @@ class ReplaceRuleAdapter(context: Context, var callBack: CallBack) :
|
||||
payloads: MutableList<Any>
|
||||
) {
|
||||
binding.run {
|
||||
val bundle = payloads.getOrNull(0) as? Bundle
|
||||
if (bundle == null) {
|
||||
if (payloads.isEmpty()) {
|
||||
root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f))
|
||||
cbName.text = item.getDisplayNameGroup()
|
||||
swtEnabled.isChecked = item.isEnabled
|
||||
cbName.isChecked = selected.contains(item)
|
||||
} else {
|
||||
for (i in payloads.indices) {
|
||||
val bundle = payloads[i] as Bundle
|
||||
bundle.keySet().map {
|
||||
when (it) {
|
||||
"selected" -> cbName.isChecked = selected.contains(item)
|
||||
@@ -120,6 +121,7 @@ class ReplaceRuleAdapter(context: Context, var callBack: CallBack) :
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun registerListener(holder: ItemViewHolder, binding: ItemReplaceRuleBinding) {
|
||||
binding.apply {
|
||||
|
||||
@@ -17,7 +17,7 @@ import io.legado.app.lib.theme.backgroundColor
|
||||
import io.legado.app.ui.widget.recycler.DragSelectTouchHelper
|
||||
import io.legado.app.ui.widget.recycler.ItemTouchCallback
|
||||
import io.legado.app.utils.ColorUtils
|
||||
import java.util.*
|
||||
import java.util.Collections
|
||||
|
||||
|
||||
class RssSourceAdapter(context: Context, val callBack: CallBack) :
|
||||
@@ -73,13 +73,14 @@ class RssSourceAdapter(context: Context, val callBack: CallBack) :
|
||||
payloads: MutableList<Any>
|
||||
) {
|
||||
binding.run {
|
||||
val bundle = payloads.getOrNull(0) as? Bundle
|
||||
if (bundle == null) {
|
||||
if (payloads.isEmpty()) {
|
||||
root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f))
|
||||
cbSource.text = item.getDisplayNameGroup()
|
||||
swtEnabled.isChecked = item.enabled
|
||||
cbSource.isChecked = selected.contains(item)
|
||||
} else {
|
||||
for (i in payloads.indices) {
|
||||
val bundle = payloads[i] as Bundle
|
||||
bundle.keySet().map {
|
||||
when (it) {
|
||||
"upName" -> cbSource.text = item.getDisplayNameGroup()
|
||||
@@ -90,6 +91,7 @@ class RssSourceAdapter(context: Context, val callBack: CallBack) :
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun registerListener(holder: ItemViewHolder, binding: ItemRssSourceBinding) {
|
||||
binding.apply {
|
||||
|
||||
Reference in New Issue
Block a user