update the Alarm enabled state at toggling

This commit is contained in:
tibbi
2018-03-05 23:04:53 +01:00
parent 0f8d61c0d0
commit eee9458d4e
4 changed files with 33 additions and 5 deletions

View File

@ -67,6 +67,14 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
return mDb.update(ALARMS_TABLE_NAME, values, selection, selectionArgs) == 1
}
fun updateAlarmEnabledState(id: Int, isEnabled: Boolean): Boolean {
val selectionArgs = arrayOf(id.toString())
val values = ContentValues()
values.put(COL_IS_ENABLED, isEnabled)
val selection = "$COL_ID = ?"
return mDb.update(ALARMS_TABLE_NAME, values, selection, selectionArgs) == 1
}
private fun fillAlarmContentValues(alarm: Alarm): ContentValues {
return ContentValues().apply {
put(COL_TIME_IN_MINUTES, alarm.timeInMinutes)