mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
removing the ignoredEventOccurrences field of Event
This commit is contained in:
@@ -221,7 +221,6 @@ class CalDAVHandler(val context: Context) {
|
||||
existingEvent.apply {
|
||||
this.id = null
|
||||
color = 0
|
||||
ignoreEventOccurrences = ArrayList()
|
||||
lastUpdated = 0L
|
||||
offset = ""
|
||||
}
|
||||
|
@@ -607,12 +607,15 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
||||
events = events
|
||||
.asSequence()
|
||||
.distinct()
|
||||
.filterNot { it.ignoreEventOccurrences.contains(Formatter.getDayCodeFromTS(it.startTS).toInt()) }
|
||||
.filterNot { getIgnoredOccurrences(it).contains(Formatter.getDayCodeFromTS(it.startTS).toInt()) }
|
||||
.toMutableList() as ArrayList<Event>
|
||||
callback(events)
|
||||
}
|
||||
|
||||
fun getRepeatableEventsFor(fromTS: Int, toTS: Int, eventId: Long = -1L, applyTypeFilter: Boolean = false): List<Event> {
|
||||
if (isOnMainThread()) {
|
||||
Log.e("DEBUG", "dbhelper getRepeatableEventsFor")
|
||||
}
|
||||
val newEvents = ArrayList<Event>()
|
||||
|
||||
var selection = "$COL_REPEAT_INTERVAL != 0 AND $COL_START_TS <= $toTS AND $COL_START_TS != 0"
|
||||
@@ -857,19 +860,13 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
||||
val color = eventTypeColors.get(eventType)!!
|
||||
val isPastEvent = false
|
||||
|
||||
val ignoreEventOccurrences = if (repeatInterval != 0) {
|
||||
getIgnoredOccurrences(id)
|
||||
} else {
|
||||
ArrayList()
|
||||
}
|
||||
|
||||
if (repeatInterval > 0 && repeatRule == 0 && (repeatInterval % MONTH == 0 || repeatInterval % YEAR == 0)) {
|
||||
repeatRule = REPEAT_SAME_DAY
|
||||
}
|
||||
|
||||
val event = Event(id, startTS, endTS, title, description, reminder1Minutes, reminder2Minutes, reminder3Minutes,
|
||||
repeatInterval, importId, flags, repeatLimit, repeatRule, eventType, ignoreEventOccurrences, offset, isDstIncluded,
|
||||
0, lastUpdated, source, color, location, isPastEvent)
|
||||
repeatInterval, importId, flags, repeatLimit, repeatRule, eventType, offset, isDstIncluded, 0, lastUpdated,
|
||||
source, color, location, isPastEvent)
|
||||
event.isPastEvent = getIsPastEvent(event)
|
||||
|
||||
events.add(event)
|
||||
@@ -928,10 +925,14 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
||||
}.start()
|
||||
}
|
||||
|
||||
private fun getIgnoredOccurrences(eventId: Long): ArrayList<Int> {
|
||||
fun getIgnoredOccurrences(event: Event): ArrayList<Int> {
|
||||
if (event.repeatInterval == 0) {
|
||||
return ArrayList()
|
||||
}
|
||||
|
||||
val projection = arrayOf(COL_OCCURRENCE_DAYCODE)
|
||||
val selection = "$COL_PARENT_EVENT_ID = ?"
|
||||
val selectionArgs = arrayOf(eventId.toString())
|
||||
val selectionArgs = arrayOf(event.id.toString())
|
||||
val daycodes = ArrayList<Int>()
|
||||
|
||||
var cursor: Cursor? = null
|
||||
|
@@ -58,7 +58,7 @@ class IcsExporter {
|
||||
Parser().getRepeatCode(event).let { if (it.isNotEmpty()) out.writeLn("$RRULE$it") }
|
||||
|
||||
fillReminders(event, out)
|
||||
fillIgnoredOccurrences(event, out)
|
||||
fillIgnoredOccurrences(activity, event, out)
|
||||
|
||||
eventsExported++
|
||||
out.writeLn(END_EVENT)
|
||||
@@ -91,9 +91,9 @@ class IcsExporter {
|
||||
}
|
||||
}
|
||||
|
||||
private fun fillIgnoredOccurrences(event: Event, out: BufferedWriter) {
|
||||
event.ignoreEventOccurrences.forEach {
|
||||
out.writeLn("$EXDATE:$it}")
|
||||
private fun fillIgnoredOccurrences(activity: BaseSimpleActivity, event: Event, out: BufferedWriter) {
|
||||
activity.dbHelper.getIgnoredOccurrences(event).forEach {
|
||||
out.writeLn("$EXDATE:$it")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -2,17 +2,14 @@ package com.simplemobiletools.calendar.pro.models
|
||||
|
||||
import com.simplemobiletools.calendar.pro.extensions.seconds
|
||||
import com.simplemobiletools.calendar.pro.helpers.*
|
||||
import com.simplemobiletools.calendar.pro.helpers.Formatter
|
||||
import org.joda.time.DateTime
|
||||
import java.io.Serializable
|
||||
import java.util.*
|
||||
|
||||
data class Event(var id: Long?, var startTS: Int = 0, var endTS: Int = 0, var title: String = "", var description: String = "",
|
||||
var reminder1Minutes: Int = -1, var reminder2Minutes: Int = -1, var reminder3Minutes: Int = -1, var repeatInterval: Int = 0,
|
||||
var importId: String = "", var flags: Int = 0, var repeatLimit: Int = 0, var repeatRule: Int = 0,
|
||||
var eventType: Long = DBHelper.REGULAR_EVENT_TYPE_ID, var ignoreEventOccurrences: ArrayList<Int> = ArrayList(),
|
||||
var offset: String = "", var isDstIncluded: Boolean = false, var parentId: Long = 0, var lastUpdated: Long = 0L,
|
||||
var source: String = SOURCE_SIMPLE_CALENDAR, var color: Int = 0, var location: String = "", var isPastEvent: Boolean = false)
|
||||
var eventType: Long = DBHelper.REGULAR_EVENT_TYPE_ID, var offset: String = "", var isDstIncluded: Boolean = false, var parentId: Long = 0,
|
||||
var lastUpdated: Long = 0L, var source: String = SOURCE_SIMPLE_CALENDAR, var color: Int = 0, var location: String = "", var isPastEvent: Boolean = false)
|
||||
: Serializable {
|
||||
|
||||
companion object {
|
||||
|
@@ -34,7 +34,7 @@ class NotificationReceiver : BroadcastReceiver() {
|
||||
return
|
||||
}
|
||||
|
||||
if (!event.ignoreEventOccurrences.contains(Formatter.getDayCodeFromTS(event.startTS).toInt())) {
|
||||
if (!context.dbHelper.getIgnoredOccurrences(event).contains(Formatter.getDayCodeFromTS(event.startTS).toInt())) {
|
||||
context.notifyEvent(event)
|
||||
}
|
||||
context.scheduleNextEventReminder(event, context.dbHelper)
|
||||
|
Reference in New Issue
Block a user