Prevent crash

pull/162/head 1.750
M66B 5 years ago
parent 721bcff8bb
commit 6b03106bc3

@ -59,7 +59,12 @@ public class Widget extends AppWidgetProvider {
static void update(Context context, Integer count) { static void update(Context context, Integer count) {
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
int[] appWidgetIds = AppWidgetManager.getInstance(context).getAppWidgetIds(new ComponentName(context, Widget.class)); if (appWidgetManager == null) {
Log.w("No app widget manager"); // Fairphone FP2
return;
}
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, Widget.class));
update(context, appWidgetManager, appWidgetIds, count); update(context, appWidgetManager, appWidgetIds, count);
} }

@ -40,7 +40,13 @@ public class WidgetUnified extends AppWidgetProvider {
static void init(Context context, int appWidgetId) { static void init(Context context, int appWidgetId) {
Log.i("Widget unified init=" + appWidgetId); Log.i("Widget unified init=" + appWidgetId);
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
if (appWidgetManager == null) {
Log.w("No app widget manager"); // Fairphone FP2
return;
}
update(context, appWidgetManager, new int[]{appWidgetId}); update(context, appWidgetManager, new int[]{appWidgetId});
} }
@ -48,6 +54,11 @@ public class WidgetUnified extends AppWidgetProvider {
Log.i("Widget unified update"); Log.i("Widget unified update");
if (ActivityBilling.isPro(context)) { if (ActivityBilling.isPro(context)) {
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
if (appWidgetManager == null) {
Log.w("No app widget manager"); // Fairphone FP2
return;
}
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, WidgetUnified.class)); int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, WidgetUnified.class));
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.lv); appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.lv);
} }

Loading…
Cancel
Save