mirror of
https://github.com/SimpleMobileTools/Simple-Clock.git
synced 2025-05-24 23:14:19 +02: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.hideTimerNotification() = hideNotification(TIMER_NOTIF_ID)
|
||||||
|
|
||||||
fun Context.updateWidgets() {
|
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()) {
|
if (widgetsCnt.isNotEmpty()) {
|
||||||
val ids = intArrayOf(R.xml.widget_date_time_info)
|
val ids = intArrayOf(R.xml.widget_date_time_info)
|
||||||
Intent(applicationContext, MyWidgetDateTimeProvider::class.java).apply {
|
Intent(applicationContext, MyWidgetDateTimeProvider::class.java).apply {
|
||||||
@ -173,7 +173,7 @@ fun Context.updateWidgets() {
|
|||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
fun Context.scheduleNextWidgetUpdate() {
|
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()) {
|
if (widgetsCnt.isEmpty()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ class MyWidgetDateTimeProvider : AppWidgetProvider() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun performUpdate(context: Context) {
|
private fun performUpdate(context: Context) {
|
||||||
val appWidgetManager = AppWidgetManager.getInstance(context)
|
val appWidgetManager = AppWidgetManager.getInstance(context) ?: return
|
||||||
appWidgetManager.getAppWidgetIds(getComponentName(context)).forEach {
|
appWidgetManager.getAppWidgetIds(getComponentName(context)).forEach {
|
||||||
RemoteViews(context.packageName, getProperLayout(context)).apply {
|
RemoteViews(context.packageName, getProperLayout(context)).apply {
|
||||||
updateTexts(context, this)
|
updateTexts(context, this)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user