com.nbsp.materialfilepicker.MaterialFilePicker Java Examples

The following examples show how to use com.nbsp.materialfilepicker.MaterialFilePicker. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RNFileSelectorModule.java    From react-native-file-selector with Apache License 2.0 5 votes vote down vote up
private void openFilePicker(final ReadableMap props, final Callback onDone, final Callback onCancel) {
  MaterialFilePicker picker = new MaterialFilePicker();
  picker = picker.withActivity(getCurrentActivity());
  picker = picker.withRequestCode(1);

  String filter = props.getString("filter");
  boolean filterDirectories = props.getBoolean("filterDirectories");
  String path = props.getString("path");
  boolean hiddenFiles = props.getBoolean("hiddenFiles");
  boolean closeMenu = props.getBoolean("closeMenu");
  String title = props.getString("title");

  if (filter.length() > 0) {
    picker = picker.withFilter(Pattern.compile(filter));
  }

  picker = picker.withFilterDirectories(filterDirectories);

  if (path.length() > 0) {
    picker = picker.withRootPath(path);
  }

  picker = picker.withHiddenFiles(hiddenFiles);
  picker = picker.withCloseMenu(closeMenu);

  picker = picker.withTitle(title);

  this.onDone = onDone;
  this.onCancel = onCancel;

  picker.start();
}
 
Example #2
Source File: FileActivity.java    From bridgefy-android-samples with MIT License 5 votes vote down vote up
@OnClick({R.id.fab})
public void onMessageSend(View v) {


    new MaterialFilePicker()
            .withActivity(this)
            .withRequestCode(1987)
            .withHiddenFiles(true) // Show hidden files and folders
            .start();

}
 
Example #3
Source File: BackupRestoreDelegate.java    From android-notepad with MIT License 5 votes vote down vote up
public void startFilePickerIntent(){
	Toast.makeText(activity, "Select a restore file with .nbu extension", Toast.LENGTH_LONG).show();
	new MaterialFilePicker()
			.withActivity(activity)
			.withRequestCode(PICK_RESTORE_FILE_REQUEST_CODE)
			.withFilter(Pattern.compile(".*\\.nbu$")) // Filtering files and directories by file name using regexp
			.withFilterDirectories(false) // Set directories filterable (false by default)
			.withHiddenFiles(false) // Show hidden files and folders
			.start();
}
 
Example #4
Source File: FilePickerProxy.java    From friendly-plans with GNU General Public License v3.0 5 votes vote down vote up
public void openFilePicker(Fragment fragment, AssetType assetType) {
    if (ContextCompat.checkSelfPermission(fragment.getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE)
            != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(fragment.getActivity(),
                    new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
                    1);
    } else {
        new MaterialFilePicker()
                .withFragment(fragment)
                .withRequestCode(getRequestCode(assetType))
                .withFilter(getPattern(assetType))
                .start();
    }
}