Merge "update widgets model when package is updated" into ub-launcher3-burnaby

This commit is contained in:
Hyunyoung Song
2015-05-05 01:28:28 +00:00
committed by Android (Google) Code Review
2 changed files with 10 additions and 7 deletions
@@ -79,7 +79,8 @@ public class LauncherAppWidgetHost extends AppWidgetHost {
} }
protected void onProvidersChanged() { protected void onProvidersChanged() {
mLauncher.getModel().loadAndBindWidgetsAndShortcuts(mLauncher, mLauncher); mLauncher.getModel().loadAndBindWidgetsAndShortcuts(mLauncher, mLauncher,
true /* refresh */);
if (!mProviderChangeListeners.isEmpty()) { if (!mProviderChangeListeners.isEmpty()) {
for (Runnable callback : new ArrayList<>(mProviderChangeListeners)) { for (Runnable callback : new ArrayList<>(mProviderChangeListeners)) {
callback.run(); callback.run();
+8 -6
View File
@@ -2867,7 +2867,7 @@ public class LauncherModel extends BroadcastReceiver
final Callbacks callbacks = tryGetCallbacks(oldCallbacks); final Callbacks callbacks = tryGetCallbacks(oldCallbacks);
if (callbacks != null) { if (callbacks != null) {
callbacks.bindAllApplications(added); callbacks.bindAllApplications(added);
loadAndBindWidgetsAndShortcuts(mContext,callbacks); loadAndBindWidgetsAndShortcuts(mContext, callbacks, true /* refresh */);
if (DEBUG_LOADERS) { if (DEBUG_LOADERS) {
Log.d(TAG, "bound " + added.size() + " apps in " Log.d(TAG, "bound " + added.size() + " apps in "
+ (SystemClock.uptimeMillis() - bindTime) + "ms"); + (SystemClock.uptimeMillis() - bindTime) + "ms");
@@ -3228,9 +3228,10 @@ public class LauncherModel extends BroadcastReceiver
} }
}); });
} }
if (Build.VERSION.SDK_INT < 17) {
loadAndBindWidgetsAndShortcuts(context, callbacks); // onProvidersChanged method (API >= 17) already refreshed the widget list
} loadAndBindWidgetsAndShortcuts(context, callbacks, Build.VERSION.SDK_INT < 17);
// Write all the logs to disk // Write all the logs to disk
mHandler.post(new Runnable() { mHandler.post(new Runnable() {
public void run() { public void run() {
@@ -3279,11 +3280,12 @@ public class LauncherModel extends BroadcastReceiver
} }
} }
public void loadAndBindWidgetsAndShortcuts(final Context context, final Callbacks callbacks) { public void loadAndBindWidgetsAndShortcuts(final Context context, final Callbacks callbacks,
final boolean refresh) {
runOnWorkerThread(new Runnable(){ runOnWorkerThread(new Runnable(){
@Override @Override
public void run() { public void run() {
final ArrayList<Object> list = getWidgetsAndShortcuts(context, true /* refresh */); final ArrayList<Object> list = getWidgetsAndShortcuts(context, refresh);
mHandler.post(new Runnable() { mHandler.post(new Runnable() {
@Override @Override
public void run() { public void run() {