filter events by the repeat limit when appropriate

This commit is contained in:
tibbi 2017-02-05 22:50:38 +01:00
parent 69306551d2
commit 6658542236
2 changed files with 2 additions and 2 deletions

View File

@ -55,7 +55,7 @@ fun Context.scheduleNextEvent(event: Event) {
newTS = getNewTS(startTS, false) newTS = getNewTS(startTS, false)
} }
if (newTS != 0) if (newTS != 0 && (event.repeatLimit == 0 || event.repeatLimit > newTS))
scheduleEventIn(newTS, event) scheduleEventIn(newTS, event)
} }

View File

@ -218,7 +218,7 @@ class DBHelper(context: Context) : SQLiteOpenHelper(context, DB_NAME, null, DB_V
val selection = "$COL_REPEAT_INTERVAL != 0 AND $COL_START_TS < $toTS" val selection = "$COL_REPEAT_INTERVAL != 0 AND $COL_START_TS < $toTS"
val events = getEvents(selection) val events = getEvents(selection)
for (e in events) { for (e in events) {
while (e.startTS < toTS) { while (e.startTS < toTS && (e.repeatLimit == 0 || e.repeatLimit > e.endTS)) {
if (e.startTS > fromTS) { if (e.startTS > fromTS) {
val newEvent = Event(e.id, e.startTS, e.endTS, e.title, e.description, e.reminderMinutes, e.repeatInterval, e.importId, e.flags) val newEvent = Event(e.id, e.startTS, e.endTS, e.title, e.description, e.reminderMinutes, e.repeatInterval, e.importId, e.flags)
newEvents.add(newEvent) newEvents.add(newEvent)