diff options
author | Daniel Sandler <dsandler@android.com> | 2010-04-13 16:23:58 -0400 |
---|---|---|
committer | Daniel Sandler <dsandler@android.com> | 2010-04-14 14:36:10 -0400 |
commit | dca661236c73ecd819cfea964c6f8170e5cc40ae (patch) | |
tree | 5edc07d1ac493d27b0346928be18d605dc1df186 /src/com/android/launcher2/AllAppsList.java | |
parent | 7018d8e32761d65816c01f62b094e17e44c7ffb9 (diff) | |
download | android_packages_apps_Trebuchet-dca661236c73ecd819cfea964c6f8170e5cc40ae.tar.gz android_packages_apps_Trebuchet-dca661236c73ecd819cfea964c6f8170e5cc40ae.tar.bz2 android_packages_apps_Trebuchet-dca661236c73ecd819cfea964c6f8170e5cc40ae.zip |
Batch loading of icons for AllApps.
AllAppsList now maintains <data> and <added> in sorted
order, to amortize the cost of sorting the apps list over
multiple batches.
Launcher boosts thread priority on first launch, but we now
reduce thread priority to normal after the main workspace
has been drawn but before all apps are loaded.
Experimental feature: a short delay is introduced between
batches to help free up the CPU (as well as to show that we
are indeed batching apps).
Bug: 2562420
Change-Id: I2035ec3e819b4e7993a80c6d03bfad3914c95a7a
Diffstat (limited to 'src/com/android/launcher2/AllAppsList.java')
-rw-r--r-- | src/com/android/launcher2/AllAppsList.java | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/com/android/launcher2/AllAppsList.java b/src/com/android/launcher2/AllAppsList.java index 9d4c5b02a..96d936948 100644 --- a/src/com/android/launcher2/AllAppsList.java +++ b/src/com/android/launcher2/AllAppsList.java @@ -24,6 +24,7 @@ import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import java.util.ArrayList; +import java.util.Collections; import java.util.List; @@ -56,10 +57,17 @@ class AllAppsList { /** * Add the supplied ApplicationInfo objects to the list, and enqueue it into the * list to broadcast when notify() is called. + * + * Postcondition: data and added are sorted in order of LauncherModel.APP_NAME_COMPARATOR. */ public void add(ApplicationInfo info) { - data.add(info); - added.add(info); + int pos = Collections.binarySearch(data, info, LauncherModel.APP_NAME_COMPARATOR); + if (pos < 0) pos = -1 - pos; + data.add(pos, info); + + pos = Collections.binarySearch(added, info, LauncherModel.APP_NAME_COMPARATOR); + if (pos < 0) pos = -1 - pos; + added.add(pos, info); } public void clear() { @@ -86,9 +94,7 @@ class AllAppsList { if (matches.size() > 0) { for (ResolveInfo info : matches) { - ApplicationInfo item = new ApplicationInfo(info, mIconCache); - data.add(item); - added.add(item); + add(new ApplicationInfo(info, mIconCache)); } } } @@ -139,9 +145,7 @@ class AllAppsList { info.activityInfo.applicationInfo.packageName, info.activityInfo.name); if (applicationInfo == null) { - applicationInfo = new ApplicationInfo(info, mIconCache); - data.add(applicationInfo); - added.add(applicationInfo); + add(new ApplicationInfo(info, mIconCache)); } else { mIconCache.remove(applicationInfo.componentName); mIconCache.getTitleAndIcon(applicationInfo, info); |