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)
|
if (event.repeatInterval == DAY)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
val dateTime = Formatter.getDateTimeFromTS(startTS + reminderSeconds)
|
return !(startTS + reminderSeconds).isTsOnValidDay(event)
|
||||||
val power = Math.pow(2.0, (dateTime.dayOfWeek - 1).toDouble()).toInt()
|
|
||||||
return event.repeatRule and power == 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getNewTS(ts: Int, isMonthly: Boolean): Int {
|
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.text.TextUtils
|
||||||
import android.util.SparseIntArray
|
import android.util.SparseIntArray
|
||||||
import com.simplemobiletools.calendar.R
|
import com.simplemobiletools.calendar.R
|
||||||
import com.simplemobiletools.calendar.extensions.config
|
import com.simplemobiletools.calendar.extensions.*
|
||||||
import com.simplemobiletools.calendar.extensions.scheduleReminder
|
|
||||||
import com.simplemobiletools.calendar.extensions.seconds
|
|
||||||
import com.simplemobiletools.calendar.extensions.updateWidgets
|
|
||||||
import com.simplemobiletools.calendar.models.Event
|
import com.simplemobiletools.calendar.models.Event
|
||||||
import com.simplemobiletools.calendar.models.EventType
|
import com.simplemobiletools.calendar.models.EventType
|
||||||
import com.simplemobiletools.commons.extensions.getIntValue
|
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)) {
|
while (it.startTS < toTS && (it.repeatLimit == 0 || it.repeatLimit >= it.startTS)) {
|
||||||
if (it.startTS >= fromTS) {
|
if (it.startTS >= fromTS) {
|
||||||
if (it.repeatInterval % WEEK == 0) {
|
if (it.repeatInterval % WEEK == 0) {
|
||||||
val dateTime = Formatter.getDateTimeFromTS(it.startTS)
|
if (it.startTS.isTsOnValidDay(it)) {
|
||||||
val power = Math.pow(2.0, (dateTime.dayOfWeek - 1).toDouble()).toInt()
|
|
||||||
if (it.repeatRule and power != 0) {
|
|
||||||
newEvents.add(it.copy())
|
newEvents.add(it.copy())
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue