From b8c21034314b0461293eecc881c2888baa430eba Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 6 Feb 2017 21:10:39 +0100 Subject: [PATCH] dont count event reminders as a jerk --- .../calendar/extensions/Context.kt | 3 +++ .../com/simplemobiletools/calendar/models/Event.kt | 13 ++----------- 2 files changed, 5 insertions(+), 11 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 50d58a115..fdc44e0b5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt @@ -42,6 +42,9 @@ fun Context.updateListWidget() { } fun Context.scheduleNextEventReminder(event: Event) { + if (event.getReminders().isEmpty()) + return + var startTS = event.startTS - event.reminder1Minutes * 60 var newTS = startTS if (event.repeatInterval == DAY || event.repeatInterval == WEEK || event.repeatInterval == BIWEEK) { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/models/Event.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/models/Event.kt index 6d514c291..22038715a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/models/Event.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/models/Event.kt @@ -31,16 +31,7 @@ data class Event(var id: Int = 0, var startTS: Int = 0, var endTS: Int = 0, var val isAllDay = flags and FLAG_ALL_DAY != 0 - fun getRemindersCount(): Int { - var cnt = 0 - if (reminder1Minutes != REMINDER_OFF) - cnt++ - if (reminder2Minutes != REMINDER_OFF) - cnt++ - if (reminder3Minutes != REMINDER_OFF) - cnt++ - return cnt - } + fun getRemindersCount() = getReminders().count() - fun getReminders() = arrayOf(reminder1Minutes, reminder2Minutes, reminder3Minutes).filter { it != REMINDER_OFF } + fun getReminders() = setOf(reminder1Minutes, reminder2Minutes, reminder3Minutes).filter { it != REMINDER_OFF } }