From a5ed7a28cee67027c9d1ad5bb4cbad96dd31f254 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 3 Apr 2017 20:55:43 +0200 Subject: [PATCH] export repeating events under some conditions too --- .../calendar/helpers/DBHelper.kt | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) 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 086e47c06..60a949a76 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt @@ -410,7 +410,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont val events = ArrayList() var cursor: Cursor? = null try { - cursor = getEventsCursor(selection, null) + cursor = getEventsCursor(selection) if (cursor != null) { val currEvents = fillEvents(cursor) events.addAll(currEvents) @@ -436,18 +436,27 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont } fun getEventsToExport(includePast: Boolean): ArrayList { + val currTime = (System.currentTimeMillis() / 1000).toString() val events = ArrayList() - val cursor = if (includePast) { + // non repeating events + var cursor = if (includePast) { getEventsCursor() } else { - val endTime = (System.currentTimeMillis() / 1000).toString() val selection = "$COL_END_TS > ?" - val selectionArgs = arrayOf(endTime) + val selectionArgs = arrayOf(currTime) getEventsCursor(selection, selectionArgs) } - events.addAll(fillEvents(cursor)) + + // repeating events + if (!includePast) { + val selection = "$COL_REPEAT_INTERVAL != 0 AND ($COL_REPEAT_LIMIT == 0 OR $COL_REPEAT_LIMIT > ?)" + val selectionArgs = arrayOf(currTime) + cursor = getEventsCursor(selection, selectionArgs) + events.addAll(fillEvents(cursor)) + } + return events }