diff options
author | John Hoford <hoford@google.com> | 2013-08-23 14:29:46 -0700 |
---|---|---|
committer | John Hoford <hoford@google.com> | 2013-08-23 16:26:50 -0700 |
commit | 601bbb6da7ed8241cda50323b46090ecfff61bdd (patch) | |
tree | fc5a1e0076fce1f6e3b9229c0414b3fa249b388d /src/com/android/gallery3d/app/AlbumPage.java | |
parent | 49798939f1bc58eaf5842bbc8bc5424284ab7930 (diff) | |
download | android_packages_apps_Gallery2-601bbb6da7ed8241cda50323b46090ecfff61bdd.tar.gz android_packages_apps_Gallery2-601bbb6da7ed8241cda50323b46090ecfff61bdd.tar.bz2 android_packages_apps_Gallery2-601bbb6da7ed8241cda50323b46090ecfff61bdd.zip |
Prevent slide show request with only on slide
bug:8794694
Change-Id: Id3354733c7f35d9303b01f07ddf30f5555b07ddd
Diffstat (limited to 'src/com/android/gallery3d/app/AlbumPage.java')
-rw-r--r-- | src/com/android/gallery3d/app/AlbumPage.java | 22 |
1 files changed, 22 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) |