mirror of
https://github.com/SimpleMobileTools/Simple-Clock.git
synced 2025-05-22 22:14:28 +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.updateTextColors
|
||||
import kotlinx.android.synthetic.main.fragment_alarm.view.*
|
||||
import java.util.*
|
||||
|
||||
class AlarmFragment : Fragment(), ToggleAlarmInterface {
|
||||
private val DEFAULT_ALARM_MINUTES = 480
|
||||
@ -66,9 +67,19 @@ class AlarmFragment : Fragment(), ToggleAlarmInterface {
|
||||
|
||||
override fun alarmToggled(id: Int, isEnabled: Boolean) {
|
||||
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 {
|
||||
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 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 getAllTimeZones() = arrayListOf(
|
||||
|
@ -9,6 +9,7 @@ import com.simplemobiletools.clock.extensions.createNewAlarm
|
||||
import com.simplemobiletools.clock.models.Alarm
|
||||
import com.simplemobiletools.commons.extensions.getIntValue
|
||||
import com.simplemobiletools.commons.extensions.getStringValue
|
||||
import com.simplemobiletools.commons.helpers.*
|
||||
import java.util.*
|
||||
|
||||
class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(context, DB_NAME, null, DB_VERSION) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user