create a room function for fetching events by ids
This commit is contained in:
parent
ec40b5954c
commit
b4d84e8960
|
@ -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<Long>) {
|
|||
return@Thread
|
||||
}
|
||||
|
||||
val events = dbHelper.getEventsWithIds(ids)
|
||||
val events = eventsDB.getEventsWithIds(ids) as ArrayList<Event>
|
||||
IcsExporter().exportEvents(this, file, events, false) {
|
||||
if (it == IcsExporter.ExportResult.EXPORT_OK) {
|
||||
sharePathIntent(file.absolutePath, BuildConfig.APPLICATION_ID)
|
||||
|
|
|
@ -483,12 +483,6 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||
return events
|
||||
}
|
||||
|
||||
fun getEventsWithIds(ids: List<Long>): ArrayList<Event> {
|
||||
val args = TextUtils.join(", ", ids)
|
||||
val selection = "$MAIN_TABLE_NAME.$COL_ID IN ($args)"
|
||||
return getEvents(selection) as ArrayList<Event>
|
||||
}
|
||||
|
||||
fun getEventsAtReboot(): List<Event> {
|
||||
//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"
|
||||
|
|
|
@ -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<Long>): List<Event>
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun insertOrUpdate(event: Event): Long
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue