add a helper function for scheduling all future events

This commit is contained in:
tibbi 2017-04-23 22:52:16 +02:00
parent b6806dfbe2
commit 9735bcf0c0
2 changed files with 9 additions and 6 deletions

View File

@ -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

View File

@ -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()
}
}