Extract method to add widget from Intent for DashboardController
Test: ./gradlew test
@@ -126,13 +126,7 @@ public class DashboardController extends UIController {
@Override
public void onReceive(Context context, Intent intent) {
fadeIn();
-
- if(intent.hasExtra(EXTRA_APPWIDGET_ID) && intent.hasExtra(EXTRA_CELL_ID)) {
- int appWidgetId = intent.getExtras().getInt(EXTRA_APPWIDGET_ID, -1);
- int cellId = intent.getExtras().getInt(EXTRA_CELL_ID, -1);
-
- addWidget(appWidgetId, cellId, true);
- }
+ addWidget(intent);
}
};
@@ -498,6 +492,16 @@ public class DashboardController extends UIController {
U.sendBroadcast(context, intent);
}
+ @VisibleForTesting
+ void addWidget(Intent intent) {
+ if (intent.hasExtra(EXTRA_APPWIDGET_ID) && intent.hasExtra(EXTRA_CELL_ID)) {
+ int appWidgetId = intent.getExtras().getInt(EXTRA_APPWIDGET_ID, -1);
+ int cellId = intent.getExtras().getInt(EXTRA_CELL_ID, -1);
+
+ addWidget(appWidgetId, cellId, true);
+ }
+ }
+
private void addWidget(int appWidgetId, int cellId, boolean shouldSave) {
AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(appWidgetId);
