properly reschedule repeating event if an exception has been added

This commit is contained in:
tibbi 2018-01-10 14:26:29 +01:00
parent 41ab749abb
commit 8229735f63
2 changed files with 6 additions and 2 deletions

View File

@ -66,9 +66,10 @@ fun Context.scheduleAllEvents() {
}
}
fun Context.scheduleNextEventReminder(event: Event, dbHelper: DBHelper) {
if (event.getReminders().isEmpty())
fun Context.scheduleNextEventReminder(event: Event?, dbHelper: DBHelper) {
if (event == null || event.getReminders().isEmpty()) {
return
}
val now = (System.currentTimeMillis() / 1000).toInt()
val reminderSeconds = event.getReminders().reversed().map { it * 60 }

View File

@ -495,6 +495,9 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
fun addEventRepeatException(parentEventId: Int, occurrenceTS: Int) {
fillExceptionValues(parentEventId, occurrenceTS) {
mDb.insert(EXCEPTIONS_TABLE_NAME, null, it)
val parentEvent = getEventWithId(parentEventId)
context.scheduleNextEventReminder(parentEvent, this)
}
}