Skip to content

Commit 3b95eb1

Browse files
committed
update api and readme
1 parent 49d5d5c commit 3b95eb1

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

Diff for: README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class ExampleSingleAppWidget extends AppWidgetProvider {
3636
@Override
3737
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
3838
// update widgets
39-
UpdateService.updateWidgets(context, ExampleSingleAppWidget.class, bundle, appWidgetIds);
39+
UpdateService.updateWidgets(context, this, bundle, appWidgetIds);
4040
}
4141

4242
@Override
@@ -49,7 +49,7 @@ public class ExampleSingleAppWidget extends AppWidgetProvider {
4949
Bundle bundle = new Bundle();
5050
//...
5151
// update widgets
52-
UpdateService.updateWidgets(context, ExampleSingleAppWidget.class, bundle, widgetIds);
52+
UpdateService.updateWidgets(context, this, bundle, widgetIds);
5353
}
5454

5555
@Override

Diff for: example/src/main/java/helper/update/widget/com/example/common/ExampleCommonAppWidget.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] a
2020
bundle.putString("action", SingleRemoteViewBuilder.PREVIOUS_ACTION);
2121
bundle.putString("main_text", SingleRemoteViewBuilder.NEXT_TEXT);
2222
WidgetUpdateService.updateWidgets(context,
23-
ExampleCommonAppWidget.class, bundle, appWidgetIds);
23+
this, bundle, appWidgetIds);
2424
}
2525

2626
@Override
@@ -33,7 +33,7 @@ public void onEnabled(Context context) {
3333
bundle.putString("action", SingleRemoteViewBuilder.PREVIOUS_ACTION);
3434
bundle.putString("main_text", SingleRemoteViewBuilder.NEXT_TEXT);
3535
WidgetUpdateService.updateWidgets(context,
36-
ExampleCommonAppWidget.class, bundle, widgetIds);
36+
this, bundle, widgetIds);
3737
}
3838

3939
@Override
@@ -50,7 +50,7 @@ public void onReceive(Context context, Intent intent) {
5050
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
5151
int[] widgetIds = appWidgetManager.getAppWidgetIds(
5252
new ComponentName(context, ExampleSingleAppWidget.class));
53-
WidgetUpdateService.updateWidgets(context, this.getClass(),
53+
WidgetUpdateService.updateWidgets(context, this,
5454
intent.getBundleExtra(WidgetUpdateService.EXTRA_DATA_BUNDLE), widgetIds);
5555
} else {
5656
super.onReceive(context, intent);

Diff for: example/src/main/java/helper/update/widget/com/example/single/ExampleSingleAppWidget.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] a
1818
Bundle bundle = new Bundle();
1919
bundle.putString("action", SingleRemoteViewBuilder.PREVIOUS_ACTION + String.valueOf(widgetId));
2020
bundle.putString("main_text", SingleRemoteViewBuilder.NEXT_TEXT);
21-
WidgetUpdateService.updateWidgets(context, ExampleSingleAppWidget.class, bundle, widgetId);
21+
WidgetUpdateService.updateWidgets(context, this, bundle, widgetId);
2222
}
2323
}
2424

@@ -33,7 +33,7 @@ public void onEnabled(Context context) {
3333
bundle.putString("action", SingleRemoteViewBuilder.PREVIOUS_ACTION + String.valueOf(widgetId));
3434
bundle.putString("main_text", SingleRemoteViewBuilder.PREVIOUS_TEXT);
3535

36-
WidgetUpdateService.updateWidgets(context, ExampleSingleAppWidget.class, bundle, widgetId);
36+
WidgetUpdateService.updateWidgets(context, this, bundle, widgetId);
3737
}
3838
}
3939

Diff for: widget-helper/src/main/java/heyalex/widgethelper/WidgetUpdateService.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,19 @@ public static Intent getIntentUpdateWidget(Context context,
6565
* Static method for starting update Widget with AppWidgetProvider.class and ids
6666
*
6767
* @param context context for intent
68-
* @param widgetClass for {@link ComponentName} associated with widget that will
68+
* @param provider for {@link ComponentName} associated with widget that will
6969
* be updated
7070
* @param dataBundle bundle of data, that you need to build a RemoteViews
7171
* @param widgetIds ids that will be updated
7272
*/
7373
public static void updateWidgets(Context context,
74-
Class<? extends AppWidgetProvider> widgetClass,
74+
AppWidgetProvider provider,
7575
Bundle dataBundle,
7676
int... widgetIds) {
7777
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
78-
context.startForegroundService(getIntentUpdateWidget(context, widgetClass, dataBundle, widgetIds));
78+
context.startForegroundService(getIntentUpdateWidget(context, provider.getClass(), dataBundle, widgetIds));
7979
} else {
80-
context.startService(getIntentUpdateWidget(context, widgetClass, dataBundle, widgetIds));
80+
context.startService(getIntentUpdateWidget(context, provider.getClass(), dataBundle, widgetIds));
8181
}
8282

8383
}

0 commit comments

Comments
 (0)