From c1ae91d34aa9b3d4ffd42a7988e59f57b3ac219d Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 3 Nov 2020 19:50:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B7=BB=E5=8A=A0=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0,=E4=B8=8D=E6=98=BE=E7=A4=BA=E4=BB=A5=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E4=B9=A6=E7=B1=8D=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/local/ImportBookAdapter.kt | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/local/ImportBookAdapter.kt b/app/src/main/java/io/legado/app/ui/book/local/ImportBookAdapter.kt index 0a83e9641..1874d3c58 100644 --- a/app/src/main/java/io/legado/app/ui/book/local/ImportBookAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/local/ImportBookAdapter.kt @@ -15,11 +15,14 @@ class ImportBookAdapter(context: Context, val callBack: CallBack) : SimpleRecyclerAdapter(context, R.layout.item_import_book) { var selectedUris = hashSetOf() var checkableCount = 0 - private var bookPaths = arrayListOf() + private var bookFileNames = arrayListOf() - fun upBookHas(uriList: List) { - bookPaths.clear() - bookPaths.addAll(uriList) + fun upBookHas(bookUrls: List) { + bookFileNames.clear() + bookUrls.forEach { + val path = Uri.decode(it) + bookFileNames.add(FileUtils.getName(path)) + } notifyDataSetChanged() upCheckableCount() } @@ -32,7 +35,7 @@ class ImportBookAdapter(context: Context, val callBack: CallBack) : private fun upCheckableCount() { checkableCount = 0 getItems().forEach { - if (!it.isDir && !bookPaths.contains(it.uri.toString())) { + if (!it.isDir && !bookFileNames.contains(it.uri.toString())) { checkableCount++ } } @@ -42,7 +45,7 @@ class ImportBookAdapter(context: Context, val callBack: CallBack) : fun selectAll(selectAll: Boolean) { if (selectAll) { getItems().forEach { - if (!it.isDir && !bookPaths.contains(it.uri.toString())) { + if (!it.isDir && !bookFileNames.contains(it.uri.toString())) { selectedUris.add(it.uri.toString()) } } @@ -84,9 +87,7 @@ class ImportBookAdapter(context: Context, val callBack: CallBack) : ll_brief.gone() cb_select.isChecked = false } else { - val path = - if (item.uri.isContentScheme()) item.uri.toString() else item.uri.path - if (bookPaths.contains(path)) { + if (bookFileNames.contains(item.name)) { iv_icon.setImageResource(R.drawable.ic_book_has) iv_icon.visible() cb_select.invisible() @@ -112,7 +113,7 @@ class ImportBookAdapter(context: Context, val callBack: CallBack) : getItem(holder.layoutPosition)?.let { if (it.isDir) { callBack.nextDoc(it.uri) - } else if (!bookPaths.contains(it.uri.toString())) { + } else if (!bookFileNames.contains(it.uri.toString())) { if (!selectedUris.contains(it.uri.toString())) { selectedUris.add(it.uri.toString()) } else {