mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
add an empty helper function for updating caldav events
This commit is contained in:
@@ -532,7 +532,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
|||||||
if (mRepeatInterval > 0 && wasRepeatable) {
|
if (mRepeatInterval > 0 && wasRepeatable) {
|
||||||
EditRepeatingEventDialog(this) {
|
EditRepeatingEventDialog(this) {
|
||||||
if (it) {
|
if (it) {
|
||||||
dbHelper.update(mEvent) {
|
dbHelper.update(mEvent, true) {
|
||||||
eventUpdated()
|
eventUpdated()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -546,7 +546,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dbHelper.update(mEvent) {
|
dbHelper.update(mEvent, true) {
|
||||||
eventUpdated()
|
eventUpdated()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -142,11 +142,11 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
|
|
||||||
Thread({
|
Thread({
|
||||||
if (newCalendarIds.isNotEmpty()) {
|
if (newCalendarIds.isNotEmpty()) {
|
||||||
val eventTypeNames = dbHelper.fetchEventTypes().map { it.title.toLowerCase() } as ArrayList<String>
|
val existingEventTypeNames = dbHelper.fetchEventTypes().map { it.title.toLowerCase() } as ArrayList<String>
|
||||||
getSyncedCalDAVCalendars().forEach {
|
getSyncedCalDAVCalendars().forEach {
|
||||||
if (!eventTypeNames.contains(it.displayName.toLowerCase())) {
|
if (!existingEventTypeNames.contains(it.displayName.toLowerCase())) {
|
||||||
val eventType = EventType(0, it.displayName, it.color, it.id)
|
val eventType = EventType(0, it.displayName, it.color, it.id)
|
||||||
eventTypeNames.add(it.displayName.toLowerCase())
|
existingEventTypeNames.add(it.displayName.toLowerCase())
|
||||||
dbHelper.insertEventType(eventType)
|
dbHelper.insertEventType(eventType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -120,7 +120,7 @@ class CalDAVEventsHandler(val context: Context) {
|
|||||||
existingEvent.id = 0
|
existingEvent.id = 0
|
||||||
if (existingEvent.hashCode() != event.hashCode()) {
|
if (existingEvent.hashCode() != event.hashCode()) {
|
||||||
event.id = originalEventId
|
event.id = originalEventId
|
||||||
context.dbHelper.update(event) {
|
context.dbHelper.update(event, false) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -149,7 +149,7 @@ class CalDAVEventsHandler(val context: Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addCalDAVEvent(event: Event) {
|
fun insertCalDAVEvent(event: Event) {
|
||||||
val calendarId = event.getCalDAVCalendarId()
|
val calendarId = event.getCalDAVCalendarId()
|
||||||
val uri = CalendarContract.Events.CONTENT_URI
|
val uri = CalendarContract.Events.CONTENT_URI
|
||||||
val calendarValues = ContentValues().apply {
|
val calendarValues = ContentValues().apply {
|
||||||
@@ -187,6 +187,10 @@ class CalDAVEventsHandler(val context: Context) {
|
|||||||
context.dbHelper.updateEventImportIdAndSource(event.id, importId, "$CALDAV-$calendarId")
|
context.dbHelper.updateEventImportIdAndSource(event.id, importId, "$CALDAV-$calendarId")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun updateCalDAVEvent(event: Event) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private fun getDurationCode(event: Event): String {
|
private fun getDurationCode(event: Event): String {
|
||||||
return if (event.getIsAllDay()) {
|
return if (event.getIsAllDay()) {
|
||||||
val dur = Math.max(1, (event.endTS - event.startTS) / DAY)
|
val dur = Math.max(1, (event.endTS - event.startTS) / DAY)
|
||||||
|
@@ -200,13 +200,13 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||||||
context.scheduleReminder(event, this)
|
context.scheduleReminder(event, this)
|
||||||
|
|
||||||
if (addToCalDAV) {
|
if (addToCalDAV) {
|
||||||
CalDAVEventsHandler(context).addCalDAVEvent(event)
|
CalDAVEventsHandler(context).insertCalDAVEvent(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(event.id)
|
callback(event.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun update(event: Event, callback: () -> Unit) {
|
fun update(event: Event, updateAtCalDAV: Boolean, callback: () -> Unit) {
|
||||||
val selectionArgs = arrayOf(event.id.toString())
|
val selectionArgs = arrayOf(event.id.toString())
|
||||||
val values = fillEventValues(event)
|
val values = fillEventValues(event)
|
||||||
val selection = "$COL_ID = ?"
|
val selection = "$COL_ID = ?"
|
||||||
@@ -222,6 +222,9 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||||||
|
|
||||||
context.updateWidgets()
|
context.updateWidgets()
|
||||||
context.scheduleReminder(event, this)
|
context.scheduleReminder(event, this)
|
||||||
|
if (updateAtCalDAV) {
|
||||||
|
CalDAVEventsHandler(context).updateCalDAVEvent(event)
|
||||||
|
}
|
||||||
callback()
|
callback()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user