[Android] Prevent NPE
Geoffrey Métais
git at videolan.org
Tue Feb 17 17:43:46 CET 2015
vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Feb 17 12:17:29 2015 +0100| [9731de50ca2232ea7cbef1e71c6714d4743ee5d7] | committer: Geoffrey Métais
Prevent NPE
CID #1270672, #1270670, #1270668
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=9731de50ca2232ea7cbef1e71c6714d4743ee5d7
---
vlc-android/src/org/videolan/vlc/gui/MainActivity.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index b13b73c..64e8e15 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -420,7 +420,7 @@ public class MainActivity extends ActionBarActivity implements OnItemClickListen
} else if (mCurrentFragment.equals(SidebarEntry.ID_NETWORK)){
NetworkFragment networkFragment = (NetworkFragment) getSupportFragmentManager()
.findFragmentById(R.id.fragment_placeholder);
- if (!networkFragment.isRootDirectory()) {
+ if (networkFragment !=null && !networkFragment.isRootDirectory()) {
networkFragment.goBack();
return;
}
@@ -647,6 +647,8 @@ public class MainActivity extends ActionBarActivity implements OnItemClickListen
MediaDatabase.getInstance().clearSearchHistory();
break;
case R.id.ml_menu_save:
+ if (current == null)
+ break;
((NetworkFragment)current).toggleFavorite();
item.setIcon(R.drawable.abc_btn_check_to_on_mtrl_015);
break;
@@ -742,6 +744,8 @@ public class MainActivity extends ActionBarActivity implements OnItemClickListen
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
View v = getCurrentFocus();
+ if (v == null)
+ return super.onKeyUp(keyCode, event);
if ((mActionBarIconId == -1) &&
(v.getId() == -1) &&
(v.getNextFocusDownId() == -1) &&
More information about the Android
mailing list