diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/extensions/Activity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/extensions/Activity.kt index 009e39eac..d4a1ab488 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/extensions/Activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/extensions/Activity.kt @@ -5,6 +5,7 @@ import com.simplemobiletools.calendar.pro.BuildConfig import com.simplemobiletools.calendar.pro.R import com.simplemobiletools.calendar.pro.dialogs.CustomEventRepeatIntervalDialog import com.simplemobiletools.calendar.pro.helpers.* +import com.simplemobiletools.calendar.pro.models.Event import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.dialogs.RadioGroupDialog import com.simplemobiletools.commons.extensions.hideKeyboard @@ -23,7 +24,7 @@ fun BaseSimpleActivity.shareEvents(ids: List) { return@Thread } - val events = dbHelper.getEventsWithIds(ids) + val events = eventsDB.getEventsWithIds(ids) as ArrayList IcsExporter().exportEvents(this, file, events, false) { if (it == IcsExporter.ExportResult.EXPORT_OK) { sharePathIntent(file.absolutePath, BuildConfig.APPLICATION_ID) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/DBHelper.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/DBHelper.kt index 84cb2669e..d494bf52a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/DBHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/DBHelper.kt @@ -483,12 +483,6 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont return events } - fun getEventsWithIds(ids: List): ArrayList { - val args = TextUtils.join(", ", ids) - val selection = "$MAIN_TABLE_NAME.$COL_ID IN ($args)" - return getEvents(selection) as ArrayList - } - fun getEventsAtReboot(): List { //val selection = "$COL_REMINDER_MINUTES != -1 AND ($COL_START_TS > ? OR $COL_REPEAT_INTERVAL != 0) AND $COL_START_TS != 0" val selection = "$COL_REMINDER_MINUTES != -1 AND ($COL_START_TS > ?) AND $COL_START_TS != 0" diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/interfaces/EventsDao.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/interfaces/EventsDao.kt index 9309736b7..7207c7483 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/interfaces/EventsDao.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/interfaces/EventsDao.kt @@ -3,10 +3,14 @@ package com.simplemobiletools.calendar.pro.interfaces import androidx.room.Dao import androidx.room.Insert import androidx.room.OnConflictStrategy +import androidx.room.Query import com.simplemobiletools.calendar.pro.models.Event @Dao interface EventsDao { + @Query("DELETE FROM events WHERE id IN (:ids)") + fun getEventsWithIds(ids: List): List + @Insert(onConflict = OnConflictStrategy.REPLACE) fun insertOrUpdate(event: Event): Long }