adding some widget related null checks

This commit is contained in:
tibbi 2021-05-14 21:05:49 +02:00
parent aa3d048468
commit 76587bf01f

View File

@ -47,7 +47,8 @@ val Context.eventsHelper: EventsHelper get() = EventsHelper(this)
val Context.calDAVHelper: CalDAVHelper get() = CalDAVHelper(this)
fun Context.updateWidgets() {
val widgetIDs = AppWidgetManager.getInstance(applicationContext)?.getAppWidgetIds(ComponentName(applicationContext, MyWidgetMonthlyProvider::class.java)) ?: return
val widgetIDs = AppWidgetManager.getInstance(applicationContext)?.getAppWidgetIds(ComponentName(applicationContext, MyWidgetMonthlyProvider::class.java))
?: return
if (widgetIDs.isNotEmpty()) {
Intent(applicationContext, MyWidgetMonthlyProvider::class.java).apply {
action = AppWidgetManager.ACTION_APPWIDGET_UPDATE
@ -61,7 +62,8 @@ fun Context.updateWidgets() {
}
fun Context.updateListWidget() {
val widgetIDs = AppWidgetManager.getInstance(applicationContext)?.getAppWidgetIds(ComponentName(applicationContext, MyWidgetListProvider::class.java)) ?: return
val widgetIDs = AppWidgetManager.getInstance(applicationContext)?.getAppWidgetIds(ComponentName(applicationContext, MyWidgetListProvider::class.java))
?: return
if (widgetIDs.isNotEmpty()) {
Intent(applicationContext, MyWidgetListProvider::class.java).apply {
action = AppWidgetManager.ACTION_APPWIDGET_UPDATE
@ -72,7 +74,8 @@ fun Context.updateListWidget() {
}
fun Context.updateDateWidget() {
val widgetIDs = AppWidgetManager.getInstance(applicationContext)?.getAppWidgetIds(ComponentName(applicationContext, MyWidgetDateProvider::class.java)) ?: return
val widgetIDs = AppWidgetManager.getInstance(applicationContext)?.getAppWidgetIds(ComponentName(applicationContext, MyWidgetDateProvider::class.java))
?: return
if (widgetIDs.isNotEmpty()) {
Intent(applicationContext, MyWidgetDateProvider::class.java).apply {
action = AppWidgetManager.ACTION_APPWIDGET_UPDATE