use a helper function for checking if the timestamp is at a valid day
This commit is contained in:
parent
005fa01001
commit
31e5c72a87
|
@ -85,9 +85,7 @@ private fun isWrongDay(event: Event, startTS: Int, reminderSeconds: Int): Boolea
|
|||
if (event.repeatInterval == DAY)
|
||||
return false
|
||||
|
||||
val dateTime = Formatter.getDateTimeFromTS(startTS + reminderSeconds)
|
||||
val power = Math.pow(2.0, (dateTime.dayOfWeek - 1).toDouble()).toInt()
|
||||
return event.repeatRule and power == 0
|
||||
return !(startTS + reminderSeconds).isTsOnValidDay(event)
|
||||
}
|
||||
|
||||
private fun getNewTS(ts: Int, isMonthly: Boolean): Int {
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package com.simplemobiletools.calendar.extensions
|
||||
|
||||
import com.simplemobiletools.calendar.helpers.Formatter
|
||||
import com.simplemobiletools.calendar.models.Event
|
||||
|
||||
fun Int.isTsOnValidDay(event: Event): Boolean {
|
||||
val dateTime = Formatter.getDateTimeFromTS(this)
|
||||
val power = Math.pow(2.0, (dateTime.dayOfWeek - 1).toDouble()).toInt()
|
||||
return event.repeatRule and power != 0
|
||||
}
|
|
@ -10,10 +10,7 @@ import android.database.sqlite.SQLiteQueryBuilder
|
|||
import android.text.TextUtils
|
||||
import android.util.SparseIntArray
|
||||
import com.simplemobiletools.calendar.R
|
||||
import com.simplemobiletools.calendar.extensions.config
|
||||
import com.simplemobiletools.calendar.extensions.scheduleReminder
|
||||
import com.simplemobiletools.calendar.extensions.seconds
|
||||
import com.simplemobiletools.calendar.extensions.updateWidgets
|
||||
import com.simplemobiletools.calendar.extensions.*
|
||||
import com.simplemobiletools.calendar.models.Event
|
||||
import com.simplemobiletools.calendar.models.EventType
|
||||
import com.simplemobiletools.commons.extensions.getIntValue
|
||||
|
@ -388,9 +385,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||
while (it.startTS < toTS && (it.repeatLimit == 0 || it.repeatLimit >= it.startTS)) {
|
||||
if (it.startTS >= fromTS) {
|
||||
if (it.repeatInterval % WEEK == 0) {
|
||||
val dateTime = Formatter.getDateTimeFromTS(it.startTS)
|
||||
val power = Math.pow(2.0, (dateTime.dayOfWeek - 1).toDouble()).toInt()
|
||||
if (it.repeatRule and power != 0) {
|
||||
if (it.startTS.isTsOnValidDay(it)) {
|
||||
newEvents.add(it.copy())
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue