mirror of
https://github.com/SimpleMobileTools/Simple-Clock.git
synced 2024-12-14 01:04:50 +01:00
adding some widget related null checks
This commit is contained in:
parent
56a5ebabbe
commit
17c436b383
@ -160,7 +160,7 @@ fun Context.hideNotification(id: Int) {
|
||||
fun Context.hideTimerNotification() = hideNotification(TIMER_NOTIF_ID)
|
||||
|
||||
fun Context.updateWidgets() {
|
||||
val widgetsCnt = AppWidgetManager.getInstance(applicationContext).getAppWidgetIds(ComponentName(applicationContext, MyWidgetDateTimeProvider::class.java))
|
||||
val widgetsCnt = AppWidgetManager.getInstance(applicationContext)?.getAppWidgetIds(ComponentName(applicationContext, MyWidgetDateTimeProvider::class.java)) ?: return
|
||||
if (widgetsCnt.isNotEmpty()) {
|
||||
val ids = intArrayOf(R.xml.widget_date_time_info)
|
||||
Intent(applicationContext, MyWidgetDateTimeProvider::class.java).apply {
|
||||
@ -173,7 +173,7 @@ fun Context.updateWidgets() {
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
fun Context.scheduleNextWidgetUpdate() {
|
||||
val widgetsCnt = AppWidgetManager.getInstance(applicationContext).getAppWidgetIds(ComponentName(applicationContext, MyWidgetDateTimeProvider::class.java))
|
||||
val widgetsCnt = AppWidgetManager.getInstance(applicationContext)?.getAppWidgetIds(ComponentName(applicationContext, MyWidgetDateTimeProvider::class.java)) ?: return
|
||||
if (widgetsCnt.isEmpty()) {
|
||||
return
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ class MyWidgetDateTimeProvider : AppWidgetProvider() {
|
||||
}
|
||||
|
||||
private fun performUpdate(context: Context) {
|
||||
val appWidgetManager = AppWidgetManager.getInstance(context)
|
||||
val appWidgetManager = AppWidgetManager.getInstance(context) ?: return
|
||||
appWidgetManager.getAppWidgetIds(getComponentName(context)).forEach {
|
||||
RemoteViews(context.packageName, getProperLayout(context)).apply {
|
||||
updateTexts(context, this)
|
||||
|
Loading…
Reference in New Issue
Block a user