aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/events
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-07-22 11:16:14 +0500
committerAbyss777 <abyss@fox5.ru>2017-07-22 11:16:14 +0500
commit4cb47c38af63696470acdc91d7b7d01512f6b2e7 (patch)
treea07ae10919ff97d8c5b91bd381508675d8fb8d6b /src/org/traccar/events
parent69c46399ee0f6b3dd2b0589cb412e9e17f040369 (diff)
downloadtraccar-server-4cb47c38af63696470acdc91d7b7d01512f6b2e7.tar.gz
traccar-server-4cb47c38af63696470acdc91d7b7d01512f6b2e7.tar.bz2
traccar-server-4cb47c38af63696470acdc91d7b7d01512f6b2e7.zip
- Add Permission helper Class
- Reorganize permission check and link - Optimize calendar retrieving
Diffstat (limited to 'src/org/traccar/events')
-rw-r--r--src/org/traccar/events/GeofenceEventHandler.java16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/org/traccar/events/GeofenceEventHandler.java b/src/org/traccar/events/GeofenceEventHandler.java
index cdac7993f..089d1e0ef 100644
--- a/src/org/traccar/events/GeofenceEventHandler.java
+++ b/src/org/traccar/events/GeofenceEventHandler.java
@@ -60,9 +60,11 @@ public class GeofenceEventHandler extends BaseEventHandler {
Collection<Event> events = new ArrayList<>();
for (long geofenceId : newGeofences) {
long calendarId = ((Geofence) geofenceManager.getById(geofenceId)).getCalendarId();
- if (calendarId == 0 || Context.getCalendarManager().getById(calendarId) == null
- || ((Calendar) Context.getCalendarManager().getById(calendarId))
- .checkMoment(position.getFixTime())) {
+ Calendar calendar = null;
+ if (calendarId != 0) {
+ calendar = (Calendar) Context.getCalendarManager().getById(calendarId);
+ }
+ if (calendar == null || calendar.checkMoment(position.getFixTime())) {
Event event = new Event(Event.TYPE_GEOFENCE_ENTER, position.getDeviceId(), position.getId());
event.setGeofenceId(geofenceId);
events.add(event);
@@ -70,9 +72,11 @@ public class GeofenceEventHandler extends BaseEventHandler {
}
for (long geofenceId : oldGeofences) {
long calendarId = ((Geofence) geofenceManager.getById(geofenceId)).getCalendarId();
- if (calendarId == 0 || Context.getCalendarManager().getById(calendarId) == null
- || ((Calendar) Context.getCalendarManager().getById(calendarId))
- .checkMoment(position.getFixTime())) {
+ Calendar calendar = null;
+ if (calendarId != 0) {
+ calendar = (Calendar) Context.getCalendarManager().getById(calendarId);
+ }
+ if (calendar == null || calendar.checkMoment(position.getFixTime())) {
Event event = new Event(Event.TYPE_GEOFENCE_EXIT, position.getDeviceId(), position.getId());
event.setGeofenceId(geofenceId);
events.add(event);