From 4dd53c7e57878d7cd361f8a45751dd3bb2af1531 Mon Sep 17 00:00:00 2001 From: Jorge Ruesga Date: Thu, 12 Sep 2013 23:54:58 +0200 Subject: Gallery2: Fix filmstrip source index Filmstrip has 1 item more (the camera itself). Do not count the Camera as an item Change-Id: I2027d857c08477cb0303e74c15818be1fc979104 Signed-off-by: Jorge Ruesga --- src/com/android/gallery3d/app/PhotoPage.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index 899309d8f..76234bda8 100644 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -164,6 +164,8 @@ public abstract class PhotoPage extends ActivityState implements private boolean mHasCameraScreennailOrPlaceholder = false; private boolean mRecenterCameraOnResume = true; + private int mGalleryMode = GalleryActionBar.ALBUM_FILMSTRIP_MODE_SELECTED; + // These are only valid after the panorama callback private boolean mIsPanorama; private boolean mIsPanorama360; @@ -1503,18 +1505,26 @@ public abstract class PhotoPage extends ActivityState implements @Override public int size() { - return mMediaSet != null ? mMediaSet.getMediaItemCount() : 1; + if (mMediaSet == null) { + return 1; + } + return (mGalleryMode == GalleryActionBar.ALBUM_GRID_MODE_SELECTED) + ? mMediaSet.getMediaItemCount() + : mMediaSet.getMediaItemCount() - 1; } @Override public int setIndex() { - return mModel.getCurrentIndex(); + return (mGalleryMode == GalleryActionBar.ALBUM_GRID_MODE_SELECTED) + ? mModel.getCurrentIndex() + : mModel.getCurrentIndex() - 1; } } @Override public void onAlbumModeSelected(int mode) { - if (mode == GalleryActionBar.ALBUM_GRID_MODE_SELECTED) { + mGalleryMode = mode; + if (mGalleryMode == GalleryActionBar.ALBUM_GRID_MODE_SELECTED) { switchToGrid(); } } -- cgit v1.2.3