adding some widget related null checks
This commit is contained in:
parent
d09aa44f91
commit
a27f25960b
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue