reset event type to regular at deleting an events type
This commit is contained in:
parent
db2deaf1dc
commit
8783b674a7
|
@ -263,11 +263,24 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
||||||
if (deleteIds.isEmpty())
|
if (deleteIds.isEmpty())
|
||||||
return
|
return
|
||||||
|
|
||||||
|
for (eventTypeId in deleteIds) {
|
||||||
|
resetEventsWithType(eventTypeId)
|
||||||
|
}
|
||||||
|
|
||||||
val args = TextUtils.join(", ", deleteIds)
|
val args = TextUtils.join(", ", deleteIds)
|
||||||
val selection = "$COL_TYPE_ID IN ($args)"
|
val selection = "$COL_TYPE_ID IN ($args)"
|
||||||
callback.invoke(mDb.delete(TYPES_TABLE_NAME, selection, null))
|
callback.invoke(mDb.delete(TYPES_TABLE_NAME, selection, null))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun resetEventsWithType(eventTypeId: Int) {
|
||||||
|
val values = ContentValues()
|
||||||
|
values.put(COL_EVENT_TYPE, REGULAR_EVENT_ID)
|
||||||
|
|
||||||
|
val selection = "$COL_EVENT_TYPE = ?"
|
||||||
|
val selectionArgs = arrayOf(eventTypeId.toString())
|
||||||
|
mDb.update(MAIN_TABLE_NAME, values, selection, selectionArgs)
|
||||||
|
}
|
||||||
|
|
||||||
fun getImportIds(): ArrayList<String> {
|
fun getImportIds(): ArrayList<String> {
|
||||||
val ids = ArrayList<String>()
|
val ids = ArrayList<String>()
|
||||||
val columns = arrayOf(COL_IMPORT_ID)
|
val columns = arrayOf(COL_IMPORT_ID)
|
||||||
|
|
Loading…
Reference in New Issue