From 66585422365e0f27f9efda37a3c6e8ffcf25f0f1 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 5 Feb 2017 22:50:38 +0100 Subject: [PATCH] filter events by the repeat limit when appropriate --- .../kotlin/com/simplemobiletools/calendar/extensions/Context.kt | 2 +- .../kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt index 4fcf6393a..aabcee3ba 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt @@ -55,7 +55,7 @@ fun Context.scheduleNextEvent(event: Event) { newTS = getNewTS(startTS, false) } - if (newTS != 0) + if (newTS != 0 && (event.repeatLimit == 0 || event.repeatLimit > newTS)) scheduleEventIn(newTS, event) } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt index b5bafa576..a685dc460 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt @@ -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 events = getEvents(selection) for (e in events) { - while (e.startTS < toTS) { + while (e.startTS < toTS && (e.repeatLimit == 0 || e.repeatLimit > e.endTS)) { 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) newEvents.add(newEvent)