mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-02-18 20:50:40 +01:00
add the initial implementation of events repeating x times
This commit is contained in:
parent
0e557ca7a6
commit
2fe79374e8
@ -388,6 +388,8 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||||||
val startTimes = SparseIntArray(events.size)
|
val startTimes = SparseIntArray(events.size)
|
||||||
events.forEach {
|
events.forEach {
|
||||||
startTimes.put(it.id, it.startTS)
|
startTimes.put(it.id, it.startTS)
|
||||||
|
if (it.repeatLimit >= 0) {
|
||||||
|
// events repeating by x days etc
|
||||||
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) {
|
||||||
@ -402,8 +404,17 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||||||
}
|
}
|
||||||
it.addIntervalTime()
|
it.addIntervalTime()
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// events repeating x times
|
||||||
|
while (it.startTS < toTS && it.repeatLimit < 0) {
|
||||||
|
newEvents.add(it.copy())
|
||||||
|
it.addIntervalTime()
|
||||||
|
it.repeatLimit++
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if weekly repeatable events are on the current day
|
||||||
val filteredEvents = ArrayList<Event>(newEvents.size)
|
val filteredEvents = ArrayList<Event>(newEvents.size)
|
||||||
newEvents.forEach {
|
newEvents.forEach {
|
||||||
if (it.repeatInterval != 0 && it.repeatInterval % WEEK == 0) {
|
if (it.repeatInterval != 0 && it.repeatInterval % WEEK == 0) {
|
||||||
@ -506,7 +517,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||||||
do {
|
do {
|
||||||
val id = cursor.getIntValue(COL_ID)
|
val id = cursor.getIntValue(COL_ID)
|
||||||
val startTS = cursor.getIntValue(COL_START_TS)
|
val startTS = cursor.getIntValue(COL_START_TS)
|
||||||
var endTS = cursor.getIntValue(COL_END_TS)
|
val endTS = cursor.getIntValue(COL_END_TS)
|
||||||
val reminder1Minutes = cursor.getIntValue(COL_REMINDER_MINUTES)
|
val reminder1Minutes = cursor.getIntValue(COL_REMINDER_MINUTES)
|
||||||
val reminder2Minutes = cursor.getIntValue(COL_REMINDER_MINUTES_2)
|
val reminder2Minutes = cursor.getIntValue(COL_REMINDER_MINUTES_2)
|
||||||
val reminder3Minutes = cursor.getIntValue(COL_REMINDER_MINUTES_3)
|
val reminder3Minutes = cursor.getIntValue(COL_REMINDER_MINUTES_3)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user