@Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { WidgetProviderComponent component = DaggerWidgetProviderComponent.builder() .applicationComponent( ((AndroidApplication) context.getApplicationContext()).getApplicationComponent()) .widgetProviderModule(new WidgetProviderModule()) .build(); component.inject(this); final int N = appWidgetIds.length; for (int i = 0; i < N; i++) { int appWidgetId = appWidgetIds[i]; executeArrivalsRequest(context, appWidgetManager, appWidgetId); } }
@Override public void onReceive(Context context, Intent intent) { super.onReceive(context, intent); int appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, 0); AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); if (intent.getAction().equals(ACTION_UPDATE_ARRIVALS)) { WidgetProviderComponent component = DaggerWidgetProviderComponent.builder() .applicationComponent( ((AndroidApplication) context.getApplicationContext()).getApplicationComponent()) .widgetProviderModule(new WidgetProviderModule()) .build(); component.inject(this); executeArrivalsRequest(context, appWidgetManager, appWidgetId); } }