diff options
author | Brad Fitzpatrick <bradfitz@android.com> | 2010-10-12 13:52:44 -0700 |
---|---|---|
committer | Brad Fitzpatrick <bradfitz@android.com> | 2010-10-12 13:52:44 -0700 |
commit | 76275ac1c53585a374b5e5f1834631fca9392dd8 (patch) | |
tree | bfaeb599f6a3664a628a4015bdaf79c3873ca34f /src | |
parent | adb4229c23faef81705b6b2fe1dfb8a6474c254c (diff) | |
parent | 700889f504ef134ab307d95b6bfbbb426ea730e3 (diff) | |
download | packages_apps_trebuchet-76275ac1c53585a374b5e5f1834631fca9392dd8.zip packages_apps_trebuchet-76275ac1c53585a374b5e5f1834631fca9392dd8.tar.gz packages_apps_trebuchet-76275ac1c53585a374b5e5f1834631fca9392dd8.tar.bz2 |
resolved conflicts for merge of 700889f5 to master
Change-Id: I85320de6483e6820fe27b4012bfc323ccafa0e04
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher2/LauncherModel.java | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java index c686ee3..eff5ed6 100644 --- a/src/com/android/launcher2/LauncherModel.java +++ b/src/com/android/launcher2/LauncherModel.java @@ -52,6 +52,16 @@ import android.os.RemoteException; import android.os.SystemClock; import android.util.Log; +import java.lang.ref.WeakReference; +import java.net.URISyntaxException; +import java.text.Collator; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; + import com.android.launcher.R; /** @@ -70,10 +80,14 @@ public class LauncherModel extends BroadcastReceiver { private final LauncherApplication mApp; private final Object mLock = new Object(); private DeferredHandler mHandler = new DeferredHandler(); - private HandlerThread mWorkerThread; - private Handler mWorker; private LoaderTask mLoaderTask; + private static final HandlerThread sWorkerThread = new HandlerThread("launcher-loader"); + static { + sWorkerThread.start(); + } + private static final Handler sWorker = new Handler(sWorkerThread.getLooper()); + // We start off with everything not loaded. After that, we assume that // our monitoring of the package manager provides all updates and we never // need to do a requery. These are only ever touched from the loader thread. @@ -119,10 +133,6 @@ public class LauncherModel extends BroadcastReceiver { mAllAppsLoadDelay = app.getResources().getInteger(R.integer.config_allAppsBatchLoadDelay); mBatchSize = app.getResources().getInteger(R.integer.config_allAppsBatchSize); - - mWorkerThread = new HandlerThread("launcher-loader"); - mWorkerThread.start(); - mWorker = new Handler(mWorkerThread.getLooper()); } public Bitmap getFallbackIcon() { @@ -164,11 +174,11 @@ public class LauncherModel extends BroadcastReceiver { values.put(LauncherSettings.Favorites.CELLY, cellY); values.put(LauncherSettings.Favorites.SCREEN, item.screen); - new Thread("moveItemInDatabase") { - public void run() { - cr.update(uri, values, null, null); - } - }.start(); + sWorker.post(new Runnable() { + public void run() { + cr.update(uri, values, null, null); + } + }); } /** @@ -349,11 +359,11 @@ public class LauncherModel extends BroadcastReceiver { static void deleteItemFromDatabase(Context context, ItemInfo item) { final ContentResolver cr = context.getContentResolver(); final Uri uriToDelete = LauncherSettings.Favorites.getContentUri(item.id, false); - new Thread("deleteItemFromDatabase") { - public void run() { - cr.delete(uriToDelete, null, null); - } - }.start(); + sWorker.post(new Runnable() { + public void run() { + cr.delete(uriToDelete, null, null); + } + }); } /** @@ -450,7 +460,7 @@ public class LauncherModel extends BroadcastReceiver { oldTask.stopLocked(); } mLoaderTask = new LoaderTask(context, isLaunching); - mWorker.post(mLoaderTask); + sWorker.post(mLoaderTask); } } } @@ -1232,7 +1242,7 @@ public class LauncherModel extends BroadcastReceiver { } void enqueuePackageUpdated(PackageUpdatedTask task) { - mWorker.post(task); + sWorker.post(task); } private class PackageUpdatedTask implements Runnable { |