add a Room function for getting events with filled import ids
This commit is contained in:
parent
a5e809b4c9
commit
22bb7595d5
3 changed files with 5 additions and 3 deletions
|
@ -199,8 +199,6 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||
mDb.update(MAIN_TABLE_NAME, values, selection, selectionArgs)
|
||||
}
|
||||
|
||||
fun getEventsWithImportIds() = getEvents("").filter { it.importId.trim().isNotEmpty() } as ArrayList<Event>
|
||||
|
||||
fun getEventWithId(id: Long): Event? {
|
||||
val selection = "$MAIN_TABLE_NAME.$COL_ID = ?"
|
||||
val selectionArgs = arrayOf(id.toString())
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.widget.Toast
|
|||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.calendar.pro.activities.SimpleActivity
|
||||
import com.simplemobiletools.calendar.pro.extensions.dbHelper
|
||||
import com.simplemobiletools.calendar.pro.extensions.eventsDB
|
||||
import com.simplemobiletools.calendar.pro.helpers.IcsImporter.ImportResult.*
|
||||
import com.simplemobiletools.calendar.pro.models.Event
|
||||
import com.simplemobiletools.calendar.pro.models.EventType
|
||||
|
@ -42,7 +43,7 @@ class IcsImporter(val activity: SimpleActivity) {
|
|||
fun importEvents(path: String, defaultEventTypeId: Long, calDAVCalendarId: Int, overrideFileEventTypes: Boolean): ImportResult {
|
||||
try {
|
||||
val eventTypes = EventsHelper(activity).getEventTypesSync()
|
||||
val existingEvents = activity.dbHelper.getEventsWithImportIds()
|
||||
val existingEvents = activity.eventsDB.getEventsWithImportIds().toMutableList() as ArrayList<Event>
|
||||
val eventsToInsert = ArrayList<Event>()
|
||||
var prevLine = ""
|
||||
|
||||
|
|
|
@ -19,6 +19,9 @@ interface EventsDao {
|
|||
@Query("SELECT * FROM events WHERE source = \'$SOURCE_CONTACT_ANNIVERSARY\'")
|
||||
fun getAnniversaries(): List<Event>
|
||||
|
||||
@Query("SELECT * FROM events WHERE import_id != \"\"")
|
||||
fun getEventsWithImportIds(): List<Event>
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun insertOrUpdate(event: Event): Long
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue