fix the reminder of daily and weekly events
This commit is contained in:
parent
e9901c851f
commit
9e4ab1e667
|
@ -66,8 +66,8 @@ fun Context.scheduleNextEventReminder(event: Event) {
|
||||||
reminderSeconds.forEach {
|
reminderSeconds.forEach {
|
||||||
var startTS = event.startTS - it
|
var startTS = event.startTS - it
|
||||||
if (event.repeatInterval == DAY || (event.repeatInterval != 0 && event.repeatInterval % WEEK == 0)) {
|
if (event.repeatInterval == DAY || (event.repeatInterval != 0 && event.repeatInterval % WEEK == 0)) {
|
||||||
while (startTS < now || isOccurrenceIgnored(event, startTS, it) || isWrongDay(event, startTS, it)) {
|
while (startTS < now || isOccurrenceIgnored(event, startTS, it) || !isCorrectDay(event, startTS, it)) {
|
||||||
startTS += DAY
|
startTS = Formatter.getDateTimeFromTS(startTS).plusDays(1).seconds()
|
||||||
}
|
}
|
||||||
nextTS = Math.min(nextTS, startTS)
|
nextTS = Math.min(nextTS, startTS)
|
||||||
} else if (event.repeatInterval == MONTH) {
|
} 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())
|
return event.ignoreEventOccurrences.contains(Formatter.getDayCodeFromTS(startTS + reminderSeconds).toInt())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isWrongDay(event: Event, startTS: Int, reminderSeconds: Int): Boolean {
|
private fun isCorrectDay(event: Event, startTS: Int, reminderSeconds: Int): Boolean {
|
||||||
if (event.repeatInterval == DAY)
|
return if (event.repeatInterval == DAY)
|
||||||
return false
|
true
|
||||||
|
else
|
||||||
return !(startTS + reminderSeconds).isTsOnProperDay(event)
|
(startTS + reminderSeconds).isTsOnProperDay(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getNewTS(ts: Int, isMonthly: Boolean): Int {
|
private fun getNewTS(ts: Int, isMonthly: Boolean): Int {
|
||||||
|
|
Loading…
Reference in New Issue