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

Commit d207f498 authored by Sihua Ma's avatar Sihua Ma
Browse files

Put widget view updating logic in setListener

Changed the name of function addListener to setListener and migrated the
view-updating logic from createView to setListener

Test: N/A
Bug: 235358918
Change-Id: I013973674c305095a082adfa29e8f2802db90c26
parent 73ce3e64
Loading
Loading
Loading
Loading
+9 −10
Original line number Diff line number Diff line
@@ -418,14 +418,7 @@ public class AppWidgetHost {
        AppWidgetHostView view = onCreateView(context, appWidgetId, appWidget);
        view.setInteractionHandler(mInteractionHandler);
        view.setAppWidget(appWidgetId, appWidget);
        addListener(appWidgetId, view);
        RemoteViews views;
        try {
            views = sService.getAppWidgetViews(mContextOpPackageName, appWidgetId);
        } catch (RemoteException e) {
            throw new RuntimeException("system server dead?", e);
        }
        view.updateAppWidget(views);
        setListener(appWidgetId, view);

        return view;
    }
@@ -513,13 +506,19 @@ public class AppWidgetHost {
     * The AppWidgetHost retains a pointer to the newly-created listener.
     * @param appWidgetId The ID of the app widget for which to add the listener
     * @param listener The listener interface that deals with actions towards the widget view
     *
     * @hide
     */
    public void addListener(int appWidgetId, @NonNull AppWidgetHostListener listener) {
    public void setListener(int appWidgetId, @NonNull AppWidgetHostListener listener) {
        synchronized (mListeners) {
            mListeners.put(appWidgetId, listener);
        }
        RemoteViews views = null;
        try {
            views = sService.getAppWidgetViews(mContextOpPackageName, appWidgetId);
        } catch (RemoteException e) {
            throw new RuntimeException("system server dead?", e);
        }
        listener.updateAppWidget(views);
    }

    /**