Skip to content

Commit 7d05ed2

Browse files
committed
Style : 알람 시간 함수 빼기
1 parent 0fe0e17 commit 7d05ed2

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

presentation/src/main/java/com/stop/AlarmFunctions.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ class AlarmFunctions(
3030
PendingIntent.getBroadcast(context, alarmCode, receiverIntent, PendingIntent.FLAG_UPDATE_CURRENT)
3131
}
3232

33+
alarmManager.setExactAndAllowWhileIdle(
34+
AlarmManager.RTC_WAKEUP,
35+
makeFullTime(lastTime).timeInMillis + (alarmTime * 60 * 1000), // 막차 시간에서 알람시간 만큼 뺀 timeInMillis
36+
pendingIntent
37+
)
38+
}
39+
40+
private fun makeFullTime(lastTime: String): Calendar {
3341
val currentTime = System.currentTimeMillis()
3442
val currentFormat = SimpleDateFormat("yyyy:MM:dd", Locale.getDefault())
3543
val currentDateTime = currentFormat.format(currentTime)
@@ -47,11 +55,7 @@ class AlarmFunctions(
4755
val calendar = Calendar.getInstance()
4856
calendar.time = dateTime
4957

50-
alarmManager.setExactAndAllowWhileIdle(
51-
AlarmManager.RTC_WAKEUP,
52-
calendar.timeInMillis + (alarmTime * 60 * 1000), // 막차 시간에서 알람시간 만큼 뺀 timeInMillis
53-
pendingIntent
54-
)
58+
return calendar
5559
}
5660

5761
fun cancelAlarm(alarmCode: Int) {

0 commit comments

Comments
 (0)