From 95505451818d10cc87aa740c9e11c785db0052e3 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 31 May 2016 17:19:01 +0200 Subject: [PATCH] small context handling change in widget --- .../simplemobiletools/calendar/MyWidgetProvider.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/simplemobiletools/calendar/MyWidgetProvider.java b/app/src/main/java/com/simplemobiletools/calendar/MyWidgetProvider.java index d02ba3ad4..816ac3530 100644 --- a/app/src/main/java/com/simplemobiletools/calendar/MyWidgetProvider.java +++ b/app/src/main/java/com/simplemobiletools/calendar/MyWidgetProvider.java @@ -38,13 +38,13 @@ public class MyWidgetProvider extends AppWidgetProvider implements Calendar { @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { - cxt = context; - initVariables(); + initVariables(context); updateWidget(); super.onUpdate(context, appWidgetManager, appWidgetIds); } - private void initVariables() { + private void initVariables(Context context) { + cxt = context; res = cxt.getResources(); final SharedPreferences prefs = initPrefs(cxt); @@ -91,9 +91,8 @@ public class MyWidgetProvider extends AppWidgetProvider implements Calendar { @Override public void onReceive(Context context, Intent intent) { - cxt = context; - if (remoteViews == null || widgetManager == null || calendar == null) - initVariables(); + if (remoteViews == null || widgetManager == null || calendar == null || cxt == null) + initVariables(context); final String action = intent.getAction(); switch (action) {