android - How do I use a FilteredFilePickerFragment for NoNonsense-FilePicker? -


i've create file picker enable me select files of specific types such "pdf", "ppt", "odt" , more. created filteredfilepickerfragment given here. need use fragment don't know how.

here intent in mainactivity:

intent = new intent(intent.action_get_content);      // set these depending on use case. these defaults.     i.putextra(filepickeractivity.extra_allow_multiple, false);     i.putextra(filepickeractivity.extra_allow_create_dir, false);     i.putextra(filepickeractivity.extra_mode, filepickeractivity.mode_file);      // configure initial directory specifying string.     // specify string "/storage/emulated/0/", can     // dangerous. use android's api calls paths sd-card or     // internal memory.     i.putextra(filepickeractivity.extra_start_path, environment.getexternalstoragedirectory().getpath());      startactivityforresult(i, file_code); 

and here filtered fragment

    import android.support.annotation.nonnull;  import com.nononsenseapps.filepicker.filepickerfragment;  import java.io.file;  public class filteredfilepickerfragment extends filepickerfragment {      // file extension filter on     private static final string extension = ".pdf";      /**      *      * @param file      * @return file extension. if file has no extension, returns null.      */     private string getextension(@nonnull file file) {         string path = file.getpath();         int = path.lastindexof(".");         if (i < 0) {             return null;         } else {             return path.substring(i);         }     }      @override     protected boolean isitemvisible(final file file) {         if (mode == mode_file || mode == mode_file_and_dir) {             return extension.equalsignorecase(getextension(file));         }         return isdir(file);     } } 

basically activity in using intent shoould intent yo new activity (url:https://github.com/spacecowboy/nononsense-filepicker/blob/master/sample/src/main/java/com/nononsenseapps/filepicker/sample/imagepickeractivity.java)

the above intent creates fragment call abstractfilepickerfragment fragment = new imagepickerfragment();

imaqe picker fragment (https://github.com/spacecowboy/nononsense-filepicker/blob/master/sample/src/main/java/com/nononsenseapps/filepicker/sample/imagepickerfragment.java) class extends file picker fragment

that thats required shows extension files (may .doc,.docx, .pdf)


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -