diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt index 6920b630a..2a6f001a9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt @@ -461,7 +461,10 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { if (it) { dbHelper.update(mEvent) } else { - + dbHelper.addEventRepeatException(mEvent.id, mEventOccurrenceTS) + mEvent.parentId = mEvent.id + mEvent.id = 0 + dbHelper.insert(mEvent) } } } else { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt index ffea5b112..ad5e1f480 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt @@ -405,7 +405,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont fun getEventsInBackground(fromTS: Int, toTS: Int, eventId: Int = -1, callback: (events: MutableList) -> Unit) { val events = ArrayList() - var selection = "$COL_START_TS <= ? AND $COL_END_TS >= ? AND $COL_REPEAT_INTERVAL IS NULL AND $COL_PARENT_EVENT_ID == 0" + var selection = "$COL_START_TS <= ? AND $COL_END_TS >= ? AND $COL_REPEAT_INTERVAL IS NULL AND $COL_START_TS != 0" if (eventId != -1) selection += " AND $MAIN_TABLE_NAME.$COL_ID = $eventId" val selectionArgs = arrayOf(toTS.toString(), fromTS.toString()) @@ -422,7 +422,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont val newEvents = ArrayList() // get repeatable events - var selection = "$COL_REPEAT_INTERVAL != 0 AND $COL_START_TS <= $toTS AND $COL_PARENT_EVENT_ID == 0" + var selection = "$COL_REPEAT_INTERVAL != 0 AND $COL_START_TS <= $toTS AND $COL_START_TS != 0" if (eventId != -1) selection += " AND $MAIN_TABLE_NAME.$COL_ID = $eventId" val events = getEvents(selection) @@ -494,7 +494,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont val events = ArrayList() val ts = (System.currentTimeMillis() / 1000).toInt() - val selection = "$COL_START_TS <= ? AND $COL_END_TS >= ? AND $COL_REPEAT_INTERVAL IS 0 AND $COL_PARENT_EVENT_ID == 0" + val selection = "$COL_START_TS <= ? AND $COL_END_TS >= ? AND $COL_REPEAT_INTERVAL IS 0 AND $COL_START_TS != 0" val selectionArgs = arrayOf(ts.toString(), ts.toString()) val cursor = getEventsCursor(selection, selectionArgs) events.addAll(fillEvents(cursor)) @@ -526,7 +526,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont } fun getEventsAtReboot(): List { - val selection = "$COL_REMINDER_MINUTES != -1 AND ($COL_START_TS > ? OR $COL_REPEAT_INTERVAL != 0) AND $COL_PARENT_EVENT_ID == 0" + val selection = "$COL_REMINDER_MINUTES != -1 AND ($COL_START_TS > ? OR $COL_REPEAT_INTERVAL != 0) AND $COL_START_TS != 0" val selectionArgs = arrayOf(DateTime.now().seconds().toString()) val cursor = getEventsCursor(selection, selectionArgs) return fillEvents(cursor)