Open sivansundar opened 4 years ago
Hi @sivansundar I'd run on 1.2.0
(it's our newest release) but the matter not seen.
I'm looking for more details...
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.
public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.ViewHolder>{
private ArrayList<FileList_AddFiles> mFileObject;
public FilesAdapter(ArrayList<FileList_AddFiles> mFileObject) {
this.mFileObject = mFileObject;
}
@NonNull
@Override
public FilesAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
.
.
.
.
.
}
@Override
public void onBindViewHolder(@NonNull FilesAdapter.ViewHolder holder, int position) {
FileList_AddFiles fileObject = mFileObject.get(position);
holder.setFileName(fileObject.getList_fileName());
}
@Override
public int getItemCount() {
int size = 0;
Log.d(TAG, "getItemCount: inside adapter : " + mFileObject.size());
if(mFileObject.size()>1) {
size = mFileObject.size()-1;
} return size;
}
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()
}
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?