[Android] Prevent NPE on crappy devices

Geoffrey Métais git at videolan.org
Wed Mar 18 10:36:13 CET 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Mar 18 10:25:35 2015 +0100| [380689a4c101ede695effe15f0338c4fb7eb99dd] | committer: Geoffrey Métais

Prevent NPE on crappy devices

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=380689a4c101ede695effe15f0338c4fb7eb99dd
---

 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java     |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 2ad63cc..b89a3b5 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -496,9 +496,10 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
 
     public boolean onPrepareOptionsMenu(Menu menu){
         MenuItem item = menu.findItem(R.id.pl_menu_nav);
-        item.setVisible(mLibVLC.getChapterCountForTitle(0) > 1 && mLibVLC.getTitleCount() > 1 && mLibVLC.getTitle() != 0);
-        MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
-
+        if (mLibVLC != null && item != null) {
+            item.setVisible(mLibVLC.getChapterCountForTitle(0) > 1 && mLibVLC.getTitleCount() > 1 && mLibVLC.getTitle() != 0);
+            MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
+        }
         return super.onPrepareOptionsMenu(menu);
     }
 



More information about the Android mailing list