Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 227239e7 authored by Hyunyoung Song's avatar Hyunyoung Song
Browse files

update widgets model when package is updated

Fixing a bug where onProviderChanged is called before Package update.
And icon loaded on the widget tray is the default icon.

Change-Id: I4ffea846d057920fd894537432ac5881642bc570
parent 80068f51
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -79,7 +79,8 @@ public class LauncherAppWidgetHost extends AppWidgetHost {
    }

    protected void onProvidersChanged() {
        mLauncher.getModel().loadAndBindWidgetsAndShortcuts(mLauncher, mLauncher);
        mLauncher.getModel().loadAndBindWidgetsAndShortcuts(mLauncher, mLauncher,
                true /* refresh */);
        if (!mProviderChangeListeners.isEmpty()) {
            for (Runnable callback : new ArrayList<>(mProviderChangeListeners)) {
                callback.run();
+8 −6
Original line number Diff line number Diff line
@@ -2867,7 +2867,7 @@ public class LauncherModel extends BroadcastReceiver
                    final Callbacks callbacks = tryGetCallbacks(oldCallbacks);
                    if (callbacks != null) {
                        callbacks.bindAllApplications(added);
                        loadAndBindWidgetsAndShortcuts(mContext,callbacks);
                        loadAndBindWidgetsAndShortcuts(mContext, callbacks, true /* refresh */);
                        if (DEBUG_LOADERS) {
                            Log.d(TAG, "bound " + added.size() + " apps in "
                                + (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
            mHandler.post(new Runnable() {
                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(){
            @Override
            public void run() {
                final ArrayList<Object> list = getWidgetsAndShortcuts(context, true /* refresh */);
                final ArrayList<Object> list = getWidgetsAndShortcuts(context, refresh);
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {