make list widget updating more reliable

This commit is contained in:
tibbi 2021-11-27 11:12:35 +01:00
parent 897fa21ec4
commit 9bd5aa3832
1 changed files with 2 additions and 0 deletions

View File

@ -64,6 +64,7 @@ fun Context.updateWidgets() {
fun Context.updateListWidget() { fun Context.updateListWidget() {
val widgetIDs = AppWidgetManager.getInstance(applicationContext)?.getAppWidgetIds(ComponentName(applicationContext, MyWidgetListProvider::class.java)) val widgetIDs = AppWidgetManager.getInstance(applicationContext)?.getAppWidgetIds(ComponentName(applicationContext, MyWidgetListProvider::class.java))
?: return ?: return
if (widgetIDs.isNotEmpty()) { if (widgetIDs.isNotEmpty()) {
Intent(applicationContext, MyWidgetListProvider::class.java).apply { Intent(applicationContext, MyWidgetListProvider::class.java).apply {
action = AppWidgetManager.ACTION_APPWIDGET_UPDATE action = AppWidgetManager.ACTION_APPWIDGET_UPDATE
@ -71,6 +72,7 @@ fun Context.updateListWidget() {
sendBroadcast(this) sendBroadcast(this)
} }
} }
AppWidgetManager.getInstance(applicationContext)?.notifyAppWidgetViewDataChanged(widgetIDs, R.id.widget_event_list)
} }
fun Context.updateDateWidget() { fun Context.updateDateWidget() {