Merge "Gallery2: fix photo details title display incorrect in Timeline." into android_ui.lnx.1.2-dev
diff --git a/src/com/android/gallery3d/app/TimeLineDataLoader.java b/src/com/android/gallery3d/app/TimeLineDataLoader.java
index be0f42c..28cb274 100644
--- a/src/com/android/gallery3d/app/TimeLineDataLoader.java
+++ b/src/com/android/gallery3d/app/TimeLineDataLoader.java
@@ -154,10 +154,23 @@
// Returns the index of the MediaItem with the given path or
// -1 if the path is not cached
public int findItem(Path id) {
- for (int i = mContentStart; i < mContentEnd; i++) {
+ return getIndex(id, true);
+ }
+
+ /**
+ * @param id given path
+ * @param needTitleItem timeline title items will be filtered out if true.
+ * @return the index of the MediaItem with the given path or -1 if the path is not cached.
+ */
+ public int getIndex(Path id, final boolean needTitleItem) {
+ for (int i = mContentStart, offset = 0; i < mContentEnd; i++) {
MediaItem item = mData[i % DATA_CACHE_SIZE];
- if (item != null && id == item.getPath()) {
- return i;
+ if (item != null) {
+ if (!needTitleItem && !item.isSelectable()) {
+ offset++;
+ } else if (id == item.getPath()) {
+ return i - offset;
+ }
}
}
return -1;
diff --git a/src/com/android/gallery3d/app/TimeLinePage.java b/src/com/android/gallery3d/app/TimeLinePage.java
index 46e5c7d..a2b4721 100644
--- a/src/com/android/gallery3d/app/TimeLinePage.java
+++ b/src/com/android/gallery3d/app/TimeLinePage.java
@@ -809,7 +809,8 @@
if (mSelectionManager.getSelected(false) == null) return -1;
Path id = mSelectionManager.getSelected(false).get(0);
mIndex = mAlbumDataAdapter.findItem(id);
- return mIndex;
+ int indexToDisplay = mAlbumDataAdapter.getIndex(id, false);
+ return indexToDisplay;
}
@Override