adding some widget related null checks

This commit is contained in:
tibbi 2021-05-13 14:50:54 +02:00
parent 4841666e18
commit fc2d42490a
2 changed files with 2 additions and 2 deletions

View file

@ -89,7 +89,7 @@ class WidgetConfigureActivity : SimpleActivity() {
private fun saveConfig() {
val views = RemoteViews(packageName, R.layout.widget)
views.setBackgroundColor(R.id.widget_holder, mBgColor)
AppWidgetManager.getInstance(this).updateAppWidget(mWidgetId, views)
AppWidgetManager.getInstance(this)?.updateAppWidget(mWidgetId, views) ?: return
config.showWidgetFolderName = folder_picker_show_folder_name.isChecked
val widget = Widget(null, mWidgetId, mFolderPath)
ensureBackgroundThread {

View file

@ -818,7 +818,7 @@ fun Context.deleteMediumWithPath(path: String) {
}
fun Context.updateWidgets() {
val widgetIDs = AppWidgetManager.getInstance(applicationContext).getAppWidgetIds(ComponentName(applicationContext, MyWidgetProvider::class.java))
val widgetIDs = AppWidgetManager.getInstance(applicationContext)?.getAppWidgetIds(ComponentName(applicationContext, MyWidgetProvider::class.java)) ?: return
if (widgetIDs.isNotEmpty()) {
Intent(applicationContext, MyWidgetProvider::class.java).apply {
action = AppWidgetManager.ACTION_APPWIDGET_UPDATE