Commit 10918167 authored by Robert Hitt's avatar Robert Hitt
Browse files

Facilities open past midnight work properly now

- Also, notifications shouldn't be set for facilities open 24/7
and they should work better for facilities open past midnight
parent 094abe19
Pipeline #877 passed with stages
in 5 minutes and 4 seconds
...@@ -158,12 +158,8 @@ public class MainPresenter { ...@@ -158,12 +158,8 @@ public class MainPresenter {
OpenTimes currentOpenTimes = null; OpenTimes currentOpenTimes = null;
for(OpenTimes o : openTimesList) { for(OpenTimes o : openTimesList) {
if(o.getStartDay() <= currentDay && o.getEndDay() >= currentDay) if(o.getStartDay() <= currentDay && o.getEndDay() >= currentDay) {
currentOpenTimes = o; currentOpenTimes = o;
}
if(currentOpenTimes == null)
return false;
// for some reason in the Api this signifies a facility that's open 24/7, sometimes // for some reason in the Api this signifies a facility that's open 24/7, sometimes
// praying for that api v2 // praying for that api v2
...@@ -182,13 +178,15 @@ public class MainPresenter { ...@@ -182,13 +178,15 @@ public class MainPresenter {
if(currentTime.compareTo(startTime) > 0 && currentTime.compareTo(endTime) < 0) if(currentTime.compareTo(startTime) > 0 && currentTime.compareTo(endTime) < 0)
return true; return true;
else
return false;
} catch (ParseException pe) { } catch (ParseException pe) {
pe.printStackTrace(); pe.printStackTrace();
return false; return false;
} }
} }
}
return false;
}
// Finds the next time the facility closes or opens and returns it // Finds the next time the facility closes or opens and returns it
public String getStatusDuration(Facility facility, Calendar now) { public String getStatusDuration(Facility facility, Calendar now) {
......
...@@ -190,6 +190,14 @@ public class NotificationPresenter { ...@@ -190,6 +190,14 @@ public class NotificationPresenter {
private static void setAlarm(Context context, String name, int day, String type, private static void setAlarm(Context context, String name, int day, String type,
int intervalMin, String time, String message) { int intervalMin, String time, String message) {
// NOTE: this doesn't set notifications based on the assumption that
// facilities shouldn't open or close at those times, thus those must indicate
// that the facility is open 24/7 or open past midnight
// As of writing this (2/9/17) there is no better way (due to the way the Api is written)
// If you're reading this and there now is an approach, please fix this
if(time.equals("00:00:00") || time.equals("23:59:59"))
return;
Long alarmTime = parseTimeStringToMs(time, day, Calendar.getInstance()); Long alarmTime = parseTimeStringToMs(time, day, Calendar.getInstance());
int interval = intervalMin * 60000; // parse minutes to ms int interval = intervalMin * 60000; // parse minutes to ms
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment