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 | 8cbc7c4eedb204e3ad9fa1cb8a7a1b21f7464c74 (patch) | |
| tree | 7a71f1d9ff8bc202a93717265e76b6fc740c1ff0 /src | |
| parent | 00b5f3c66113d14a7fc6f37d3a4e9d0c9b566eaa (diff) | |
| parent | 2066200f8fd0a2ed5b97e53115eb5de6b56320e1 (diff) | |
| download | android_packages_apps_Gallery2-8cbc7c4eedb204e3ad9fa1cb8a7a1b21f7464c74.tar.gz android_packages_apps_Gallery2-8cbc7c4eedb204e3ad9fa1cb8a7a1b21f7464c74.tar.bz2 android_packages_apps_Gallery2-8cbc7c4eedb204e3ad9fa1cb8a7a1b21f7464c74.zip | |
Merge "Fix 5637927: NPE while trying to do slide show for gmail image attachment" into ics-mr1
Diffstat (limited to 'src')
| -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; |
