From 6953086c9942a0ba114a449e0a53e54bc7c8d38f Mon Sep 17 00:00:00 2001 From: Daniele Gobbetti Date: Sat, 27 Jun 2015 18:50:21 +0200 Subject: [PATCH] Allow setting alarms once for the next day. (cherry picked from commit 417ea02) --- .../java/nodomain/freeyourgadget/gadgetbridge/GBAlarm.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBAlarm.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBAlarm.java index 466f5634..0ba74373 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBAlarm.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBAlarm.java @@ -121,9 +121,15 @@ public class GBAlarm implements Parcelable, Comparable { } public Calendar getAlarmCal() { + Calendar alarm = Calendar.getInstance(); + Calendar now = Calendar.getInstance(); alarm.set(Calendar.HOUR_OF_DAY, this.hour); alarm.set(Calendar.MINUTE, this.minute); + if (now.after(alarm) && repetition == ALARM_ONCE) { + //if the alarm is in the past set it to tomorrow + alarm.add(Calendar.DATE, 1); + } return alarm; }