summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHyunyoung Song <hyunyoungs@google.com>2015-04-21 03:40:03 (GMT)
committerHyunyoung Song <hyunyoungs@google.com>2015-04-21 23:07:30 (GMT)
commitd4af1484447129d489203130e0d654f81a10437d (patch)
tree886f07ca551f867b46be98fa0eab128e9835c8b4
parent7e2a3608b6fa51c884e051625e10d13597cb8796 (diff)
downloadandroid_packages_apps_Trebuchet-d4af1484447129d489203130e0d654f81a10437d.zip
android_packages_apps_Trebuchet-d4af1484447129d489203130e0d654f81a10437d.tar.gz
android_packages_apps_Trebuchet-d4af1484447129d489203130e0d654f81a10437d.tar.bz2
Remove duplicate calls to getSortedWidgetsAndShortcuts
Note: this is a manual CP of the CL that was submitted to ub-launcher3-almonte b/19904873 Change-Id: I2e56bc0c7524caa2ef3c5fb00f35cb032cd1860b
-rw-r--r--src/com/android/launcher3/LauncherAppWidgetHost.java6
-rw-r--r--src/com/android/launcher3/LauncherModel.java36
2 files changed, 24 insertions, 18 deletions
diff --git a/src/com/android/launcher3/LauncherAppWidgetHost.java b/src/com/android/launcher3/LauncherAppWidgetHost.java
index 583f85a..e32e0d9 100644
--- a/src/com/android/launcher3/LauncherAppWidgetHost.java
+++ b/src/com/android/launcher3/LauncherAppWidgetHost.java
@@ -79,11 +79,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);
if (!mProviderChangeListeners.isEmpty()) {
for (Runnable callback : new ArrayList<>(mProviderChangeListeners)) {
callback.run();
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index f7df6bc..424f649 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -38,6 +38,7 @@ import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.net.Uri;
+import android.os.Build;
import android.os.Environment;
import android.os.Handler;
import android.os.HandlerThread;
@@ -3219,19 +3220,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() {
@@ -3280,6 +3271,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();