Merge "Put widget view updating logic in setListener" into tm-qpr-dev
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user