[Android] Prevent NPE in browsers context menu
Geoffrey Métais
git at videolan.org
Wed Nov 29 09:40:36 CET 2017
vlc-android | branch: 2.5.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Nov 27 15:21:54 2017 +0100| [98abc923d4e41333e0f2bc832a01131c231b53e0] | committer: Geoffrey Métais
Prevent NPE in browsers context menu
(cherry picked from commit 39b6afc333b84f75dc358f152f71b8d125167bd8)
> https://code.videolan.org/videolan/vlc-android/commit/98abc923d4e41333e0f2bc832a01131c231b53e0
---
vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java | 2 ++
1 file changed, 2 insertions(+)
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
index 5aee19028..fe76e0a2f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
@@ -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) {
More information about the Android
mailing list