use a helper function for checking KITKAT

This commit is contained in:
tibbi 2017-05-14 22:12:30 +02:00
parent 514f660c8a
commit 34f83f74bf
1 changed files with 3 additions and 1 deletions

View File

@ -19,6 +19,7 @@ import com.simplemobiletools.calendar.helpers.*
import com.simplemobiletools.calendar.models.Event
import com.simplemobiletools.calendar.receivers.NotificationReceiver
import com.simplemobiletools.commons.extensions.getContrastColor
import com.simplemobiletools.commons.extensions.isKitkatPlus
import com.simplemobiletools.commons.extensions.isLollipopPlus
import org.joda.time.DateTime
import org.joda.time.DateTimeZone
@ -121,7 +122,8 @@ fun Context.scheduleEventIn(notifTS: Int, event: Event) {
val notifInMs = SystemClock.elapsedRealtime() + delayFromNow
val pendingIntent = getNotificationIntent(this, event.id)
val alarmManager = getSystemService(Context.ALARM_SERVICE) as AlarmManager
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
if (isKitkatPlus())
alarmManager.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, notifInMs, pendingIntent)
else
alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, notifInMs, pendingIntent)