add a boolean to indicate if the created event should be added to caldav
This commit is contained in:
parent
5d6404d075
commit
c0d6beb81f
|
@ -466,7 +466,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
||||||
|
|
||||||
private fun storeEvent(wasRepeatable: Boolean) {
|
private fun storeEvent(wasRepeatable: Boolean) {
|
||||||
if (mEvent.id == 0) {
|
if (mEvent.id == 0) {
|
||||||
dbHelper.insert(mEvent) {
|
dbHelper.insert(mEvent, true) {
|
||||||
if (DateTime.now().isAfter(mEventStartDateTime.millis)) {
|
if (DateTime.now().isAfter(mEventStartDateTime.millis)) {
|
||||||
toast(R.string.past_event_added)
|
toast(R.string.past_event_added)
|
||||||
} else {
|
} else {
|
||||||
|
@ -486,7 +486,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
||||||
dbHelper.addEventRepeatException(mEvent.id, mEventOccurrenceTS)
|
dbHelper.addEventRepeatException(mEvent.id, mEventOccurrenceTS)
|
||||||
mEvent.parentId = mEvent.id
|
mEvent.parentId = mEvent.id
|
||||||
mEvent.id = 0
|
mEvent.id = 0
|
||||||
dbHelper.insert(mEvent) {
|
dbHelper.insert(mEvent, true) {
|
||||||
toast(R.string.event_updated)
|
toast(R.string.event_updated)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
|
@ -326,7 +326,7 @@ fun Context.fetchCalDAVCalendarEvents(calendarId: Long, eventTypeId: Int) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dbHelper.insert(event) {
|
dbHelper.insert(event, false) {
|
||||||
importIdsMap.put(event.importId, event)
|
importIdsMap.put(event.importId, event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,7 +175,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
||||||
addEventType(eventType, db)
|
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()) {
|
if (event.startTS > event.endTS || event.title.trim().isEmpty()) {
|
||||||
callback(0)
|
callback(0)
|
||||||
return
|
return
|
||||||
|
@ -192,6 +192,11 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
||||||
|
|
||||||
context.updateWidgets()
|
context.updateWidgets()
|
||||||
context.scheduleReminder(event, this)
|
context.scheduleReminder(event, this)
|
||||||
|
|
||||||
|
if (addToCalDAV) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
callback(event.id)
|
callback(event.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,7 +288,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
||||||
endTS = 0
|
endTS = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
insert(childEvent) {
|
insert(childEvent, false) {
|
||||||
callback(ContentValues().apply {
|
callback(ContentValues().apply {
|
||||||
put(COL_PARENT_EVENT_ID, parentEventId)
|
put(COL_PARENT_EVENT_ID, parentEventId)
|
||||||
put(COL_OCCURRENCE_DAYCODE, Formatter.getDayCodeFromTS(occurrenceTS))
|
put(COL_OCCURRENCE_DAYCODE, Formatter.getDayCodeFromTS(occurrenceTS))
|
||||||
|
|
|
@ -105,7 +105,7 @@ class IcsImporter {
|
||||||
event.endTS -= DAY
|
event.endTS -= DAY
|
||||||
}
|
}
|
||||||
|
|
||||||
context.dbHelper.insert(event) {
|
context.dbHelper.insert(event, true) {
|
||||||
for (exceptionTS in curRepeatExceptions) {
|
for (exceptionTS in curRepeatExceptions) {
|
||||||
context.dbHelper.addEventRepeatException(it, exceptionTS)
|
context.dbHelper.addEventRepeatException(it, exceptionTS)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue