diff options
| author | Likai Ding <likaid@codeaurora.org> | 2016-04-11 15:00:30 +0800 |
|---|---|---|
| committer | Likai Ding <likaid@codeaurora.org> | 2016-04-11 15:42:47 +0800 |
| commit | 0555d4c8b28ee879cc5f4b53550c99cc510f0f06 (patch) | |
| tree | 3dfc3fa1ca12176e99cc4091cece8e4a32415c77 /src | |
| parent | 53deaf4cbc171ca6afe2cd7131fdefe58fee84de (diff) | |
| download | android_packages_apps_Gallery2-0555d4c8b28ee879cc5f4b53550c99cc510f0f06.tar.gz android_packages_apps_Gallery2-0555d4c8b28ee879cc5f4b53550c99cc510f0f06.tar.bz2 android_packages_apps_Gallery2-0555d4c8b28ee879cc5f4b53550c99cc510f0f06.zip | |
Gallery: improve timeline loading performance
MediaSet's getTotalMediaItemCount() method involves database queries
which is slow. The call is not needed in time clustering as the items
will be enumerated right after that.
Change-Id: I8eaa68237c923486109935180247188da94f397b
CRs-Fixed: 984190
Diffstat (limited to 'src')
| -rw-r--r-- | src/com/android/gallery3d/data/TimeClustering.java | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/src/com/android/gallery3d/data/TimeClustering.java b/src/com/android/gallery3d/data/TimeClustering.java index 87111f29d..db47c40d9 100644 --- a/src/com/android/gallery3d/data/TimeClustering.java +++ b/src/com/android/gallery3d/data/TimeClustering.java @@ -98,14 +98,12 @@ public class TimeClustering extends Clustering { @Override public void run(MediaSet baseSet) { - final int total = baseSet.getTotalMediaItemCount(); - final SmallItem[] buf = new SmallItem[total]; final double[] latLng = new double[2]; + final ArrayList<SmallItem> items = new ArrayList<>(); baseSet.enumerateTotalMediaItems(new MediaSet.ItemConsumer() { @Override public void consume(int index, MediaItem item) { - if (index < 0 || index >= total) return; SmallItem s = new SmallItem(); s.path = item.getPath(); s.mediaType = item.getMediaType(); @@ -113,17 +111,10 @@ public class TimeClustering extends Clustering { item.getLatLong(latLng); s.lat = latLng[0]; s.lng = latLng[1]; - buf[index] = s; + items.add(s); } }); - ArrayList<SmallItem> items = new ArrayList<SmallItem>(total); - for (int i = 0; i < total; i++) { - if (buf[i] != null) { - items.add(buf[i]); - } - } - Collections.sort(items, sDateComparator); int n = items.size(); |
