mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Null pending intent check
This commit is contained in:
parent
299deff230
commit
4c617ce94c
2 changed files with 7 additions and 3 deletions
|
@ -25,7 +25,7 @@ object PendingIntentUtils {
|
|||
requestCode: Int,
|
||||
intent: Intent,
|
||||
flags: Int,
|
||||
): PendingIntent = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
): PendingIntent? = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
PendingIntent.getBroadcast(context, requestCode, intent, flags or PendingIntent.FLAG_IMMUTABLE)
|
||||
} else {
|
||||
PendingIntent.getBroadcast(context, requestCode, intent, flags)
|
||||
|
|
|
@ -31,7 +31,9 @@ object WidgetUtils {
|
|||
val pendingIntent = getImmutableBroadcast(context, RC_WIDGET_UPDATE, intent, PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
val widgetUpdateInterval = 1000 * 60 * 5
|
||||
val startAlarmAt = SystemClock.currentThreadTimeMillis() + widgetUpdateInterval
|
||||
alarmManager.setInexactRepeating(AlarmManager.RTC, startAlarmAt, widgetUpdateInterval.toLong(), pendingIntent)
|
||||
pendingIntent?.let {
|
||||
alarmManager.setInexactRepeating(AlarmManager.RTC, startAlarmAt, widgetUpdateInterval.toLong(), it)
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
|
@ -39,7 +41,9 @@ object WidgetUtils {
|
|||
Log.d(this.javaClass.name, "disableWidgetUpdate")
|
||||
val alarmManager = context.getSystemService(AlarmManager::class.java)
|
||||
val pendingIntent = getImmutableBroadcast(context, RC_WIDGET_UPDATE, getUpdateIntent(context), PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
alarmManager.cancel(pendingIntent)
|
||||
pendingIntent?.let {
|
||||
alarmManager.cancel(it)
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
|
|
Loading…
Add table
Reference in a new issue