add a boolean to indicate if the created event should be added to caldav

This commit is contained in:
tibbi 2017-08-16 21:28:43 +02:00
parent 5d6404d075
commit c0d6beb81f
4 changed files with 11 additions and 6 deletions

View File

@ -466,7 +466,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
private fun storeEvent(wasRepeatable: Boolean) {
if (mEvent.id == 0) {
dbHelper.insert(mEvent) {
dbHelper.insert(mEvent, true) {
if (DateTime.now().isAfter(mEventStartDateTime.millis)) {
toast(R.string.past_event_added)
} else {
@ -486,7 +486,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
dbHelper.addEventRepeatException(mEvent.id, mEventOccurrenceTS)
mEvent.parentId = mEvent.id
mEvent.id = 0
dbHelper.insert(mEvent) {
dbHelper.insert(mEvent, true) {
toast(R.string.event_updated)
finish()
}

View File

@ -326,7 +326,7 @@ fun Context.fetchCalDAVCalendarEvents(calendarId: Long, eventTypeId: Int) {
}
}
} else {
dbHelper.insert(event) {
dbHelper.insert(event, false) {
importIdsMap.put(event.importId, event)
}
}

View File

@ -175,7 +175,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
addEventType(eventType, db)
}
fun insert(event: Event, callback: (id: Int) -> Unit) {
fun insert(event: Event, addToCalDAV: Boolean, callback: (id: Int) -> Unit) {
if (event.startTS > event.endTS || event.title.trim().isEmpty()) {
callback(0)
return
@ -192,6 +192,11 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
context.updateWidgets()
context.scheduleReminder(event, this)
if (addToCalDAV) {
}
callback(event.id)
}
@ -283,7 +288,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
endTS = 0
}
insert(childEvent) {
insert(childEvent, false) {
callback(ContentValues().apply {
put(COL_PARENT_EVENT_ID, parentEventId)
put(COL_OCCURRENCE_DAYCODE, Formatter.getDayCodeFromTS(occurrenceTS))

View File

@ -105,7 +105,7 @@ class IcsImporter {
event.endTS -= DAY
}
context.dbHelper.insert(event) {
context.dbHelper.insert(event, true) {
for (exceptionTS in curRepeatExceptions) {
context.dbHelper.addEventRepeatException(it, exceptionTS)
}