From 7aa72733bd020374c831227e6fbff349cc002d69 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 16 Dec 2020 17:33:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/arrange/ArrangeBookAdapter.kt | 17 ++++++------ .../app/ui/book/group/GroupSelectDialog.kt | 4 +-- .../book/source/manage/BookSourceAdapter.kt | 26 +++++++++++-------- .../ui/rss/source/manage/RssSourceAdapter.kt | 26 +++++++++++-------- 4 files changed, 41 insertions(+), 32 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookAdapter.kt b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookAdapter.kt index 3e7d25318..730e63822 100644 --- a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookAdapter.kt @@ -52,16 +52,17 @@ class ArrangeBookAdapter(context: Context, val callBack: CallBack) : override fun registerListener(holder: ItemViewHolder, binding: ItemArrangeBookBinding) { binding.apply { checkbox.setOnCheckedChangeListener { buttonView, isChecked -> - getItem(holder.layoutPosition)?.let { - if (buttonView.isPressed) { - if (isChecked) { - selectedBooks.add(it) - } else { - selectedBooks.remove(it) + if (buttonView.isPressed) { + getItem(holder.layoutPosition)?.let { + if (buttonView.isPressed) { + if (isChecked) { + selectedBooks.add(it) + } else { + selectedBooks.remove(it) + } + callBack.upSelectCount() } - callBack.upSelectCount() } - } } root.onClick { diff --git a/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt b/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt index a6908e354..3a02b4757 100644 --- a/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt @@ -177,8 +177,8 @@ class GroupSelectDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener override fun registerListener(holder: ItemViewHolder, binding: ItemGroupSelectBinding) { with(binding) { cbGroup.setOnCheckedChangeListener { buttonView, isChecked -> - getItem(holder.layoutPosition)?.let { - if (buttonView.isPressed) { + if (buttonView.isPressed) { + getItem(holder.layoutPosition)?.let { groupId = if (isChecked) { groupId + it.groupId } else { 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 2e65d5a5f..9d37f7776 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 @@ -117,22 +117,26 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : override fun registerListener(holder: ItemViewHolder, binding: ItemBookSourceBinding) { binding.apply { swtEnabled.setOnCheckedChangeListener { view, checked -> - getItem(holder.layoutPosition)?.let { - if (view.isPressed) { - it.enabled = checked - callBack.update(it) + if (view.isPressed) { + getItem(holder.layoutPosition)?.let { + if (view.isPressed) { + it.enabled = checked + callBack.update(it) + } } } } cbBookSource.setOnCheckedChangeListener { view, checked -> - getItem(holder.layoutPosition)?.let { - if (view.isPressed) { - if (checked) { - selected.add(it) - } else { - selected.remove(it) + if (view.isPressed) { + getItem(holder.layoutPosition)?.let { + if (view.isPressed) { + if (checked) { + selected.add(it) + } else { + selected.remove(it) + } + callBack.upCountView() } - callBack.upCountView() } } } diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt index 63733f70c..96f4be01f 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt @@ -98,22 +98,26 @@ class RssSourceAdapter(context: Context, val callBack: CallBack) : override fun registerListener(holder: ItemViewHolder, binding: ItemRssSourceBinding) { binding.apply { swtEnabled.setOnCheckedChangeListener { view, checked -> - getItem(holder.layoutPosition)?.let { - if (view.isPressed) { - it.enabled = checked - callBack.update(it) + if (view.isPressed) { + getItem(holder.layoutPosition)?.let { + if (view.isPressed) { + it.enabled = checked + callBack.update(it) + } } } } cbSource.setOnCheckedChangeListener { view, checked -> - getItem(holder.layoutPosition)?.let { - if (view.isPressed) { - if (checked) { - selected.add(it) - } else { - selected.remove(it) + if (view.isPressed) { + getItem(holder.layoutPosition)?.let { + if (view.isPressed) { + if (checked) { + selected.add(it) + } else { + selected.remove(it) + } + callBack.upCountView() } - callBack.upCountView() } } }