From 6efbd7283aea80eef8e5001291eb53c9e156e88c Mon Sep 17 00:00:00 2001 From: Wei Huang Date: Thu, 15 Mar 2012 15:23:00 -0700 Subject: 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 --- src/com/android/gallery3d/app/ActivityState.java | 5 ++++- src/com/android/gallery3d/app/AlbumPage.java | 5 ++++- 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(); } -- cgit v1.2.3