优化
This commit is contained in:
@@ -53,9 +53,8 @@ class ChangeBookSourceAdapter(
|
|||||||
item: SearchBook,
|
item: SearchBook,
|
||||||
payloads: MutableList<Any>
|
payloads: MutableList<Any>
|
||||||
) {
|
) {
|
||||||
val bundle = payloads.getOrNull(0) as? Bundle
|
|
||||||
binding.apply {
|
binding.apply {
|
||||||
if (bundle == null) {
|
if (payloads.isEmpty()) {
|
||||||
tvOrigin.text = item.originName
|
tvOrigin.text = item.originName
|
||||||
tvAuthor.text = item.author
|
tvAuthor.text = item.author
|
||||||
tvLast.text = item.getDisplayLastChapterTitle()
|
tvLast.text = item.getDisplayLastChapterTitle()
|
||||||
@@ -67,14 +66,17 @@ class ChangeBookSourceAdapter(
|
|||||||
ivChecked.invisible()
|
ivChecked.invisible()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bundle.keySet().map {
|
for (i in payloads.indices) {
|
||||||
when (it) {
|
val bundle = payloads[i] as Bundle
|
||||||
"name" -> tvOrigin.text = item.originName
|
bundle.keySet().map {
|
||||||
"latest" -> tvLast.text = item.getDisplayLastChapterTitle()
|
when (it) {
|
||||||
"upCurSource" -> if (callBack.oldBookUrl == item.bookUrl) {
|
"name" -> tvOrigin.text = item.originName
|
||||||
ivChecked.visible()
|
"latest" -> tvLast.text = item.getDisplayLastChapterTitle()
|
||||||
} else {
|
"upCurSource" -> if (callBack.oldBookUrl == item.bookUrl) {
|
||||||
ivChecked.invisible()
|
ivChecked.visible()
|
||||||
|
} else {
|
||||||
|
ivChecked.invisible()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-10
@@ -50,9 +50,8 @@ class ChangeChapterSourceAdapter(
|
|||||||
item: SearchBook,
|
item: SearchBook,
|
||||||
payloads: MutableList<Any>
|
payloads: MutableList<Any>
|
||||||
) {
|
) {
|
||||||
val bundle = payloads.getOrNull(0) as? Bundle
|
|
||||||
binding.apply {
|
binding.apply {
|
||||||
if (bundle == null) {
|
if (payloads.isEmpty()) {
|
||||||
tvOrigin.text = item.originName
|
tvOrigin.text = item.originName
|
||||||
tvAuthor.text = item.author
|
tvAuthor.text = item.author
|
||||||
tvLast.text = item.getDisplayLastChapterTitle()
|
tvLast.text = item.getDisplayLastChapterTitle()
|
||||||
@@ -64,14 +63,17 @@ class ChangeChapterSourceAdapter(
|
|||||||
ivChecked.invisible()
|
ivChecked.invisible()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bundle.keySet().map {
|
for (i in payloads.indices) {
|
||||||
when (it) {
|
val bundle = payloads[i] as Bundle
|
||||||
"name" -> tvOrigin.text = item.originName
|
bundle.keySet().map {
|
||||||
"latest" -> tvLast.text = item.getDisplayLastChapterTitle()
|
when (it) {
|
||||||
"upCurSource" -> if (callBack.oldBookUrl == item.bookUrl) {
|
"name" -> tvOrigin.text = item.originName
|
||||||
ivChecked.visible()
|
"latest" -> tvLast.text = item.getDisplayLastChapterTitle()
|
||||||
} else {
|
"upCurSource" -> if (callBack.oldBookUrl == item.bookUrl) {
|
||||||
ivChecked.invisible()
|
ivChecked.visible()
|
||||||
|
} else {
|
||||||
|
ivChecked.invisible()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,11 +28,13 @@ class ExploreShowAdapter(context: Context, val callBack: CallBack) :
|
|||||||
item: SearchBook,
|
item: SearchBook,
|
||||||
payloads: MutableList<Any>
|
payloads: MutableList<Any>
|
||||||
) {
|
) {
|
||||||
val bundle = payloads.getOrNull(0) as? Bundle
|
if (payloads.isEmpty()) {
|
||||||
if (bundle == null) {
|
|
||||||
bind(binding, item)
|
bind(binding, item)
|
||||||
} else {
|
} else {
|
||||||
bindChange(binding, item, bundle)
|
for (i in payloads.indices) {
|
||||||
|
val bundle = payloads[i] as Bundle
|
||||||
|
bindChange(binding, item, bundle)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,11 +59,13 @@ class SearchAdapter(context: Context, val callBack: CallBack) :
|
|||||||
item: SearchBook,
|
item: SearchBook,
|
||||||
payloads: MutableList<Any>
|
payloads: MutableList<Any>
|
||||||
) {
|
) {
|
||||||
val bundle = payloads.getOrNull(0) as? Bundle
|
if (payloads.isEmpty()) {
|
||||||
if (bundle == null) {
|
|
||||||
bind(binding, item)
|
bind(binding, item)
|
||||||
} else {
|
} else {
|
||||||
bindChange(binding, item, bundle)
|
for (i in payloads.indices) {
|
||||||
|
val bundle = payloads[i] as Bundle
|
||||||
|
bindChange(binding, item, bundle)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,8 +89,7 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) :
|
|||||||
payloads: MutableList<Any>
|
payloads: MutableList<Any>
|
||||||
) {
|
) {
|
||||||
binding.run {
|
binding.run {
|
||||||
val payload = payloads.getOrNull(0) as? Bundle
|
if (payloads.isEmpty()) {
|
||||||
if (payload == null) {
|
|
||||||
root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f))
|
root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f))
|
||||||
cbBookSource.text = item.getDisPlayNameGroup()
|
cbBookSource.text = item.getDisPlayNameGroup()
|
||||||
swtEnabled.isChecked = item.enabled
|
swtEnabled.isChecked = item.enabled
|
||||||
@@ -98,13 +97,16 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) :
|
|||||||
upCheckSourceMessage(binding, item)
|
upCheckSourceMessage(binding, item)
|
||||||
upShowExplore(ivExplore, item)
|
upShowExplore(ivExplore, item)
|
||||||
} else {
|
} else {
|
||||||
payload.keySet().map {
|
for (i in payloads.indices) {
|
||||||
when (it) {
|
val bundle = payloads[i] as Bundle
|
||||||
"enabled" -> swtEnabled.isChecked = payload.getBoolean("enabled")
|
bundle.keySet().map {
|
||||||
"upName" -> cbBookSource.text = item.getDisPlayNameGroup()
|
when (it) {
|
||||||
"upExplore" -> upShowExplore(ivExplore, item)
|
"enabled" -> swtEnabled.isChecked = bundle.getBoolean("enabled")
|
||||||
"selected" -> cbBookSource.isChecked = selected.contains(item)
|
"upName" -> cbBookSource.text = item.getDisPlayNameGroup()
|
||||||
"checkSourceMessage" -> upCheckSourceMessage(binding, item)
|
"upExplore" -> upShowExplore(ivExplore, item)
|
||||||
|
"selected" -> cbBookSource.isChecked = selected.contains(item)
|
||||||
|
"checkSourceMessage" -> upCheckSourceMessage(binding, item)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,20 +77,22 @@ class TxtTocRuleAdapter(context: Context, private val callBack: CallBack) :
|
|||||||
payloads: MutableList<Any>
|
payloads: MutableList<Any>
|
||||||
) {
|
) {
|
||||||
binding.run {
|
binding.run {
|
||||||
val bundle = payloads.getOrNull(0) as? Bundle
|
if (payloads.isEmpty()) {
|
||||||
if (bundle == null) {
|
|
||||||
root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f))
|
root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f))
|
||||||
cbSource.text = item.name
|
cbSource.text = item.name
|
||||||
swtEnabled.isChecked = item.enable
|
swtEnabled.isChecked = item.enable
|
||||||
cbSource.isChecked = selected.contains(item)
|
cbSource.isChecked = selected.contains(item)
|
||||||
titleExample.text = item.example
|
titleExample.text = item.example
|
||||||
} else {
|
} else {
|
||||||
bundle.keySet().map {
|
for (i in payloads.indices) {
|
||||||
when (it) {
|
val bundle = payloads[i] as Bundle
|
||||||
"selected" -> cbSource.isChecked = selected.contains(item)
|
bundle.keySet().map {
|
||||||
"upName" -> cbSource.text = item.name
|
when (it) {
|
||||||
"upExample" -> titleExample.text = item.example
|
"selected" -> cbSource.isChecked = selected.contains(item)
|
||||||
"enabled" -> swtEnabled.isChecked = item.enable
|
"upName" -> cbSource.text = item.name
|
||||||
|
"upExample" -> titleExample.text = item.example
|
||||||
|
"enabled" -> swtEnabled.isChecked = item.enable
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -249,20 +249,22 @@ class TxtTocRuleDialog() : BaseDialogFragment(R.layout.dialog_toc_regex),
|
|||||||
payloads: MutableList<Any>
|
payloads: MutableList<Any>
|
||||||
) {
|
) {
|
||||||
binding.apply {
|
binding.apply {
|
||||||
val bundle = payloads.getOrNull(0) as? Bundle
|
if (payloads.isEmpty()) {
|
||||||
if (bundle == null) {
|
|
||||||
root.setBackgroundColor(context.backgroundColor)
|
root.setBackgroundColor(context.backgroundColor)
|
||||||
rbRegexName.text = item.name
|
rbRegexName.text = item.name
|
||||||
titleExample.text = item.example
|
titleExample.text = item.example
|
||||||
rbRegexName.isChecked = item.name == selectedName
|
rbRegexName.isChecked = item.name == selectedName
|
||||||
swtEnabled.isChecked = item.enable
|
swtEnabled.isChecked = item.enable
|
||||||
} else {
|
} else {
|
||||||
bundle.keySet().map {
|
for (i in payloads.indices) {
|
||||||
when (it) {
|
val bundle = payloads[i] as Bundle
|
||||||
"upName" -> rbRegexName.text = item.name
|
bundle.keySet().map {
|
||||||
"upExample" -> titleExample.text = item.example
|
when (it) {
|
||||||
"enabled" -> swtEnabled.isChecked = item.enable
|
"upName" -> rbRegexName.text = item.name
|
||||||
"upSelect" -> rbRegexName.isChecked = item.name == selectedName
|
"upExample" -> titleExample.text = item.example
|
||||||
|
"enabled" -> swtEnabled.isChecked = item.enable
|
||||||
|
"upSelect" -> rbRegexName.isChecked = item.name == selectedName
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,18 +95,20 @@ class DictRuleAdapter(context: Context, var callBack: CallBack) :
|
|||||||
payloads: MutableList<Any>
|
payloads: MutableList<Any>
|
||||||
) {
|
) {
|
||||||
binding.run {
|
binding.run {
|
||||||
val bundle = payloads.getOrNull(0) as? Bundle
|
if (payloads.isEmpty()) {
|
||||||
if (bundle == null) {
|
|
||||||
root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f))
|
root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f))
|
||||||
cbName.text = item.name
|
cbName.text = item.name
|
||||||
swtEnabled.isChecked = item.enabled
|
swtEnabled.isChecked = item.enabled
|
||||||
cbName.isChecked = selected.contains(item)
|
cbName.isChecked = selected.contains(item)
|
||||||
} else {
|
} else {
|
||||||
bundle.keySet().map {
|
for (i in payloads.indices) {
|
||||||
when (it) {
|
val bundle = payloads[i] as Bundle
|
||||||
"selected" -> cbName.isChecked = selected.contains(item)
|
bundle.keySet().map {
|
||||||
"upName" -> cbName.text = item.name
|
when (it) {
|
||||||
"enabled" -> swtEnabled.isChecked = item.enabled
|
"selected" -> cbName.isChecked = selected.contains(item)
|
||||||
|
"upName" -> cbName.text = item.name
|
||||||
|
"enabled" -> swtEnabled.isChecked = item.enabled
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,17 +24,19 @@ class BooksAdapterGrid(context: Context, private val callBack: CallBack) :
|
|||||||
item: Book,
|
item: Book,
|
||||||
payloads: MutableList<Any>
|
payloads: MutableList<Any>
|
||||||
) = binding.run {
|
) = binding.run {
|
||||||
val bundle = payloads.getOrNull(0) as? Bundle
|
if (payloads.isEmpty()) {
|
||||||
if (bundle == null) {
|
|
||||||
tvName.text = item.name
|
tvName.text = item.name
|
||||||
ivCover.load(item.getDisplayCover(), item.name, item.author, false, item.origin)
|
ivCover.load(item.getDisplayCover(), item.name, item.author, false, item.origin)
|
||||||
upRefresh(binding, item)
|
upRefresh(binding, item)
|
||||||
} else {
|
} else {
|
||||||
bundle.keySet().forEach {
|
for (i in payloads.indices) {
|
||||||
when (it) {
|
val bundle = payloads[i] as Bundle
|
||||||
"name" -> tvName.text = item.name
|
bundle.keySet().forEach {
|
||||||
"cover" -> ivCover.load(item.getDisplayCover(), item.name, item.author, false, item.origin)
|
when (it) {
|
||||||
"refresh" -> upRefresh(binding, item)
|
"name" -> tvName.text = item.name
|
||||||
|
"cover" -> ivCover.load(item.getDisplayCover(), item.name, item.author, false, item.origin)
|
||||||
|
"refresh" -> upRefresh(binding, item)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+20
-18
@@ -30,8 +30,7 @@ class BooksAdapterList(
|
|||||||
item: Book,
|
item: Book,
|
||||||
payloads: MutableList<Any>
|
payloads: MutableList<Any>
|
||||||
) = binding.run {
|
) = binding.run {
|
||||||
val bundle = payloads.getOrNull(0) as? Bundle
|
if (payloads.isEmpty()) {
|
||||||
if (bundle == null) {
|
|
||||||
tvName.text = item.name
|
tvName.text = item.name
|
||||||
tvAuthor.text = item.author
|
tvAuthor.text = item.author
|
||||||
tvRead.text = item.durChapterTitle
|
tvRead.text = item.durChapterTitle
|
||||||
@@ -40,23 +39,26 @@ class BooksAdapterList(
|
|||||||
upRefresh(binding, item)
|
upRefresh(binding, item)
|
||||||
upLastUpdateTime(binding, item)
|
upLastUpdateTime(binding, item)
|
||||||
} else {
|
} else {
|
||||||
bundle.keySet().forEach {
|
for (i in payloads.indices) {
|
||||||
when (it) {
|
val bundle = payloads[i] as Bundle
|
||||||
"name" -> tvName.text = item.name
|
bundle.keySet().forEach {
|
||||||
"author" -> tvAuthor.text = item.author
|
when (it) {
|
||||||
"dur" -> tvRead.text = item.durChapterTitle
|
"name" -> tvName.text = item.name
|
||||||
"last" -> tvLast.text = item.latestChapterTitle
|
"author" -> tvAuthor.text = item.author
|
||||||
"cover" -> ivCover.load(
|
"dur" -> tvRead.text = item.durChapterTitle
|
||||||
item.getDisplayCover(),
|
"last" -> tvLast.text = item.latestChapterTitle
|
||||||
item.name,
|
"cover" -> ivCover.load(
|
||||||
item.author,
|
item.getDisplayCover(),
|
||||||
false,
|
item.name,
|
||||||
item.origin,
|
item.author,
|
||||||
lifecycle
|
false,
|
||||||
)
|
item.origin,
|
||||||
|
lifecycle
|
||||||
|
)
|
||||||
|
|
||||||
"refresh" -> upRefresh(binding, item)
|
"refresh" -> upRefresh(binding, item)
|
||||||
"lastUpdateTime" -> upLastUpdateTime(binding, item)
|
"lastUpdateTime" -> upLastUpdateTime(binding, item)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,18 +103,20 @@ class ReplaceRuleAdapter(context: Context, var callBack: CallBack) :
|
|||||||
payloads: MutableList<Any>
|
payloads: MutableList<Any>
|
||||||
) {
|
) {
|
||||||
binding.run {
|
binding.run {
|
||||||
val bundle = payloads.getOrNull(0) as? Bundle
|
if (payloads.isEmpty()) {
|
||||||
if (bundle == null) {
|
|
||||||
root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f))
|
root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f))
|
||||||
cbName.text = item.getDisplayNameGroup()
|
cbName.text = item.getDisplayNameGroup()
|
||||||
swtEnabled.isChecked = item.isEnabled
|
swtEnabled.isChecked = item.isEnabled
|
||||||
cbName.isChecked = selected.contains(item)
|
cbName.isChecked = selected.contains(item)
|
||||||
} else {
|
} else {
|
||||||
bundle.keySet().map {
|
for (i in payloads.indices) {
|
||||||
when (it) {
|
val bundle = payloads[i] as Bundle
|
||||||
"selected" -> cbName.isChecked = selected.contains(item)
|
bundle.keySet().map {
|
||||||
"upName" -> cbName.text = item.getDisplayNameGroup()
|
when (it) {
|
||||||
"enabled" -> swtEnabled.isChecked = item.isEnabled
|
"selected" -> cbName.isChecked = selected.contains(item)
|
||||||
|
"upName" -> cbName.text = item.getDisplayNameGroup()
|
||||||
|
"enabled" -> swtEnabled.isChecked = item.isEnabled
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.DragSelectTouchHelper
|
||||||
import io.legado.app.ui.widget.recycler.ItemTouchCallback
|
import io.legado.app.ui.widget.recycler.ItemTouchCallback
|
||||||
import io.legado.app.utils.ColorUtils
|
import io.legado.app.utils.ColorUtils
|
||||||
import java.util.*
|
import java.util.Collections
|
||||||
|
|
||||||
|
|
||||||
class RssSourceAdapter(context: Context, val callBack: CallBack) :
|
class RssSourceAdapter(context: Context, val callBack: CallBack) :
|
||||||
@@ -73,18 +73,20 @@ class RssSourceAdapter(context: Context, val callBack: CallBack) :
|
|||||||
payloads: MutableList<Any>
|
payloads: MutableList<Any>
|
||||||
) {
|
) {
|
||||||
binding.run {
|
binding.run {
|
||||||
val bundle = payloads.getOrNull(0) as? Bundle
|
if (payloads.isEmpty()) {
|
||||||
if (bundle == null) {
|
|
||||||
root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f))
|
root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f))
|
||||||
cbSource.text = item.getDisplayNameGroup()
|
cbSource.text = item.getDisplayNameGroup()
|
||||||
swtEnabled.isChecked = item.enabled
|
swtEnabled.isChecked = item.enabled
|
||||||
cbSource.isChecked = selected.contains(item)
|
cbSource.isChecked = selected.contains(item)
|
||||||
} else {
|
} else {
|
||||||
bundle.keySet().map {
|
for (i in payloads.indices) {
|
||||||
when (it) {
|
val bundle = payloads[i] as Bundle
|
||||||
"upName" -> cbSource.text = item.getDisplayNameGroup()
|
bundle.keySet().map {
|
||||||
"enabled" -> swtEnabled.isChecked = bundle.getBoolean("enabled")
|
when (it) {
|
||||||
"selected" -> cbSource.isChecked = selected.contains(item)
|
"upName" -> cbSource.text = item.getDisplayNameGroup()
|
||||||
|
"enabled" -> swtEnabled.isChecked = bundle.getBoolean("enabled")
|
||||||
|
"selected" -> cbSource.isChecked = selected.contains(item)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user