diff options
| author | Likai Ding <likaid@codeaurora.org> | 2016-04-08 12:59:44 +0800 |
|---|---|---|
| committer | Likai Ding <likaid@codeaurora.org> | 2016-04-08 12:59:44 +0800 |
| commit | 727dedd804641dac07970f0943143400d0a91255 (patch) | |
| tree | 50b17f2ab5f96f0e936453640ef4bcd49cf08801 /src | |
| parent | abc97666333eeb1b3c89293dca3324b7dd9260b9 (diff) | |
| download | android_packages_apps_Gallery2-727dedd804641dac07970f0943143400d0a91255.tar.gz android_packages_apps_Gallery2-727dedd804641dac07970f0943143400d0a91255.tar.bz2 android_packages_apps_Gallery2-727dedd804641dac07970f0943143400d0a91255.zip | |
Gallery: improve timeline loading performance
Cache size in TimeLineDataLoader is unnecessarily large, which prevents
top images from being shown. Reduce the cache size as there already is
cache in underlying mediaset.
Also fixed some minor issues hinted by IDE.
Change-Id: Ia0b3259d489d880e53ec35f589efdd6ac36254c8
CRs-Fixed: 984190
Diffstat (limited to 'src')
| -rw-r--r-- | src/com/android/gallery3d/app/TimeLineDataLoader.java | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/src/com/android/gallery3d/app/TimeLineDataLoader.java b/src/com/android/gallery3d/app/TimeLineDataLoader.java index bd2193ff9..be0f42cd3 100644 --- a/src/com/android/gallery3d/app/TimeLineDataLoader.java +++ b/src/com/android/gallery3d/app/TimeLineDataLoader.java @@ -38,14 +38,14 @@ import java.util.concurrent.FutureTask; public class TimeLineDataLoader { @SuppressWarnings("unused") private static final String TAG = "TimeLineDataLoader"; - private static final int DATA_CACHE_SIZE = 1000; + private static final int DATA_CACHE_SIZE = 96 * 2; private static final int MSG_LOAD_START = 1; private static final int MSG_LOAD_FINISH = 2; private static final int MSG_RUN_OBJECT = 3; private static final int MIN_LOAD_COUNT = 32; - private static final int MAX_LOAD_COUNT = 64; + private static final int MAX_LOAD_COUNT = 96 * 2; private final MediaItem[] mData; private final long[] mItemVersion; @@ -119,8 +119,7 @@ public class TimeLineDataLoader { } public MediaSet getMediaSet(int index) { - MediaSet mediaSet = ((ClusterAlbumSet)mSource).getAlbumFromindex(index); - return mediaSet; + return ((ClusterAlbumSet) mSource).getAlbumFromindex(index); } public MediaItem get(int index) { @@ -131,11 +130,7 @@ public class TimeLineDataLoader { } public int getTimeLineTitlesCount() { - return ((ClusterAlbumSet) mSource).getSubMediaSetCount(); - } - - public int getActiveStart() { - return mActiveStart; + return mSource.getSubMediaSetCount(); } public boolean isActive(int index) { @@ -376,11 +371,7 @@ public class TimeLineDataLoader { if (mActive && !mDirty && updateComplete && version != MediaObject.INVALID_DATA_VERSION) { updateLoading(false); - if (mFailedVersion != MediaObject.INVALID_DATA_VERSION) { - } Utils.waitWithoutInterrupt(this); - if (mActive && (mFailedVersion != MediaObject.INVALID_DATA_VERSION)) { - } continue; } mDirty = false; @@ -397,9 +388,10 @@ public class TimeLineDataLoader { info.version = version; } if (info.reloadCount > 0) { - info.items = mSource.getMediaItem(info.reloadStart, info.reloadCount); + int start = Math.max(info.reloadStart, mContentStart); + int end = Math.min(info.reloadStart + info.reloadCount, mContentEnd); + info.items = mSource.getMediaItem(start, end - start); } - executeAndWait(new UpdateContent(info)); } updateLoading(false); |
