add a helper function for scheduling all future events
This commit is contained in:
parent
b6806dfbe2
commit
9735bcf0c0
|
@ -47,6 +47,13 @@ fun Context.updateListWidget() {
|
|||
}
|
||||
}
|
||||
|
||||
fun Context.scheduleAllEvents() {
|
||||
val events = dbHelper.getEventsAtReboot()
|
||||
events.forEach {
|
||||
scheduleNextEventReminder(it)
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.scheduleNextEventReminder(event: Event) {
|
||||
if (event.getReminders().isEmpty())
|
||||
return
|
||||
|
|
|
@ -3,17 +3,13 @@ package com.simplemobiletools.calendar.receivers
|
|||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.simplemobiletools.calendar.extensions.dbHelper
|
||||
import com.simplemobiletools.calendar.extensions.notifyRunningEvents
|
||||
import com.simplemobiletools.calendar.extensions.scheduleNextEventReminder
|
||||
import com.simplemobiletools.calendar.extensions.scheduleAllEvents
|
||||
|
||||
class BootCompletedReceiver : BroadcastReceiver() {
|
||||
|
||||
override fun onReceive(context: Context, arg1: Intent) {
|
||||
val events = context.dbHelper.getEventsAtReboot()
|
||||
for (event in events) {
|
||||
context.scheduleNextEventReminder(event)
|
||||
}
|
||||
context.scheduleAllEvents()
|
||||
context.notifyRunningEvents()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue