diff options
author | Daniel Sandler <dsandler@android.com> | 2010-04-16 15:06:06 -0400 |
---|---|---|
committer | Daniel Sandler <dsandler@android.com> | 2010-04-16 15:17:01 -0400 |
commit | 2ff10b3b0137d258569ce5471808842e88696133 (patch) | |
tree | 2c964f40adc312024e9bd6803d3d1172dc25dbf3 /src/com/android/launcher2/LauncherModel.java | |
parent | 707b0f7c3cece27b0edda61b44c3658e10f4403a (diff) | |
download | packages_apps_trebuchet-2ff10b3b0137d258569ce5471808842e88696133.zip packages_apps_trebuchet-2ff10b3b0137d258569ce5471808842e88696133.tar.gz packages_apps_trebuchet-2ff10b3b0137d258569ce5471808842e88696133.tar.bz2 |
More Launcher performance improvements.
* Removed another redundant sort
* Correctly set the thread priority to BACKGROUND for the
all apps loading step.
* Moved batch delay to a resource
* Reduced delay between loading batches of apps to 100ms
(we really just want to sleep a tiny bit between batches
to give the UI time to react)
Bug: 2562420
Bug: 2599979 (related)
Change-Id: I1ae72a68c1a47377a9eb62827fe7666bfc50caa5
Diffstat (limited to 'src/com/android/launcher2/LauncherModel.java')
-rw-r--r-- | src/com/android/launcher2/LauncherModel.java | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java index 9766831..7a56bcd 100644 --- a/src/com/android/launcher2/LauncherModel.java +++ b/src/com/android/launcher2/LauncherModel.java @@ -62,7 +62,7 @@ public class LauncherModel extends BroadcastReceiver { static final boolean DEBUG_LOADERS = false; static final String TAG = "Launcher.Model"; - final int ALL_APPS_LOAD_DELAY = 150; // ms + private int mAllAppsLoadDelay; // milliseconds between batches private final LauncherApplication mApp; private final Object mLock = new Object(); @@ -98,6 +98,8 @@ public class LauncherModel extends BroadcastReceiver { mDefaultIcon = Utilities.createIconBitmap( app.getPackageManager().getDefaultActivityIcon(), app); + + mAllAppsLoadDelay = app.getResources().getInteger(R.integer.config_allAppsBatchLoadDelay); } public Bitmap getFallbackIcon() { @@ -581,7 +583,7 @@ public class LauncherModel extends BroadcastReceiver { // Whew! Hard work done. synchronized (mLock) { if (mIsLaunching) { - android.os.Process.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT); + android.os.Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); } } @@ -1055,9 +1057,6 @@ public class LauncherModel extends BroadcastReceiver { mAllAppsList.add(new ApplicationInfo(apps.get(i), mIconCache)); i++; } - // re-sort before binding this batch to the grid - Collections.sort(mAllAppsList.data, APP_NAME_COMPARATOR); - Collections.sort(mAllAppsList.added, APP_NAME_COMPARATOR); if (DEBUG_LOADERS) { Log.d(TAG, "batch of " + batchSize + " icons processed in " + (SystemClock.uptimeMillis()-t2) + "ms"); @@ -1066,16 +1065,17 @@ public class LauncherModel extends BroadcastReceiver { mHandler.post(bindAllAppsTask); - if (ALL_APPS_LOAD_DELAY > 0) { + if (mAllAppsLoadDelay > 0 && i < N) { try { - Thread.sleep(ALL_APPS_LOAD_DELAY); + Thread.sleep(mAllAppsLoadDelay); } catch (InterruptedException exc) { } } } if (DEBUG_LOADERS) { Log.d(TAG, "cached all " + N + " apps in " - + (SystemClock.uptimeMillis()-t) + "ms"); + + (SystemClock.uptimeMillis()-t) + "ms" + + (mAllAppsLoadDelay > 0 ? " (including delay)" : "")); } } |