aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/events
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-11-24 16:49:54 +1300
committerGitHub <noreply@github.com>2016-11-24 16:49:54 +1300
commitebe64e810bd8e57a805a571cfd6110fbc3cd57c1 (patch)
tree90d8bb347c6081116df225d5c1e08f9469458675 /src/org/traccar/events
parent04f33e6ba29b3a73a65b081d2a8b6ac3e0e0ebee (diff)
parent03fb12d4a9453d6845198a167a70e720726df2e2 (diff)
downloadtrackermap-server-ebe64e810bd8e57a805a571cfd6110fbc3cd57c1.tar.gz
trackermap-server-ebe64e810bd8e57a805a571cfd6110fbc3cd57c1.tar.bz2
trackermap-server-ebe64e810bd8e57a805a571cfd6110fbc3cd57c1.zip
Merge pull request #2593 from Abyss777/attributes_helpers
Attributes helpers
Diffstat (limited to 'src/org/traccar/events')
-rw-r--r--src/org/traccar/events/IgnitionEventHandler.java12
-rw-r--r--src/org/traccar/events/MaintenanceEventHandler.java9
2 files changed, 5 insertions, 16 deletions
diff --git a/src/org/traccar/events/IgnitionEventHandler.java b/src/org/traccar/events/IgnitionEventHandler.java
index b52083f57..3086adb13 100644
--- a/src/org/traccar/events/IgnitionEventHandler.java
+++ b/src/org/traccar/events/IgnitionEventHandler.java
@@ -39,20 +39,12 @@ public class IgnitionEventHandler extends BaseEventHandler {
Collection<Event> result = null;
- boolean ignition = false;
- Object ignitionObject = position.getAttributes().get(Position.KEY_IGNITION);
- if (ignitionObject != null && ignitionObject instanceof Boolean) {
- ignition = (Boolean) ignitionObject;
- }
+ boolean ignition = position.getBoolean(Position.KEY_IGNITION);
boolean oldIgnition = false;
- Object oldIgnitionObject = null;
Position lastPosition = Context.getIdentityManager().getLastPosition(position.getDeviceId());
if (lastPosition != null) {
- oldIgnitionObject = lastPosition.getAttributes().get(Position.KEY_IGNITION);
- }
- if (oldIgnitionObject != null && oldIgnitionObject instanceof Boolean) {
- oldIgnition = (Boolean) oldIgnitionObject;
+ oldIgnition = lastPosition.getBoolean(Position.KEY_IGNITION);
}
if (ignition && !oldIgnition) {
diff --git a/src/org/traccar/events/MaintenanceEventHandler.java b/src/org/traccar/events/MaintenanceEventHandler.java
index 466e0b617..f423e035b 100644
--- a/src/org/traccar/events/MaintenanceEventHandler.java
+++ b/src/org/traccar/events/MaintenanceEventHandler.java
@@ -50,13 +50,10 @@ public class MaintenanceEventHandler extends BaseEventHandler {
double newTotalDistance = 0.0;
Position lastPosition = Context.getIdentityManager().getLastPosition(position.getDeviceId());
- if (lastPosition != null && lastPosition.getAttributes().containsKey(Position.KEY_TOTAL_DISTANCE)) {
- oldTotalDistance = ((Number) lastPosition.getAttributes().get(Position.KEY_TOTAL_DISTANCE)).doubleValue();
- }
-
- if (position.getAttributes().containsKey(Position.KEY_TOTAL_DISTANCE)) {
- newTotalDistance = ((Number) position.getAttributes().get(Position.KEY_TOTAL_DISTANCE)).doubleValue();
+ if (lastPosition != null) {
+ oldTotalDistance = lastPosition.getDouble(Position.KEY_TOTAL_DISTANCE);
}
+ newTotalDistance = position.getDouble(Position.KEY_TOTAL_DISTANCE);
oldTotalDistance -= maintenanceStart;
newTotalDistance -= maintenanceStart;