summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHyunyoung Song <hyunyoungs@google.com>2015-04-20 20:40:03 -0700
committerHyunyoung Song <hyunyoungs@google.com>2015-04-20 21:22:46 -0700
commit3af56b605217e4ff1c6ed79a70fa49eacaf5b02f (patch)
tree66b858d7210a46c6bb9f62d5b884f2eb6d3e5792
parent68fdeaadc621b7a9200f5c75790eb756a1983d02 (diff)
downloadandroid_packages_apps_Trebuchet-3af56b605217e4ff1c6ed79a70fa49eacaf5b02f.tar.gz
android_packages_apps_Trebuchet-3af56b605217e4ff1c6ed79a70fa49eacaf5b02f.tar.bz2
android_packages_apps_Trebuchet-3af56b605217e4ff1c6ed79a70fa49eacaf5b02f.zip
Remove duplicate calls to getSortedWidgetsAndShortcuts
b/19904873 Change-Id: I2e56bc0c7524caa2ef3c5fb00f35cb032cd1860b
-rw-r--r--src/com/android/launcher3/LauncherAppWidgetHost.java4
-rw-r--r--src/com/android/launcher3/LauncherModel.java36
2 files changed, 24 insertions, 16 deletions
diff --git a/src/com/android/launcher3/LauncherAppWidgetHost.java b/src/com/android/launcher3/LauncherAppWidgetHost.java
index a28fd255a..55596e5bf 100644
--- a/src/com/android/launcher3/LauncherAppWidgetHost.java
+++ b/src/com/android/launcher3/LauncherAppWidgetHost.java
@@ -81,9 +81,7 @@ public class LauncherAppWidgetHost extends AppWidgetHost {
protected void onProvidersChanged() {
// Once we get the message that widget packages are updated, we need to rebind items
// in AppsCustomize accordingly.
- mLauncher.bindPackagesUpdated(LauncherModel.getSortedWidgetsAndShortcuts(mLauncher,
- true /* refresh */));
-
+ mLauncher.getModel().loadAndBindWidgetsAndShortcuts(mLauncher, mLauncher);
for (Runnable callback : mProviderChangeListeners) {
callback.run();
}
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index b19496147..2e5d4e9b3 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -39,6 +39,7 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Rect;
import android.net.Uri;
+import android.os.Build;
import android.os.Environment;
import android.os.Handler;
import android.os.HandlerThread;
@@ -3320,19 +3321,9 @@ public class LauncherModel extends BroadcastReceiver
}
});
}
-
- final ArrayList<Object> widgetsAndShortcuts =
- getSortedWidgetsAndShortcuts(context, true /* refresh */);
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- Callbacks cb = getCallback();
- if (callbacks == cb && cb != null) {
- callbacks.bindPackagesUpdated(widgetsAndShortcuts);
- }
- }
- });
-
+ if (Build.VERSION.SDK_INT < 17) {
+ loadAndBindWidgetsAndShortcuts(context, callbacks);
+ }
// Write all the logs to disk
mHandler.post(new Runnable() {
public void run() {
@@ -3381,6 +3372,25 @@ public class LauncherModel extends BroadcastReceiver
}
}
+ public void loadAndBindWidgetsAndShortcuts(final Context context, final Callbacks callbacks) {
+ runOnWorkerThread(new Runnable(){
+ @Override
+ public void run() {
+ final ArrayList<Object> list =
+ getSortedWidgetsAndShortcuts(context, true /* refresh */);
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ Callbacks cb = getCallback();
+ if (callbacks == cb && cb != null) {
+ callbacks.bindPackagesUpdated(list);
+ }
+ }
+ });
+ }
+ });
+ }
+
// Returns a list of ResolveInfos/AppWidgetInfos in sorted order
public static ArrayList<Object> getSortedWidgetsAndShortcuts(Context context, boolean refresh) {
PackageManager packageManager = context.getPackageManager();