From 9e4ab1e6677ba8aa5cb590691025157ffb9c1da1 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 5 May 2017 22:18:28 +0200 Subject: [PATCH] fix the reminder of daily and weekly events --- .../calendar/extensions/Context.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 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 dc7f93388..557ce800b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt @@ -66,8 +66,8 @@ fun Context.scheduleNextEventReminder(event: Event) { reminderSeconds.forEach { var startTS = event.startTS - it if (event.repeatInterval == DAY || (event.repeatInterval != 0 && event.repeatInterval % WEEK == 0)) { - while (startTS < now || isOccurrenceIgnored(event, startTS, it) || isWrongDay(event, startTS, it)) { - startTS += DAY + while (startTS < now || isOccurrenceIgnored(event, startTS, it) || !isCorrectDay(event, startTS, it)) { + startTS = Formatter.getDateTimeFromTS(startTS).plusDays(1).seconds() } nextTS = Math.min(nextTS, startTS) } else if (event.repeatInterval == MONTH) { @@ -93,11 +93,11 @@ private fun isOccurrenceIgnored(event: Event, startTS: Int, reminderSeconds: Int return event.ignoreEventOccurrences.contains(Formatter.getDayCodeFromTS(startTS + reminderSeconds).toInt()) } -private fun isWrongDay(event: Event, startTS: Int, reminderSeconds: Int): Boolean { - if (event.repeatInterval == DAY) - return false - - return !(startTS + reminderSeconds).isTsOnProperDay(event) +private fun isCorrectDay(event: Event, startTS: Int, reminderSeconds: Int): Boolean { + return if (event.repeatInterval == DAY) + true + else + (startTS + reminderSeconds).isTsOnProperDay(event) } private fun getNewTS(ts: Int, isMonthly: Boolean): Int {