diff options
author | Wei Huang <weih@google.com> | 2012-03-15 15:23:00 -0700 |
---|---|---|
committer | Wei Huang <weih@google.com> | 2012-03-15 15:29:28 -0700 |
commit | 6fe7e6ae561511922f99346a8021f44a126c6218 (patch) | |
tree | c759ef35b34b53a51cd0569e612eeb84b4a5b9e1 | |
parent | be0cb26de2b21fd5166b05ff5db427636344b7b6 (diff) | |
download | android_packages_apps_Snap-6fe7e6ae561511922f99346a8021f44a126c6218.tar.gz android_packages_apps_Snap-6fe7e6ae561511922f99346a8021f44a126c6218.tar.bz2 android_packages_apps_Snap-6fe7e6ae561511922f99346a8021f44a126c6218.zip |
bug #6176711: guard against null GalleryActionBar.
When entering Gallery app from WallPaper picker, the activity is DialogPicker, which doesn't initialize GalleryActionbar so getGalleryActionbar() returns null. Guard against using the null object.
I fixed the obvious NPE here, but Ray or Yuli should take a closer look, to see why this is broken.
Change-Id: Ic6923c388ea7b72ab402131fc3b039546509e340
-rw-r--r-- | src/com/android/gallery3d/app/ActivityState.java | 5 | ||||
-rw-r--r-- | src/com/android/gallery3d/app/AlbumPage.java | 5 | ||||
-rw-r--r-- | src/com/android/gallery3d/app/PhotoPage.java | 6 |
3 files changed, 12 insertions, 4 deletions
diff --git a/src/com/android/gallery3d/app/ActivityState.java b/src/com/android/gallery3d/app/ActivityState.java index 443e2bd29..384ae734b 100644 --- a/src/com/android/gallery3d/app/ActivityState.java +++ b/src/com/android/gallery3d/app/ActivityState.java @@ -141,7 +141,10 @@ abstract public class ActivityState { actionBar.show(); } int stateCount = mActivity.getStateManager().getStateCount(); - mActivity.getGalleryActionBar().setDisplayOptions(stateCount > 1, true); + GalleryActionBar galleryActionbar = mActivity.getGalleryActionBar(); + if (galleryActionbar != null) { + galleryActionbar.setDisplayOptions(stateCount > 1, true); + } // Default behavior, this can be overridden in ActivityState's onResume. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); } diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java index 411464e86..32c5b7fc2 100644 --- a/src/com/android/gallery3d/app/AlbumPage.java +++ b/src/com/android/gallery3d/app/AlbumPage.java @@ -319,7 +319,10 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster Path path = mMediaSet.getPath(); boolean enableHomeButton = (mActivity.getStateManager().getStateCount() > 1) | mParentMediaSetString != null; - mActivity.getGalleryActionBar().setDisplayOptions(enableHomeButton, true); + GalleryActionBar galleryActionBar = mActivity.getGalleryActionBar(); + if (galleryActionBar != null) { + galleryActionBar.setDisplayOptions(enableHomeButton, true); + } // Set the reload bit here to prevent it exit this page in clearLoadingBit(). setLoadingBit(BIT_LOADING_RELOAD); diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index 8040a2fc6..a8c69b567 100644 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -630,8 +630,10 @@ public class PhotoPage extends ActivityState if (mMenuVisibilityListener == null) { mMenuVisibilityListener = new MyMenuVisibilityListener(); } - mActivity.getGalleryActionBar().setDisplayOptions(mSetPathString != null, true); - + GalleryActionBar galleryActionBar = mActivity.getGalleryActionBar(); + if (galleryActionBar != null) { + galleryActionBar.setDisplayOptions(mSetPathString != null, true); + } mActionBar.addOnMenuVisibilityListener(mMenuVisibilityListener); onUserInteraction(); } |