|
|
@ -15,11 +15,14 @@ class ImportBookAdapter(context: Context, val callBack: CallBack) : |
|
|
|
SimpleRecyclerAdapter<DocItem>(context, R.layout.item_import_book) { |
|
|
|
SimpleRecyclerAdapter<DocItem>(context, R.layout.item_import_book) { |
|
|
|
var selectedUris = hashSetOf<String>() |
|
|
|
var selectedUris = hashSetOf<String>() |
|
|
|
var checkableCount = 0 |
|
|
|
var checkableCount = 0 |
|
|
|
private var bookPaths = arrayListOf<String>() |
|
|
|
private var bookFileNames = arrayListOf<String>() |
|
|
|
|
|
|
|
|
|
|
|
fun upBookHas(uriList: List<String>) { |
|
|
|
fun upBookHas(bookUrls: List<String>) { |
|
|
|
bookPaths.clear() |
|
|
|
bookFileNames.clear() |
|
|
|
bookPaths.addAll(uriList) |
|
|
|
bookUrls.forEach { |
|
|
|
|
|
|
|
val path = Uri.decode(it) |
|
|
|
|
|
|
|
bookFileNames.add(FileUtils.getName(path)) |
|
|
|
|
|
|
|
} |
|
|
|
notifyDataSetChanged() |
|
|
|
notifyDataSetChanged() |
|
|
|
upCheckableCount() |
|
|
|
upCheckableCount() |
|
|
|
} |
|
|
|
} |
|
|
@ -32,7 +35,7 @@ class ImportBookAdapter(context: Context, val callBack: CallBack) : |
|
|
|
private fun upCheckableCount() { |
|
|
|
private fun upCheckableCount() { |
|
|
|
checkableCount = 0 |
|
|
|
checkableCount = 0 |
|
|
|
getItems().forEach { |
|
|
|
getItems().forEach { |
|
|
|
if (!it.isDir && !bookPaths.contains(it.uri.toString())) { |
|
|
|
if (!it.isDir && !bookFileNames.contains(it.uri.toString())) { |
|
|
|
checkableCount++ |
|
|
|
checkableCount++ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -42,7 +45,7 @@ class ImportBookAdapter(context: Context, val callBack: CallBack) : |
|
|
|
fun selectAll(selectAll: Boolean) { |
|
|
|
fun selectAll(selectAll: Boolean) { |
|
|
|
if (selectAll) { |
|
|
|
if (selectAll) { |
|
|
|
getItems().forEach { |
|
|
|
getItems().forEach { |
|
|
|
if (!it.isDir && !bookPaths.contains(it.uri.toString())) { |
|
|
|
if (!it.isDir && !bookFileNames.contains(it.uri.toString())) { |
|
|
|
selectedUris.add(it.uri.toString()) |
|
|
|
selectedUris.add(it.uri.toString()) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -84,9 +87,7 @@ class ImportBookAdapter(context: Context, val callBack: CallBack) : |
|
|
|
ll_brief.gone() |
|
|
|
ll_brief.gone() |
|
|
|
cb_select.isChecked = false |
|
|
|
cb_select.isChecked = false |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
val path = |
|
|
|
if (bookFileNames.contains(item.name)) { |
|
|
|
if (item.uri.isContentScheme()) item.uri.toString() else item.uri.path |
|
|
|
|
|
|
|
if (bookPaths.contains(path)) { |
|
|
|
|
|
|
|
iv_icon.setImageResource(R.drawable.ic_book_has) |
|
|
|
iv_icon.setImageResource(R.drawable.ic_book_has) |
|
|
|
iv_icon.visible() |
|
|
|
iv_icon.visible() |
|
|
|
cb_select.invisible() |
|
|
|
cb_select.invisible() |
|
|
@ -112,7 +113,7 @@ class ImportBookAdapter(context: Context, val callBack: CallBack) : |
|
|
|
getItem(holder.layoutPosition)?.let { |
|
|
|
getItem(holder.layoutPosition)?.let { |
|
|
|
if (it.isDir) { |
|
|
|
if (it.isDir) { |
|
|
|
callBack.nextDoc(it.uri) |
|
|
|
callBack.nextDoc(it.uri) |
|
|
|
} else if (!bookPaths.contains(it.uri.toString())) { |
|
|
|
} else if (!bookFileNames.contains(it.uri.toString())) { |
|
|
|
if (!selectedUris.contains(it.uri.toString())) { |
|
|
|
if (!selectedUris.contains(it.uri.toString())) { |
|
|
|
selectedUris.add(it.uri.toString()) |
|
|
|
selectedUris.add(it.uri.toString()) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|