@Override public void onSelection(MaterialDialog materialDialog, View view, int i, CharSequence s) { if (canGoUp && i == 0) { parentFolder = parentFolder.getParentFile(); if (parentFolder.getAbsolutePath().equals("/storage/emulated")) parentFolder = parentFolder.getParentFile(); canGoUp = parentFolder.getParent() != null; } else { parentFolder = parentContents[canGoUp ? i - 1 : i]; canGoUp = true; if (parentFolder.getAbsolutePath().equals("/storage/emulated")) parentFolder = Environment.getExternalStorageDirectory(); } if (parentFolder.isFile()) { mCallback.onFileSelection(this, parentFolder); dismiss(); } else { parentContents = listFiles(getBuilder().mMimeType); MaterialDialog dialog = (MaterialDialog) getDialog(); dialog.setTitle(parentFolder.getAbsolutePath()); getArguments().putString("current_path", parentFolder.getAbsolutePath()); dialog.setItems(getContentsArray()); } }
@Override public void setEntries(CharSequence[] entries) { super.setEntries(entries); if (mDialog != null) mDialog.setItems(entries); }