[Android] Fix a potential crash if mCurrentFragment is null
Jean-Baptiste Kempf
git at videolan.org
Wed Apr 2 20:08:48 CEST 2014
vlc-ports/android | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Wed Apr 2 19:52:03 2014 +0200| [1c9409ba0e747289712fe8a0cf0f6b3fbd932e37] | committer: Jean-Baptiste Kempf
Fix a potential crash if mCurrentFragment is null
---
java.lang.NullPointerException
at org.videolan.vlc.betav7neon.gui.MainActivity.onBackPressed(MainActivity.java:433)
at android.app.Activity.onKeyUp(Activity.java:2101)
at android.view.KeyEvent.dispatch(KeyEvent.java:2577)
at android.app.Activity.dispatchKeyEvent(Activity.java:2334)
at com.actionbarsherlock.app.SherlockFragmentActivity.dispatchKeyEvent(SherlockFragmentActivity.java:122)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1825)
at android.view.ViewRootImpl.deliverKeyEventPostIme(ViewRootImpl.java:3340)
at android.view.ViewRootImpl.handleFinishedEvent(ViewRootImpl.java:3313)
at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2473)
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=1c9409ba0e747289712fe8a0cf0f6b3fbd932e37
---
.../src/org/videolan/vlc/gui/MainActivity.java | 24 +++++++++++---------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index 6ae5637..e40d0b2 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -429,19 +429,21 @@ public class MainActivity extends SherlockFragmentActivity {
if (slideDownAudioPlayer())
return;
- // If it's the directory view, a "backpressed" action shows a parent.
- if (mCurrentFragment.equals("directories")) {
- DirectoryViewFragment directoryView = (DirectoryViewFragment) getFragment(mCurrentFragment);
- if (!directoryView.isRootDirectory()) {
- directoryView.showParentDirectory();
- return;
+ if (mCurrentFragment!= null) {
+ // If it's the directory view, a "backpressed" action shows a parent.
+ if (mCurrentFragment.equals("directories")) {
+ DirectoryViewFragment directoryView = (DirectoryViewFragment) getFragment(mCurrentFragment);
+ if (!directoryView.isRootDirectory()) {
+ directoryView.showParentDirectory();
+ return;
+ }
}
- }
- // If it's the albums songs fragment, we leave it.
- if (secondaryFragments.contains(mCurrentFragment)) {
- popSecondaryFragment();
- return;
+ // If it's the albums songs fragment, we leave it.
+ if (secondaryFragments.contains(mCurrentFragment)) {
+ popSecondaryFragment();
+ return;
+ }
}
super.onBackPressed();
More information about the Android
mailing list