diff options
| author | John Hoford <hoford@google.com> | 2013-08-26 22:12:44 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-08-26 22:12:46 +0000 |
| commit | 3e6ca1692d499fce6842c00428368598b68b86cb (patch) | |
| tree | 05a936acb2625a1cd6ec212f1e66bd34930fd3ef /src/com | |
| parent | fa2b9222725e96fdb584aca1b1213b0bda8af110 (diff) | |
| parent | 601bbb6da7ed8241cda50323b46090ecfff61bdd (diff) | |
| download | android_packages_apps_Gallery2-3e6ca1692d499fce6842c00428368598b68b86cb.tar.gz android_packages_apps_Gallery2-3e6ca1692d499fce6842c00428368598b68b86cb.tar.bz2 android_packages_apps_Gallery2-3e6ca1692d499fce6842c00428368598b68b86cb.zip | |
Merge "Prevent slide show request with only on slide" into gb-ub-photos-carlsbad
Diffstat (limited to 'src/com')
| -rw-r--r-- | src/com/android/gallery3d/app/AlbumPage.java | 22 | ||||
| -rw-r--r-- | src/com/android/gallery3d/app/PhotoPage.java | 16 |
2 files changed, 38 insertions, 0 deletions
diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java index 658abbbd4..ad757da9c 100644 --- a/src/com/android/gallery3d/app/AlbumPage.java +++ b/src/com/android/gallery3d/app/AlbumPage.java @@ -538,6 +538,27 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster mSlotView.invalidate(); } + private boolean canDoSlideShow() { + if (mMediaSet == null) { + return false; + } + + final int[] count = new int[]{0}; + mMediaSet.enumerateMediaItems(new MediaSet.ItemConsumer() { + @Override + public void consume(int index, MediaItem item) { + if (item.getMediaType() == MediaObject.MEDIA_TYPE_IMAGE) { + count[0]++; + } + } + }); + + if (count[0] < 2) { // you must have 2 pictures to go into slide show + return false; + } + return true; + } + @Override protected boolean onCreateActionBar(Menu menu) { GalleryActionBar actionBar = mActivity.getGalleryActionBar(); @@ -553,6 +574,7 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster FilterUtils.setupMenuItems(actionBar, mMediaSetPath, true); + menu.findItem(R.id.action_slideshow).setVisible(canDoSlideShow()); menu.findItem(R.id.action_group_by).setVisible(mShowClusterMenu); menu.findItem(R.id.action_camera).setVisible( MediaSetUtils.isCameraSource(mMediaSetPath) diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index 325723ca4..1dacb8763 100644 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -760,16 +760,32 @@ public abstract class PhotoPage extends ActivityState implements supportedOperations &= ~MediaObject.SUPPORT_EDIT; } } + MenuExecutor.updateMenuOperation(menu, supportedOperations); } private boolean canDoSlideShow() { + if (mMediaSet == null || mCurrentPhoto == null) { return false; } if (mCurrentPhoto.getMediaType() != MediaObject.MEDIA_TYPE_IMAGE) { return false; } + final int[] count = new int[]{0}; + + mMediaSet.enumerateMediaItems(new MediaSet.ItemConsumer() { + @Override + public void consume(int index, MediaItem item) { + if (item.getMediaType() == MediaObject.MEDIA_TYPE_IMAGE) { + count[0]++; + } + } + }); + + if (count[0] < 2) { // you must have 3 pictures to go into slide show + return false; + } return true; } |
