Moved stuff from one line

This commit is contained in:
Rawlin C 2023-07-03 00:12:15 +05:30
parent 7af2a25fa8
commit 1b39d7a892

View File

@ -145,7 +145,11 @@ fun Context.setupAlarmClock(alarm: Alarm, triggerInSeconds: Int) {
AlarmManagerCompat.setAlarmClock(alarmManager, targetMS, getOpenAlarmTabIntent(), getAlarmIntent(alarm)) AlarmManagerCompat.setAlarmClock(alarmManager, targetMS, getOpenAlarmTabIntent(), getAlarmIntent(alarm))
// Trigger a notification to dismiss the alarm 5 minutes before the alarm if the screen is on // Trigger a notification to dismiss the alarm 5 minutes before the alarm if the screen is on
val dismissalTriggerTime = if (targetMS - System.currentTimeMillis() < (5.minutes.inWholeMilliseconds))(System.currentTimeMillis() + 500) else targetMS - (5.minutes.inWholeMilliseconds) val dismissalTriggerTime = if (targetMS - System.currentTimeMillis() < (5.minutes.inWholeMilliseconds)) {
(System.currentTimeMillis() + 500)
} else {
targetMS - (5.minutes.inWholeMilliseconds)
}
AlarmManagerCompat.setExactAndAllowWhileIdle(alarmManager, 0, dismissalTriggerTime, getEarlyAlarmDismissalIntent(alarm)) AlarmManagerCompat.setExactAndAllowWhileIdle(alarmManager, 0, dismissalTriggerTime, getEarlyAlarmDismissalIntent(alarm))
} catch (e: Exception) { } catch (e: Exception) {
showErrorToast(e) showErrorToast(e)