[Android] Prevent NPE

Geoffrey Métais git at videolan.org
Tue Mar 3 10:41:37 CET 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Mar  3 10:30:42 2015 +0100| [7fe5ed19547a2c138fdcd1daea5a76af03812164] | committer: Geoffrey Métais

Prevent NPE

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

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

diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index 0c1b22c..e1cbd3e 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -398,10 +398,11 @@ public class MainActivity extends ActionBarActivity implements OnItemClickListen
 
     @Override
     public void onBackPressed() {
-        if(mRootContainer.isDrawerOpen(mSideMenu)) {
             /* Close the menu first */
-            if (mFocusedPrior != 0)
-                findViewById(R.id.ml_menu_search).requestFocus();
+        if(mRootContainer.isDrawerOpen(mSideMenu)) {
+            View search = findViewById(R.id.ml_menu_search);
+            if (mFocusedPrior != 0 && search != null)
+                search.requestFocus();
             mRootContainer.closeDrawer(mSideMenu);
             return;
         }



More information about the Android mailing list