From 46abd120cd8f8eade54b7b21a5bac7ebc9a0c544 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 31 Jan 2020 11:20:38 +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 --- .../io/legado/app/ui/importbook/ImportBookActivity.kt | 1 + .../java/io/legado/app/ui/importbook/ImportBookAdapter.kt | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/importbook/ImportBookActivity.kt b/app/src/main/java/io/legado/app/ui/importbook/ImportBookActivity.kt index 58c8aec0f..297715822 100644 --- a/app/src/main/java/io/legado/app/ui/importbook/ImportBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/importbook/ImportBookActivity.kt @@ -108,6 +108,7 @@ class ImportBookActivity : VMBaseActivity(R.layout.activity } docList.sortWith(compareBy({ !it.isDirectory }, { it.name })) tv_path.text = path + importBookAdapter.selectedUris.clear() importBookAdapter.setItems(docList) } } diff --git a/app/src/main/java/io/legado/app/ui/importbook/ImportBookAdapter.kt b/app/src/main/java/io/legado/app/ui/importbook/ImportBookAdapter.kt index 40cc5b8b5..5c80057d4 100644 --- a/app/src/main/java/io/legado/app/ui/importbook/ImportBookAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/importbook/ImportBookAdapter.kt @@ -17,7 +17,7 @@ import java.util.* class ImportBookAdapter(context: Context, val callBack: CallBack) : SimpleRecyclerAdapter(context, R.layout.item_import_book) { - + var selectedUris = linkedSetOf() private var localUri = arrayListOf() fun upBookHas(uriList: List) { @@ -48,12 +48,18 @@ class ImportBookAdapter(context: Context, val callBack: CallBack) : tv_date.text = AppConst.DATE_FORMAT.format(Date(item.lastModified())) } tv_name.text = item.name + cb_select.isChecked = selectedUris.contains(item.uri.toString()) onClick { item.name?.let { name -> if (item.isDirectory) { callBack.findFolder(name) } else { cb_select.isChecked = !cb_select.isChecked + if (cb_select.isChecked) { + selectedUris.add(item.uri.toString()) + } else { + selectedUris.remove(item.uri.toString()) + } } } }