From eac9a7e5619a10263d63abb7651994c030bf63f3 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 15 Feb 2020 10:15:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/arrange/ArrangeBookAdapter.kt | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 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 67589e9ad..540084d8f 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 @@ -49,29 +49,40 @@ class ArrangeBookAdapter(context: Context, val callBack: CallBack) : } tv_author.text = getGroupName(item.group) checkbox.isChecked = selectedBooks.contains(item) - checkbox.onClick { - if (checkbox.isChecked) { - selectedBooks.add(item) - } else { - selectedBooks.remove(item) + checkbox.setOnCheckedChangeListener { buttonView, isChecked -> + getItem(holder.layoutPosition)?.let { + if (buttonView.isPressed) { + if (isChecked) { + selectedBooks.add(it) + } else { + selectedBooks.remove(it) + } + callBack.upSelectCount() + } + } - callBack.upSelectCount() } onClick { - checkbox.isChecked = !checkbox.isChecked - if (checkbox.isChecked) { - selectedBooks.add(item) - } else { - selectedBooks.remove(item) + getItem(holder.layoutPosition)?.let { + checkbox.isChecked = !checkbox.isChecked + if (checkbox.isChecked) { + selectedBooks.add(it) + } else { + selectedBooks.remove(it) + } + callBack.upSelectCount() } - callBack.upSelectCount() } tv_delete.onClick { - callBack.deleteBook(item) + getItem(holder.layoutPosition)?.let { + callBack.deleteBook(it) + } } tv_group.onClick { - actionItem = item - callBack.selectGroup(item.group, groupRequestCode) + getItem(holder.layoutPosition)?.let { + actionItem = it + callBack.selectGroup(it.group, groupRequestCode) + } } } }