diff options
author | Owen Lin <owenlin@google.com> | 2012-04-09 16:11:30 +0800 |
---|---|---|
committer | Owen Lin <owenlin@google.com> | 2012-04-10 11:12:58 +0800 |
commit | a66827d34d8c29a612787e3fa2557a53191494da (patch) | |
tree | bac0ba9200a75d7a1f68d7f22e63a8c83a0db207 /src/com/android/gallery3d/app/AlbumSetDataLoader.java | |
parent | 359dadda41154bd1836312a70280b42d86777be1 (diff) | |
download | android_packages_apps_Snap-a66827d34d8c29a612787e3fa2557a53191494da.tar.gz android_packages_apps_Snap-a66827d34d8c29a612787e3fa2557a53191494da.tar.bz2 android_packages_apps_Snap-a66827d34d8c29a612787e3fa2557a53191494da.zip |
Prevent album's label get flashing when content changed.
Change-Id: I1b00b308af740ccab143a073643729ca880770f4
Diffstat (limited to 'src/com/android/gallery3d/app/AlbumSetDataLoader.java')
-rw-r--r-- | src/com/android/gallery3d/app/AlbumSetDataLoader.java | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/com/android/gallery3d/app/AlbumSetDataLoader.java b/src/com/android/gallery3d/app/AlbumSetDataLoader.java index 1d3ab7173..819adccb7 100644 --- a/src/com/android/gallery3d/app/AlbumSetDataLoader.java +++ b/src/com/android/gallery3d/app/AlbumSetDataLoader.java @@ -53,6 +53,7 @@ public class AlbumSetDataLoader { private final MediaSet[] mData; private final MediaItem[] mCoverItem; + private final int[] mTotalCount; private final long[] mItemVersion; private final long[] mSetVersion; @@ -78,6 +79,7 @@ public class AlbumSetDataLoader { mSource = Utils.checkNotNull(albumSet); mCoverItem = new MediaItem[cacheSize]; mData = new MediaSet[cacheSize]; + mTotalCount = new int[cacheSize]; mItemVersion = new long[cacheSize]; mSetVersion = new long[cacheSize]; Arrays.fill(mItemVersion, MediaObject.INVALID_DATA_VERSION); @@ -113,22 +115,28 @@ public class AlbumSetDataLoader { mReloadTask.start(); } - public MediaSet getMediaSet(int index) { + private void assertIsActive(int index) { if (index < mActiveStart && index >= mActiveEnd) { throw new IllegalArgumentException(String.format( "%s not in (%s, %s)", index, mActiveStart, mActiveEnd)); } + } + + public MediaSet getMediaSet(int index) { + assertIsActive(index); return mData[index % mData.length]; } public MediaItem getCoverItem(int index) { - if (index < mActiveStart && index >= mActiveEnd) { - throw new IllegalArgumentException(String.format( - "%s not in (%s, %s)", index, mActiveStart, mActiveEnd)); - } + assertIsActive(index); return mCoverItem[index % mCoverItem.length]; } + public int getTotalCount(int index) { + assertIsActive(index); + return mTotalCount[index % mTotalCount.length]; + } + public int getActiveStart() { return mActiveStart; } @@ -144,6 +152,7 @@ public class AlbumSetDataLoader { private void clearSlot(int slotIndex) { mData[slotIndex] = null; mCoverItem[slotIndex] = null; + mTotalCount[slotIndex] = 0; mItemVersion[slotIndex] = MediaObject.INVALID_DATA_VERSION; mSetVersion[slotIndex] = MediaObject.INVALID_DATA_VERSION; } @@ -216,6 +225,7 @@ public class AlbumSetDataLoader { public int size; public MediaSet item; public MediaItem cover; + public int totalCount; } private class GetUpdateInfo implements Callable<UpdateInfo> { @@ -276,6 +286,7 @@ public class AlbumSetDataLoader { mItemVersion[pos] = itemVersion; mData[pos] = info.item; mCoverItem[pos] = info.cover; + mTotalCount[pos] = info.totalCount; if (mDataListener != null && info.index >= mActiveStart && info.index < mActiveEnd) { mDataListener.onContentChanged(info.index); @@ -356,6 +367,7 @@ public class AlbumSetDataLoader { info.item = mSource.getSubMediaSet(info.index); if (info.item == null) continue; info.cover = info.item.getCoverMediaItem(); + info.totalCount = info.item.getTotalMediaItemCount(); } } executeAndWait(new UpdateContent(info)); |