diff options
author | Abyss777 <abyss@fox5.ru> | 2016-06-15 14:22:23 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2016-06-15 14:22:23 +0500 |
commit | f08bb5adf425269a00e760c669bdeeadc8c7e112 (patch) | |
tree | c2215abadf212d5e56def143e906683f8390f677 /src/org/traccar/events | |
parent | 8ddcc66dc6441ce8f8a122d09872c143922fa0f0 (diff) | |
download | traccar-server-f08bb5adf425269a00e760c669bdeeadc8c7e112.tar.gz traccar-server-f08bb5adf425269a00e760c669bdeeadc8c7e112.tar.bz2 traccar-server-f08bb5adf425269a00e760c669bdeeadc8c7e112.zip |
- Work only with cached devices from everywhere
- Some optimization
Diffstat (limited to 'src/org/traccar/events')
-rw-r--r-- | src/org/traccar/events/GeofenceEventHandler.java | 10 | ||||
-rw-r--r-- | src/org/traccar/events/MotionEventHandler.java | 5 |
2 files changed, 6 insertions, 9 deletions
diff --git a/src/org/traccar/events/GeofenceEventHandler.java b/src/org/traccar/events/GeofenceEventHandler.java index ed63b6f7d..56029fced 100644 --- a/src/org/traccar/events/GeofenceEventHandler.java +++ b/src/org/traccar/events/GeofenceEventHandler.java @@ -10,7 +10,6 @@ import org.traccar.Context; import org.traccar.database.DataManager; import org.traccar.database.GeofenceManager; import org.traccar.helper.Log; -import org.traccar.model.Device; import org.traccar.model.Event; import org.traccar.model.Position; @@ -32,21 +31,20 @@ public class GeofenceEventHandler extends BaseEventHandler { return null; } - Device device = dataManager.getDeviceById(position.getDeviceId()); - if (device == null) { + if (getDevice() == null) { return null; } List<Long> currentGeofences = geofenceManager.getCurrentDeviceGeofences(position); List<Long> oldGeofences = new ArrayList<Long>(); - if (device.getGeofenceIds() != null) { - oldGeofences.addAll(device.getGeofenceIds()); + if (getDevice().getGeofenceIds() != null) { + oldGeofences.addAll(getDevice().getGeofenceIds()); } List<Long> newGeofences = new ArrayList<Long>(currentGeofences); newGeofences.removeAll(oldGeofences); oldGeofences.removeAll(currentGeofences); - device.setGeofenceIds(currentGeofences); + getDevice().setGeofenceIds(currentGeofences); Collection<Event> events = new ArrayList<>(); try { diff --git a/src/org/traccar/events/MotionEventHandler.java b/src/org/traccar/events/MotionEventHandler.java index 54b6b922d..2ba5979e3 100644 --- a/src/org/traccar/events/MotionEventHandler.java +++ b/src/org/traccar/events/MotionEventHandler.java @@ -29,11 +29,10 @@ public class MotionEventHandler extends BaseEventHandler { double speed = position.getSpeed(); boolean valid = position.getValid(); - Device device = Context.getIdentityManager().getDeviceById(position.getDeviceId()); - if (device == null) { + if (getDevice() == null) { return null; } - String motion = device.getMotion(); + String motion = getDevice().getMotion(); if (motion == null) { motion = Device.STATUS_STOPPED; } |