From 0a24dcbc31a9f7a5771696e2c7579fc83d385d99 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 23 Apr 2017 19:57:19 +0200 Subject: [PATCH] some fixes to weekly repeating events repeating x times --- .../calendar/helpers/DBHelper.kt | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) 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 0afc08936..9baa265ff 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt @@ -404,17 +404,27 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont } } else { // events repeating x times - while (it.repeatLimit < 0) { - if (it.startTS >= fromTS && it.startTS < toTS) { - newEvents.add(it.copy()) + while (it.repeatLimit < 0 && it.endTS < toTS) { + if (it.repeatInterval != 0 && it.repeatInterval % WEEK == 0) { + if (it.startTS >= fromTS && it.startTS < toTS) { + if (it.startTS.isTsOnValidDay(it)) { + newEvents.add(it.copy()) + it.repeatLimit++ + } + } + it.addIntervalTime() + } else { + if (it.startTS >= fromTS && it.startTS < toTS) { + newEvents.add(it.copy()) + } + it.addIntervalTime() + it.repeatLimit++ } - it.addIntervalTime() - it.repeatLimit++ } } } - // check if weekly repeatable events are on the current day + // check if weekly repeatable events are on the correct day val filteredEvents = ArrayList(newEvents.size) newEvents.forEach { if (it.repeatInterval != 0 && it.repeatInterval % WEEK == 0) {