diff options
author | Chih-Chung Chang <chihchung@google.com> | 2011-11-21 04:56:35 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-11-21 04:56:35 -0800 |
commit | ef71b24dbf31f73e6df8ae15ac2a1ad1cbc255f6 (patch) | |
tree | 80f60d293ae614bb65012bb3ca0de35cd8d3dd5d | |
parent | 980202694fa6ad982fe04c5742c9042f47fe2dc2 (diff) | |
parent | 86024818e1c03d1a1179510d91a038e1b756c9f4 (diff) | |
download | android_packages_apps_Snap-ef71b24dbf31f73e6df8ae15ac2a1ad1cbc255f6.tar.gz android_packages_apps_Snap-ef71b24dbf31f73e6df8ae15ac2a1ad1cbc255f6.tar.bz2 android_packages_apps_Snap-ef71b24dbf31f73e6df8ae15ac2a1ad1cbc255f6.zip |
Merge "Fix 5637927: NPE while trying to do slide show for gmail image attachment" into ics-mr1
-rw-r--r-- | src/com/android/gallery3d/app/PhotoPage.java | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index 5d0fd15c7..ed67b08fd 100644 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -300,19 +300,33 @@ public class PhotoPage extends ActivityState } private void updateMenuOperations() { - if (mCurrentPhoto == null || mMenu == null) return; + if (mMenu == null) return; + MenuItem item = mMenu.findItem(R.id.action_slideshow); + if (item != null) { + item.setVisible(canDoSlideShow()); + } + if (mCurrentPhoto == null) return; int supportedOperations = mCurrentPhoto.getSupportedOperations(); if (!GalleryUtils.isEditorAvailable((Context) mActivity, "image/*")) { supportedOperations &= ~MediaObject.SUPPORT_EDIT; } - MenuItem item = mMenu.findItem(R.id.action_slideshow); - if (item != null) { - item.setVisible(mCurrentPhoto.getMediaType() == MediaObject.MEDIA_TYPE_IMAGE); - } MenuExecutor.updateMenuOperation(mMenu, supportedOperations); } + private boolean canDoSlideShow() { + if (mMediaSet == null || mCurrentPhoto == null) { + return false; + } + if (mCurrentPhoto.getMediaType() != MediaObject.MEDIA_TYPE_IMAGE) { + return false; + } + if (mMediaSet instanceof MtpDevice) { + return false; + } + return true; + } + private void showBars() { if (mShowBars) return; mShowBars = true; @@ -401,8 +415,6 @@ public class PhotoPage extends ActivityState protected boolean onCreateActionBar(Menu menu) { MenuInflater inflater = ((Activity) mActivity).getMenuInflater(); inflater.inflate(R.menu.photo, menu); - menu.findItem(R.id.action_slideshow).setVisible( - mMediaSet != null && !(mMediaSet instanceof MtpDevice)); mShareActionProvider = GalleryActionBar.initializeShareActionProvider(menu); if (mPendingSharePath != null) updateShareURI(mPendingSharePath); mMenu = menu; |