mirror of
https://github.com/SimpleMobileTools/Simple-Clock.git
synced 2025-05-23 14:34:21 +02:00
removing some redundant constants
This commit is contained in:
parent
eee9458d4e
commit
ce033cf6fa
@ -16,6 +16,7 @@ import com.simplemobiletools.clock.models.Alarm
|
|||||||
import com.simplemobiletools.commons.extensions.toast
|
import com.simplemobiletools.commons.extensions.toast
|
||||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||||
import kotlinx.android.synthetic.main.fragment_alarm.view.*
|
import kotlinx.android.synthetic.main.fragment_alarm.view.*
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
class AlarmFragment : Fragment(), ToggleAlarmInterface {
|
class AlarmFragment : Fragment(), ToggleAlarmInterface {
|
||||||
private val DEFAULT_ALARM_MINUTES = 480
|
private val DEFAULT_ALARM_MINUTES = 480
|
||||||
@ -66,9 +67,19 @@ class AlarmFragment : Fragment(), ToggleAlarmInterface {
|
|||||||
|
|
||||||
override fun alarmToggled(id: Int, isEnabled: Boolean) {
|
override fun alarmToggled(id: Int, isEnabled: Boolean) {
|
||||||
if (context!!.dbHelper.updateAlarmEnabledState(id, isEnabled)) {
|
if (context!!.dbHelper.updateAlarmEnabledState(id, isEnabled)) {
|
||||||
alarms.firstOrNull { it.id == id }?.isEnabled = isEnabled
|
val alarm = alarms.firstOrNull { it.id == id } ?: return
|
||||||
|
alarm.isEnabled = isEnabled
|
||||||
|
if (isEnabled) {
|
||||||
|
getClosestTriggerTimestamp(alarm)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
activity!!.toast(R.string.unknown_error_occurred)
|
activity!!.toast(R.string.unknown_error_occurred)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getClosestTriggerTimestamp(alarm: Alarm) {
|
||||||
|
val calendar = Calendar.getInstance()
|
||||||
|
calendar.firstDayOfWeek = Calendar.MONDAY
|
||||||
|
val currentDay = (calendar.get(Calendar.DAY_OF_WEEK) + 5) % 7
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,14 +11,6 @@ const val EDITED_TIME_ZONE_TITLES = "edited_time_zone_titles"
|
|||||||
const val TABS_COUNT = 3
|
const val TABS_COUNT = 3
|
||||||
const val EDITED_TIME_ZONE_SEPARATOR = ":"
|
const val EDITED_TIME_ZONE_SEPARATOR = ":"
|
||||||
|
|
||||||
const val MONDAY_BIT = 1
|
|
||||||
const val TUESDAY_BIT = 2
|
|
||||||
const val WEDNESDAY_BIT = 4
|
|
||||||
const val THURSDAY_BIT = 8
|
|
||||||
const val FRIDAY_BIT = 16
|
|
||||||
const val SATURDAY_BIT = 32
|
|
||||||
const val SUNDAY_BIT = 64
|
|
||||||
|
|
||||||
fun getDefaultTimeZoneTitle(id: Int) = getAllTimeZones().firstOrNull { it.id == id }?.title ?: ""
|
fun getDefaultTimeZoneTitle(id: Int) = getAllTimeZones().firstOrNull { it.id == id }?.title ?: ""
|
||||||
|
|
||||||
fun getAllTimeZones() = arrayListOf(
|
fun getAllTimeZones() = arrayListOf(
|
||||||
|
@ -9,6 +9,7 @@ import com.simplemobiletools.clock.extensions.createNewAlarm
|
|||||||
import com.simplemobiletools.clock.models.Alarm
|
import com.simplemobiletools.clock.models.Alarm
|
||||||
import com.simplemobiletools.commons.extensions.getIntValue
|
import com.simplemobiletools.commons.extensions.getIntValue
|
||||||
import com.simplemobiletools.commons.extensions.getStringValue
|
import com.simplemobiletools.commons.extensions.getStringValue
|
||||||
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(context, DB_NAME, null, DB_VERSION) {
|
class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(context, DB_NAME, null, DB_VERSION) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user