From f125aa8bc3e90ecba40ddc34b9cb3d65d6207891 Mon Sep 17 00:00:00 2001 From: gedoor Date: Mon, 15 Nov 2021 23:15:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/book/local/rule/TxtTocRuleActivity.kt | 6 +++++ .../ui/book/local/rule/TxtTocRuleAdapter.kt | 24 ++++++++++++++++- .../book/source/manage/BookSourceAdapter.kt | 26 ++++++++----------- 3 files changed, 40 insertions(+), 16 deletions(-) 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() } } }