mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
This commit is contained in:
@@ -59,6 +59,14 @@ data class ReplaceRule(
|
||||
return id.hashCode()
|
||||
}
|
||||
|
||||
fun getDisplayNameGroup(): String {
|
||||
return if (group.isNullOrBlank()) {
|
||||
name
|
||||
} else {
|
||||
String.format("%s (%s)", name, group)
|
||||
}
|
||||
}
|
||||
|
||||
fun isValid(): Boolean {
|
||||
if (TextUtils.isEmpty(pattern)) {
|
||||
return false
|
||||
|
||||
@@ -57,11 +57,10 @@ class ReplaceRuleAdapter(context: Context, var callBack: CallBack) :
|
||||
|
||||
override fun getChangePayload(oldItem: ReplaceRule, newItem: ReplaceRule): Any? {
|
||||
val payload = Bundle()
|
||||
if (oldItem.name != newItem.name) {
|
||||
payload.putString("name", newItem.name)
|
||||
}
|
||||
if (oldItem.group != newItem.group) {
|
||||
payload.putString("group", newItem.group)
|
||||
if (oldItem.name != newItem.name
|
||||
|| oldItem.group != newItem.group
|
||||
) {
|
||||
payload.putBoolean("upName", true)
|
||||
}
|
||||
if (oldItem.isEnabled != newItem.isEnabled) {
|
||||
payload.putBoolean("enabled", newItem.isEnabled)
|
||||
@@ -111,25 +110,14 @@ class ReplaceRuleAdapter(context: Context, var callBack: CallBack) :
|
||||
val bundle = payloads.getOrNull(0) as? Bundle
|
||||
if (bundle == null) {
|
||||
root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f))
|
||||
if (item.group.isNullOrEmpty()) {
|
||||
cbName.text = item.name
|
||||
} else {
|
||||
cbName.text =
|
||||
String.format("%s (%s)", item.name, item.group)
|
||||
}
|
||||
cbName.text = item.getDisplayNameGroup()
|
||||
swtEnabled.isChecked = item.isEnabled
|
||||
cbName.isChecked = selected.contains(item)
|
||||
} else {
|
||||
bundle.keySet().map {
|
||||
when (it) {
|
||||
"selected" -> cbName.isChecked = selected.contains(item)
|
||||
"name", "group" ->
|
||||
if (item.group.isNullOrEmpty()) {
|
||||
cbName.text = item.name
|
||||
} else {
|
||||
cbName.text =
|
||||
String.format("%s (%s)", item.name, item.group)
|
||||
}
|
||||
"upName" -> cbName.text = item.getDisplayNameGroup()
|
||||
"enabled" -> swtEnabled.isChecked = item.isEnabled
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user