Merge "Remove duplicate calls to getSortedWidgetsAndShortcuts" into ub-launcher3-burnaby
This commit is contained in:
committed by
Android (Google) Code Review
commit
31a18f1d81
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user