Skip to content
Snippets Groups Projects
Commit 98abc923 authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Prevent NPE in browsers context menu

(cherry picked from commit 39b6afc3)
parent 08c7facd
No related branches found
No related tags found
No related merge requests found
......@@ -503,6 +503,7 @@ public abstract class BaseBrowserFragment extends SortableFragment<BaseBrowserAd
@Override
protected void inflate(Menu menu, int position) {
MediaWrapper mw = (MediaWrapper) mAdapter.getItem(position);
if (mw == null) return;
int type = mw.getType();
MenuInflater inflater = getActivity().getMenuInflater();
inflater.inflate(type == MediaWrapper.TYPE_DIR ? R.menu.directory_view_dir : R.menu.directory_view_file, menu);
......@@ -510,6 +511,7 @@ public abstract class BaseBrowserFragment extends SortableFragment<BaseBrowserAd
protected void setContextMenuItems(Menu menu, int position) {
final MediaWrapper mw = (MediaWrapper) mAdapter.getItem(position);
if (mw == null) return;
final int type = mw.getType();
boolean canWrite = this instanceof FileBrowserFragment && FileUtils.canWrite(mw.getUri().getPath());
if (type == MediaWrapper.TYPE_DIR) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment