diff --git a/app/src/main/kotlin/com/simplemobiletools/calculator/activities/WidgetConfigureActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calculator/activities/WidgetConfigureActivity.kt index b2a87987..9baa43ee 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calculator/activities/WidgetConfigureActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calculator/activities/WidgetConfigureActivity.kt @@ -64,7 +64,7 @@ class WidgetConfigureActivity : SimpleActivity() { } private fun saveConfig() { - val appWidgetManager = AppWidgetManager.getInstance(this) + val appWidgetManager = AppWidgetManager.getInstance(this) ?: return val views = RemoteViews(packageName, R.layout.widget).apply { applyColorFilter(R.id.widget_background, mBgColor) } diff --git a/app/src/main/kotlin/com/simplemobiletools/calculator/helpers/MyWidgetProvider.kt b/app/src/main/kotlin/com/simplemobiletools/calculator/helpers/MyWidgetProvider.kt index 80f36c98..81b1819e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calculator/helpers/MyWidgetProvider.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calculator/helpers/MyWidgetProvider.kt @@ -115,7 +115,7 @@ class MyWidgetProvider : AppWidgetProvider(), Calculator { } override fun showNewResult(value: String, context: Context) { - val appWidgetManager = AppWidgetManager.getInstance(context) + val appWidgetManager = AppWidgetManager.getInstance(context) ?: return appWidgetManager.getAppWidgetIds(getComponentName(context)).forEach { val views = RemoteViews(context.packageName, R.layout.widget) views.setText(R.id.result, value) @@ -124,7 +124,7 @@ class MyWidgetProvider : AppWidgetProvider(), Calculator { } override fun showNewFormula(value: String, context: Context) { - val appWidgetManager = AppWidgetManager.getInstance(context) + val appWidgetManager = AppWidgetManager.getInstance(context) ?: return appWidgetManager.getAppWidgetIds(getComponentName(context)).forEach { val views = RemoteViews(context.packageName, R.layout.widget) views.setText(R.id.formula, value)