eltos / SimpleDialogFragments

An Android library to create dialogs with ease and handle user interaction reliably, using fragments and material design.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

File/Folder picker dialog

isabsent opened this issue · comments

I am going to create a simple file/folder chooser based on your library. For this purpose I would like to extending your SimpleListDialog and customize onItemClick :

import android.view.View;
import android.widget.AdapterView;

import eltos.simpledialogfragment.list.SimpleListDialog;

public class SimpleListDialogMod extends SimpleListDialog {

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        super.onItemClick(parent, view, position, id); 
        //Some custom code
    }
}

and use it as follows:

SimpleListDialogMod.build()
        .title(titleResId)
        .choiceMode(SimpleListDialog.SINGLE_CHOICE)
        .choiceMin(1)
        .items(itemNames)
        .extra(extras)
        .pos(R.string.button_deeper)
        .neg(R.string.button_up)
        .neut(R.string.button_pick)
        .show(this, PICK_DIALOG);

but onItemClick is never called when I press an item in the list! Why?

P.S. Would you be so kind to write your own SimplePickFileDialog? It is widely used and would be very useful as I suppose.

Given your code example, you are actually building a SimpleListDialog instead of a SimpleListDialogMod. Please have a look in the wiki here and my answer on the related issue #19.

In my opinion Androids Storage Access Framework provides a really good and advanced document picker, so I personally don't think it's worth the effort creating a SimplePickFileDialog. But feel free to create a pull request once you completed your work ;)

EDIT:
You might want to make use of the class CustomListDialog, which allows you to make more modifications (and would have thrown an exeption explaining the issue to you ;)).

Given your code example, you are actually building a SimpleListDialog instead of a SimpleListDialogMod.

You are right, thanks!

Android Storage Access Framework provides a really good and advanced document picker...

I can lost some details, but it seems Android Storage Access Framework does not have an opportunity to pickup a folder.

Please, give a hint - what is a simplest way to insert file or folder icon before each list item? Is it possible by extending a SimpleListDialog or it is necessary to extend CustomListDialog?

I can lost some details, but it seems Android Storage Access Framework does not have an opportunity to pickup a folder.

It does: Intent.ACTION_OPEN_DOCUMENT_TREE (API 21+ only though)

Please, give a hint - what is the simplest way to insert file or folder icon before each list item? Is it possible by extending a SimpleListDialog or it is necessary to extend CustomListDialog?

As said, I suggest to extend from CustomListDialog and write your own AdvancedAdapter implementation. The wiki and SimpleListDialog will give you some hints on how to do that.

It does: Intent.ACTION_OPEN_DOCUMENT_TREE (API 21+ only though)

Do you mean a DocumentFile.fromTreeUri() as a result of Android file picker? If yes, it is inacceptable when you need an access to the file with RandomAccessFile. It is impossible to get with Document File API unfortunately.

Enclosed zip-archive is a simplest realization of a File/Folder Chooser for internal phone memory (in SINGLE_CHOICE mode only) based on your library.

Enclosed zip-archive is a simplest realization of a File/Folder Chooser for internal phone memory (in SINGLE_CHOICE and MULTI_CHOICE modes) based on your library.

My implementation of FIle/Folder Picker Dialog based on your library.

Great work @isabsent, looks good :)
I'll add a link to your extension in the readme. Or do you want to create a pull request?

I have never made a pull request before and I am not sure my code is acceptable for you. I think it would be better if you take my code, change it and include it in your code in consistence with your approach to the library construction.