This repository has been archived by the owner on Jul 23, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 62
Folder added as an item while selecting multiple files #81
Comments
Hi @sivansundar I'd run on Tested:
|
The problem still persists. I've chosen multiple files from a folder but the folder also gets added as an item. As a temporary fix, I've decremented the size of the ArrayList object by 1 in the adapter class.
|
So where the data are coming from, in your mFileObject, I'm expecting what content are saying in chooserDialog.withChosenListener() & withDismissListener()... Here is an clean multi-select afc picker: object Demo {
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
fun demo2(context: Context, startPath: String, callback: ((paths: ArrayList<String>) -> Unit)? = null) {
val files = ArrayList<File>()
val dlg = ChooserDialog(context)
dlg.displayPath(true)
.withFilter(false, true, "jpg", "jpeg", "png")
.withStartFile(startPath)
.enableOptions(true)
.enableMultiple(true)
.withResources(R.string.title_choose_file, R.string.title_choose, R.string.dialog_cancel)
.withOptionResources(R.string.option_create_folder, R.string.options_delete, R.string.new_folder_cancel, R.string.new_folder_ok)
.withChosenListener { dir, dirFile ->
if (dirFile.isDirectory) {
dlg.dismiss()
} else if (!files.remove(dirFile)) {
files.add(dirFile)
}
}
.withOnDismissListener {
val paths = ArrayList<String>()
if (files.isNotEmpty()) {
for (file in files) {
paths.add(file.absolutePath)
}
}
callback?.invoke(paths)
}
.withDateFormat("dd MMMM yyyy")
.build()
.show()
}
} And, use it: Demo.demo2(ctx, "") { paths ->
val builder = AlertDialog.Builder(ctx, R.style.FileChooserDialogStyle)
builder.setTitle("${paths.size} files selected:")
.setAdapter(ArrayAdapter(ctx, android.R.layout.simple_expandable_list_item_1, paths), null)
.create()
.show()
} |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi.
While adding multiple files to an array adapter which populates a recycler view, the folder also gets added as an item.
Example :
Twitter is the folder in which the image file is located.
Is there a fix to this?
The text was updated successfully, but these errors were encountered: