[Android] Avoid NPE on fragment restore
Jean-Baptiste Kempf
git at videolan.org
Mon Apr 14 20:10:15 CEST 2014
vlc-ports/android | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Mon Apr 14 20:03:39 2014 +0200| [33d54feb6312605ce3fe1bfe593d98e2da567f26] | committer: Jean-Baptiste Kempf
Avoid NPE on fragment restore
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=33d54feb6312605ce3fe1bfe593d98e2da567f26
---
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 4cc4420..963a517 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -228,6 +228,10 @@ public class MainActivity extends SherlockFragmentActivity {
return;
}
+ // This should not happen
+ if(entry == null || entry.id == null)
+ return;
+
/*
* Clear any backstack before switching tabs. This avoids
* activating an old backstack, when a user hits the back button
@@ -372,7 +376,7 @@ public class MainActivity extends SherlockFragmentActivity {
*/
if(current == null || (!current.getTag().equals(mCurrentFragment) && found)) {
Log.d(TAG, "Reloading displayed fragment");
- if (secondaryFragments.contains(mCurrentFragment))
+ if (mCurrentFragment == null || secondaryFragments.contains(mCurrentFragment))
mCurrentFragment = "video";
Fragment ff = getFragment(mCurrentFragment);
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
More information about the Android
mailing list