change the way we obtain widget IDs
This commit is contained in:
parent
2b71625de5
commit
1da9c0e268
|
@ -47,12 +47,11 @@ val Context.dbHelper: DBHelper get() = DBHelper.newInstance(applicationContext)
|
||||||
fun Context.getNowSeconds() = (System.currentTimeMillis() / 1000).toInt()
|
fun Context.getNowSeconds() = (System.currentTimeMillis() / 1000).toInt()
|
||||||
|
|
||||||
fun Context.updateWidgets() {
|
fun Context.updateWidgets() {
|
||||||
val widgetsCnt = AppWidgetManager.getInstance(applicationContext).getAppWidgetIds(ComponentName(applicationContext, MyWidgetMonthlyProvider::class.java))
|
val widgetIDs = AppWidgetManager.getInstance(applicationContext).getAppWidgetIds(ComponentName(applicationContext, MyWidgetMonthlyProvider::class.java))
|
||||||
if (widgetsCnt.isNotEmpty()) {
|
if (widgetIDs.isNotEmpty()) {
|
||||||
val ids = intArrayOf(R.xml.widget_monthly_info)
|
|
||||||
Intent(applicationContext, MyWidgetMonthlyProvider::class.java).apply {
|
Intent(applicationContext, MyWidgetMonthlyProvider::class.java).apply {
|
||||||
action = AppWidgetManager.ACTION_APPWIDGET_UPDATE
|
action = AppWidgetManager.ACTION_APPWIDGET_UPDATE
|
||||||
putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids)
|
putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, widgetIDs)
|
||||||
sendBroadcast(this)
|
sendBroadcast(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,12 +60,11 @@ fun Context.updateWidgets() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.updateListWidget() {
|
fun Context.updateListWidget() {
|
||||||
val widgetsCnt = AppWidgetManager.getInstance(applicationContext).getAppWidgetIds(ComponentName(applicationContext, MyWidgetListProvider::class.java))
|
val widgetIDs = AppWidgetManager.getInstance(applicationContext).getAppWidgetIds(ComponentName(applicationContext, MyWidgetListProvider::class.java))
|
||||||
if (widgetsCnt.isNotEmpty()) {
|
if (widgetIDs.isNotEmpty()) {
|
||||||
val ids = intArrayOf(R.xml.widget_list_info)
|
|
||||||
Intent(applicationContext, MyWidgetListProvider::class.java).apply {
|
Intent(applicationContext, MyWidgetListProvider::class.java).apply {
|
||||||
action = AppWidgetManager.ACTION_APPWIDGET_UPDATE
|
action = AppWidgetManager.ACTION_APPWIDGET_UPDATE
|
||||||
putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids)
|
putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, widgetIDs)
|
||||||
sendBroadcast(this)
|
sendBroadcast(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue