mirror of
https://github.com/SimpleMobileTools/Simple-Clock.git
synced 2025-02-20 22:00:45 +01:00
handle inserting new alarms
This commit is contained in:
parent
660ebc90f0
commit
50a573cc33
@ -97,8 +97,14 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba
|
||||
alarm.isEnabled = false
|
||||
}
|
||||
|
||||
if (!activity.dbHelper.updateAlarm(alarm)) {
|
||||
activity.toast(R.string.unknown_error_occurred)
|
||||
if (alarm.id == 0) {
|
||||
if (!activity.dbHelper.insertAlarm(alarm)) {
|
||||
activity.toast(R.string.unknown_error_occurred)
|
||||
}
|
||||
} else {
|
||||
if (!activity.dbHelper.updateAlarm(alarm)) {
|
||||
activity.toast(R.string.unknown_error_occurred)
|
||||
}
|
||||
}
|
||||
callback()
|
||||
}
|
||||
|
@ -57,9 +57,9 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
||||
insertAlarm(weekEndAlarm, db)
|
||||
}
|
||||
|
||||
private fun insertAlarm(alarm: Alarm, db: SQLiteDatabase) {
|
||||
fun insertAlarm(alarm: Alarm, db: SQLiteDatabase = mDb): Boolean {
|
||||
val values = fillAlarmContentValues(alarm)
|
||||
db.insert(ALARMS_TABLE_NAME, null, values)
|
||||
return db.insert(ALARMS_TABLE_NAME, null, values) != -1L
|
||||
}
|
||||
|
||||
fun updateAlarm(alarm: Alarm): Boolean {
|
||||
|
Loading…
x
Reference in New Issue
Block a user