diff --git a/app/src/main/java/io/legado/app/ui/book/local/rule/TxtTocRuleActivity.kt b/app/src/main/java/io/legado/app/ui/book/local/rule/TxtTocRuleActivity.kt index 8f450e770..c34fb8076 100644 --- a/app/src/main/java/io/legado/app/ui/book/local/rule/TxtTocRuleActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/local/rule/TxtTocRuleActivity.kt @@ -10,10 +10,16 @@ class TxtTocRuleActivity : VMBaseActivity(context) { + private val selected = linkedSetOf() + override fun getViewBinding(parent: ViewGroup): ItemTxtTocRuleBinding { return ItemTxtTocRuleBinding.inflate(inflater, parent, false) } @@ -25,7 +27,27 @@ class TxtTocRuleAdapter(context: Context) : } override fun registerListener(holder: ItemViewHolder, binding: ItemTxtTocRuleBinding) { - TODO("Not yet implemented") + binding.cbSource.setOnCheckedChangeListener { buttonView, isChecked -> + getItem(holder.layoutPosition)?.let { + if (buttonView.isPressed) { + if (isChecked) { + selected.add(it) + } else { + selected.remove(it) + } + } + } + } + binding.swtEnabled.setOnCheckedChangeListener { buttonView, isChecked -> + getItem(holder.layoutPosition)?.let { + if (buttonView.isPressed) { + it.enable = isChecked + } + } + } + binding.ivEdit.setOnClickListener { + + } } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt index bedde1b8f..f84f01229 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt @@ -110,26 +110,22 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : override fun registerListener(holder: ItemViewHolder, binding: ItemBookSourceBinding) { binding.apply { swtEnabled.setOnCheckedChangeListener { view, checked -> - if (view.isPressed) { - getItem(holder.layoutPosition)?.let { - if (view.isPressed) { - it.enabled = checked - callBack.update(it) - } + getItem(holder.layoutPosition)?.let { + if (view.isPressed) { + it.enabled = checked + callBack.update(it) } } } cbBookSource.setOnCheckedChangeListener { view, checked -> - if (view.isPressed) { - getItem(holder.layoutPosition)?.let { - if (view.isPressed) { - if (checked) { - selected.add(it) - } else { - selected.remove(it) - } - callBack.upCountView() + getItem(holder.layoutPosition)?.let { + if (view.isPressed) { + if (checked) { + selected.add(it) + } else { + selected.remove(it) } + callBack.upCountView() } } }