show daily repeating events only on appropriate days

This commit is contained in:
tibbi 2017-04-15 19:12:09 +02:00
parent fbf542df3e
commit 2c19f0bcb5
1 changed files with 9 additions and 1 deletions

View File

@ -384,7 +384,15 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
for (event in events) { for (event in events) {
while (event.startTS < toTS && (event.repeatLimit == 0 || event.repeatLimit >= event.startTS)) { while (event.startTS < toTS && (event.repeatLimit == 0 || event.repeatLimit >= event.startTS)) {
if (event.startTS >= fromTS) { if (event.startTS >= fromTS) {
newEvents.add(event.copy()) if (event.repeatInterval == DAY) {
val dateTime = Formatter.getDateTimeFromTS(event.startTS)
val power = Math.pow(2.0, (dateTime.dayOfWeek - 1).toDouble()).toInt()
if (event.repeatRule and power != 0) {
newEvents.add(event.copy())
}
} else {
newEvents.add(event.copy())
}
} else if (getRunningEvents && (event.startTS <= fromTS && event.endTS >= toTS)) { } else if (getRunningEvents && (event.startTS <= fromTS && event.endTS >= toTS)) {
newEvents.add(event.copy()) newEvents.add(event.copy())
} }