pull/32/head
kunfei 5 years ago
parent b9aab12513
commit 39e3ffe5a3
  1. 1
      app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt
  2. 9
      app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleAdapter.kt

@ -102,7 +102,6 @@ class ReplaceRuleActivity : VMBaseActivity<ReplaceRuleViewModel>(R.layout.activi
} }
replaceRuleLiveData?.observe(this, Observer { replaceRuleLiveData?.observe(this, Observer {
val diffResult = DiffUtil.calculateDiff(DiffCallBack(adapter.getItems(), it)) val diffResult = DiffUtil.calculateDiff(DiffCallBack(adapter.getItems(), it))
adapter.selectedIds.clear()
adapter.setItemsNoNotify(it) adapter.setItemsNoNotify(it)
diffResult.dispatchUpdatesTo(adapter) diffResult.dispatchUpdatesTo(adapter)
}) })

@ -20,13 +20,10 @@ class ReplaceRuleAdapter(context: Context, var callBack: CallBack) :
val selectedIds = linkedSetOf<Long>() val selectedIds = linkedSetOf<Long>()
fun selectAll() { fun selectAll() {
if (selectedIds.size == itemCount) { getItems().forEach {
selectedIds.clear() selectedIds.add(it.id)
notifyItemRangeChanged(0, itemCount, 1)
} else {
getItems().forEach { selectedIds.add(it.id) }
notifyItemRangeChanged(0, itemCount, 1)
} }
notifyItemRangeChanged(0, itemCount, 1)
} }
fun revertSelection() { fun revertSelection() {

Loading…
Cancel
Save