[Android] Prevent NPE in menu preparation

Geoffrey Métais git at videolan.org
Wed Apr 4 11:27:31 CEST 2018


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

Prevent NPE in menu preparation

(cherry picked from commit cb9cb1b3ba33cac869d7025a35d54973b0eed74a)

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

 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