diff options
author | Owen Lin <owenlin@google.com> | 2012-08-29 01:46:38 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-08-29 01:46:39 -0700 |
commit | baef14a1aafdd7a173b90f022ed3c9272fb9f359 (patch) | |
tree | 13194ad7753aba63ff6ef336603e87c02deb0e26 | |
parent | b0f84ee364784ffb64bb58df675a8042cbb49a6d (diff) | |
parent | 24081fe26ca25448ddb9c8f9cc7f406d26344dec (diff) | |
download | android_packages_apps_Gallery2-baef14a1aafdd7a173b90f022ed3c9272fb9f359.tar.gz android_packages_apps_Gallery2-baef14a1aafdd7a173b90f022ed3c9272fb9f359.tar.bz2 android_packages_apps_Gallery2-baef14a1aafdd7a173b90f022ed3c9272fb9f359.zip |
Merge "Fix NPE in viewing single image." into gb-ub-photos-arches
-rw-r--r-- | src/com/android/gallery3d/app/GalleryActionBar.java | 20 | ||||
-rw-r--r-- | src/com/android/gallery3d/app/PhotoPage.java | 32 |
2 files changed, 25 insertions, 27 deletions
diff --git a/src/com/android/gallery3d/app/GalleryActionBar.java b/src/com/android/gallery3d/app/GalleryActionBar.java index 0f7579e60..0aac60e77 100644 --- a/src/com/android/gallery3d/app/GalleryActionBar.java +++ b/src/com/android/gallery3d/app/GalleryActionBar.java @@ -298,27 +298,27 @@ public class GalleryActionBar implements OnNavigationListener { private Menu mActionBarMenu; private MenuItem mShareMenuItem; + private Intent mShareIntent; public void createActionBarMenu(int menuRes, Menu menu) { mActivity.getSupportMenuInflater().inflate(menuRes, menu); mActionBarMenu = menu; mShareMenuItem = menu.findItem(R.id.action_share); + if (mShareMenuItem != null) { + ((ShareActionProvider) mShareMenuItem.getActionProvider()) + .setShareIntent(mShareIntent); + } } public Menu getMenu() { return mActionBarMenu; } - public boolean hasShareMenuItem() { - return mShareMenuItem != null; - } - public void setShareIntent(Intent shareIntent) { - ((ShareActionProvider) mShareMenuItem.getActionProvider()) - .setShareIntent(shareIntent); - } - - public MenuItem findMenuItem(int itemId) { - return mActionBarMenu.findItem(itemId); + mShareIntent = shareIntent; + if (mShareMenuItem != null) { + ((ShareActionProvider) mShareMenuItem.getActionProvider()) + .setShareIntent(shareIntent); + } } } diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index b50f0b762..71f886129 100644 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -53,13 +53,13 @@ import com.android.gallery3d.data.SnailItem; import com.android.gallery3d.data.SnailSource; import com.android.gallery3d.picasasource.PicasaSource; import com.android.gallery3d.ui.AnimationTime; +import com.android.gallery3d.ui.BitmapScreenNail; import com.android.gallery3d.ui.DetailsHelper; import com.android.gallery3d.ui.DetailsHelper.CloseListener; import com.android.gallery3d.ui.DetailsHelper.DetailsSource; import com.android.gallery3d.ui.GLCanvas; import com.android.gallery3d.ui.GLRoot; import com.android.gallery3d.ui.GLRoot.OnGLIdleListener; -import com.android.gallery3d.ui.BitmapScreenNail; import com.android.gallery3d.ui.GLView; import com.android.gallery3d.ui.ImportCompleteListener; import com.android.gallery3d.ui.MenuExecutor; @@ -108,7 +108,6 @@ public class PhotoPage extends ActivityState implements private PhotoPage.Model mModel; private DetailsHelper mDetailsHelper; private boolean mShowDetails; - private Path mPendingSharePath; // mMediaSet could be null if there is no KEY_MEDIA_SET_PATH supplied. // E.g., viewing a photo in gmail attachment @@ -377,7 +376,7 @@ public class PhotoPage extends ActivityState implements @TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN) private void setNfcBeamPushUris(Uri[] uris) { if (mNfcAdapter != null && ApiHelper.HAS_SET_BEAM_PUSH_URIS) { - mNfcAdapter.setBeamPushUris(uris, (Activity)mActivity); + mNfcAdapter.setBeamPushUris(uris, mActivity); } } @@ -393,16 +392,10 @@ public class PhotoPage extends ActivityState implements } private void updateShareURI(Path path) { - if (mActionBar.hasShareMenuItem()) { - DataManager manager = mActivity.getDataManager(); - Uri uri = manager.getContentUri(path); - mActionBar.setShareIntent(createShareIntent(path)); - setNfcBeamPushUris(new Uri[]{uri}); - mPendingSharePath = null; - } else { - // This happens when ActionBar is not created yet. - mPendingSharePath = path; - } + DataManager manager = mActivity.getDataManager(); + Uri uri = manager.getContentUri(path); + mActionBar.setShareIntent(createShareIntent(path)); + setNfcBeamPushUris(new Uri[]{uri}); } private void updateCurrentPhoto(MediaItem photo) { @@ -432,16 +425,22 @@ public class PhotoPage extends ActivityState implements } private void updateMenuOperations() { - MenuItem item = mActionBar.findMenuItem(R.id.action_slideshow); + Menu menu = mActionBar.getMenu(); + + // it could be null if onCreateActionBar has not been called yet + if (menu == null) return; + + MenuItem item = menu.findItem(R.id.action_slideshow); item.setVisible((mSecureAlbum == null) && canDoSlideShow()); if (mCurrentPhoto == null) return; + int supportedOperations = mCurrentPhoto.getSupportedOperations(); if (mSecureAlbum != null) { - supportedOperations = supportedOperations & MediaObject.SUPPORT_DELETE; + supportedOperations &= MediaObject.SUPPORT_DELETE; } else if (!GalleryUtils.isEditorAvailable(mActivity, "image/*")) { supportedOperations &= ~MediaObject.SUPPORT_EDIT; } - MenuExecutor.updateMenuOperation(mActionBar.getMenu(), supportedOperations); + MenuExecutor.updateMenuOperation(menu, supportedOperations); } private boolean canDoSlideShow() { @@ -600,7 +599,6 @@ public class PhotoPage extends ActivityState implements @Override protected boolean onCreateActionBar(Menu menu) { mActionBar.createActionBarMenu(R.menu.photo, menu); - if (mPendingSharePath != null) updateShareURI(mPendingSharePath); updateMenuOperations(); updateTitle(); return true; |