From fff8f0c792606daff151624479d9ae9dc54187d5 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 14 Dec 2016 17:34:34 +0500 Subject: Calendars implementation --- src/org/traccar/events/GeofenceEventHandler.java | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/org/traccar/events') diff --git a/src/org/traccar/events/GeofenceEventHandler.java b/src/org/traccar/events/GeofenceEventHandler.java index d31e516ef..fbec932b1 100644 --- a/src/org/traccar/events/GeofenceEventHandler.java +++ b/src/org/traccar/events/GeofenceEventHandler.java @@ -57,14 +57,22 @@ public class GeofenceEventHandler extends BaseEventHandler { Collection events = new ArrayList<>(); for (long geofenceId : newGeofences) { - Event event = new Event(Event.TYPE_GEOFENCE_ENTER, position.getDeviceId(), position.getId()); - event.setGeofenceId(geofenceId); - events.add(event); + long calendarId = geofenceManager.getGeofence(geofenceId).getCalendarId(); + if (calendarId == 0 || Context.getCalendarManager().getCalendar(calendarId) == null + || Context.getCalendarManager().getCalendar(calendarId).checkMoment(position.getFixTime())) { + Event event = new Event(Event.TYPE_GEOFENCE_ENTER, position.getDeviceId(), position.getId()); + event.setGeofenceId(geofenceId); + events.add(event); + } } for (long geofenceId : oldGeofences) { - Event event = new Event(Event.TYPE_GEOFENCE_EXIT, position.getDeviceId(), position.getId()); - event.setGeofenceId(geofenceId); - events.add(event); + long calendarId = geofenceManager.getGeofence(geofenceId).getCalendarId(); + if (calendarId == 0 || Context.getCalendarManager().getCalendar(calendarId) == null + || Context.getCalendarManager().getCalendar(calendarId).checkMoment(position.getFixTime())) { + Event event = new Event(Event.TYPE_GEOFENCE_EXIT, position.getDeviceId(), position.getId()); + event.setGeofenceId(geofenceId); + events.add(event); + } } return events; } -- cgit v1.2.3