[Android] Prevent NPE in menu preparation

Geoffrey Métais git at videolan.org
Tue Apr 3 10:19:56 CEST 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Apr  3 10:18:32 2018 +0200| [cb9cb1b3ba33cac869d7025a35d54973b0eed74a] | committer: Geoffrey Métais

Prevent NPE in menu preparation

> https://code.videolan.org/videolan/vlc-android/commit/cb9cb1b3ba33cac869d7025a35d54973b0eed74a
---

 vlc-android/src/org/videolan/vlc/gui/browser/SortableFragment.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/SortableFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/SortableFragment.java
index 0f4639bfc..a979b6251 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/SortableFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/SortableFragment.java
@@ -58,7 +58,8 @@ public abstract class SortableFragment<T extends SortableAdapter> extends MediaB
     @Override
     public void onPrepareOptionsMenu(Menu menu) {
         super.onPrepareOptionsMenu(menu);
-        menu.findItem(R.id.ml_menu_sortby).setVisible(isSortEnabled());
+        final MenuItem item = menu.findItem(R.id.ml_menu_sortby);
+        if (item != null) item.setVisible(isSortEnabled());
         UiTools.updateSortTitles(this, menu);
     }
 



More information about the Android mailing list