mirror of
				https://github.com/SimpleMobileTools/Simple-Clock.git
				synced 2025-06-05 22:19:17 +02:00 
			
		
		
		
	handle inserting new alarms
This commit is contained in:
		| @@ -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 { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user