From 2334dc2e3c51895c81f93d60fdfac87dd11a5291 Mon Sep 17 00:00:00 2001 From: CiufudeanDani Date: Tue, 15 Mar 2022 17:42:58 +0200 Subject: [PATCH] make marker move --- .../activities/AbstractLiveActivity.java | 1 - .../com/safemobile/dispatch/LiveActivity.java | 4 +- .../dispatch/TabLayoutActivity.java | 58 +++++++------------ 3 files changed, 22 insertions(+), 41 deletions(-) diff --git a/libSafeMobile/src/main/java/com/safemobile/activities/AbstractLiveActivity.java b/libSafeMobile/src/main/java/com/safemobile/activities/AbstractLiveActivity.java index 11a7695..2f2e654 100644 --- a/libSafeMobile/src/main/java/com/safemobile/activities/AbstractLiveActivity.java +++ b/libSafeMobile/src/main/java/com/safemobile/activities/AbstractLiveActivity.java @@ -24,7 +24,6 @@ public abstract class AbstractLiveActivity extends AppCompatActivity { public abstract void vehicleStatusReceived(long imei, int opCode, int status); // --> UpdateOptions public abstract void emergencyAlarmReceived(int position, double lat, double lng); // --> UpdateEmergencyAlarm - /** Misc */ public AbstractSDParentActivity getParentTab() { return parentTab; diff --git a/safeDispatch/src/main/java/com/safemobile/dispatch/LiveActivity.java b/safeDispatch/src/main/java/com/safemobile/dispatch/LiveActivity.java index a2a2789..081e942 100644 --- a/safeDispatch/src/main/java/com/safemobile/dispatch/LiveActivity.java +++ b/safeDispatch/src/main/java/com/safemobile/dispatch/LiveActivity.java @@ -471,7 +471,7 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall for (int i = 0; i < displayedVehicles.size(); i++) { if (displayedVehicles.get(i)) { - SuperVehicle tmpSuper = Objects.requireNonNull(tableHashOverlay.get((int) liveVehicle.get(i).driver_id)).get(0); + SuperVehicle tmpSuper = getParentTab().SuperVehHash.get(Long.valueOf(liveVehicle.get(i).imei)); if (tmpSuper != null) { LatLng newLocation = new LatLng(tmpSuper.lat, tmpSuper.lng); @@ -481,7 +481,6 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall markerOptions.icon(markerIcon); Marker marker = this.googleMap.addMarker(markerOptions); - this.googleMap.moveCamera(CameraUpdateFactory.newLatLng(newLocation)); } } } @@ -665,7 +664,6 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall pollReceived(position,lat,lng); } - public void updatePosition(int pos) { contextMenuPosition = pos; } diff --git a/safeDispatch/src/main/java/com/safemobile/dispatch/TabLayoutActivity.java b/safeDispatch/src/main/java/com/safemobile/dispatch/TabLayoutActivity.java index fe01c66..423b978 100644 --- a/safeDispatch/src/main/java/com/safemobile/dispatch/TabLayoutActivity.java +++ b/safeDispatch/src/main/java/com/safemobile/dispatch/TabLayoutActivity.java @@ -1237,35 +1237,24 @@ public class TabLayoutActivity extends AbstractSDParentActivity{ GPSmsg GPSPos= new GPSmsg(msg); //SM.Debug("Got new GPS pos data:" + GPSPos.data); - if(SuperVehHash.get(GPSPos.gpsValue.imei) != null) - { - ((SuperVehicle)SuperVehHash.get(GPSPos.gpsValue.imei)).SetNewPosition(GPSPos.gpsValue.lat, GPSPos.gpsValue.lng, GPSPos.gpsValue.timeGMT, GPSPos.gpsValue.speed); - - if(SuperVehHash.get(GPSPos.gpsValue.imei).needUpdate) - { - - //list for live - if(AppParams.crtTab == AppParams.Tabs.live) - { - //SM.Debug("+++++ duda +++++"); - SM.Debug("currentActivity instanceof LiveActivity"); - try - { - if(liveActivity != null) - liveActivity.refreshMap(); - } - catch (Exception ex) - { - SM.Debug("Error load hash:"+ex.toString()); - } - } - } + if (SuperVehHash.get(GPSPos.gpsValue.imei) != null) { + ((SuperVehicle)SuperVehHash.get(GPSPos.gpsValue.imei)).SetNewPosition(GPSPos.gpsValue.lat, GPSPos.gpsValue.lng, GPSPos.gpsValue.timeGMT, GPSPos.gpsValue.speed); +// if (SuperVehHash.get(GPSPos.gpsValue.imei).needUpdate) { + if (AppParams.crtTab == AppParams.Tabs.live) { + SM.Debug("currentActivity instanceof LiveActivity"); + try { + if (liveActivity != null) + liveActivity.refreshMap(); + } catch (Exception ex) { + SM.Debug("Error load hash: "+ ex); + } + } +// } } } @Override - public void onPollReceived(TCPEvent event) - { + public void onPollReceived(TCPEvent event) { SM.Debug("Got POLL GPS message"); TCPmsg msg= event.msg(); GPSmsg GPSPos= new GPSmsg(msg); @@ -1273,13 +1262,11 @@ public class TabLayoutActivity extends AbstractSDParentActivity{ mess = "LAT:"+Double.toString(GPSPos.gpsValue.lat)+" LNG:"+Double.toString(GPSPos.gpsValue.lng); SM.Debug("Got new Poll pos data:" + GPSPos.data); - if(SuperVehHash.get(GPSPos.gpsValue.imei) != null) - { + if (SuperVehHash.get(GPSPos.gpsValue.imei) != null) { ((SuperVehicle)SuperVehHash.get(GPSPos.gpsValue.imei)).SetNewPosition(GPSPos.gpsValue.lat, GPSPos.gpsValue.lng, GPSPos.gpsValue.timeGMT, GPSPos.gpsValue.speed); //if is not check i need to force check to put on the map Boolean forceChecked =false; - if (!SuperVehHash.get(GPSPos.gpsValue.imei).needUpdate) - { + if (!SuperVehHash.get(GPSPos.gpsValue.imei).needUpdate) { SuperVehHash.get(GPSPos.gpsValue.imei).needUpdate =true; forceChecked =true; } @@ -1525,15 +1512,12 @@ public class TabLayoutActivity extends AbstractSDParentActivity{ @Override public void onLastPositionsReceived(TCPEvent event) { TCPmsg msg= event.msg(); - SM.Debug("Got lastpos"); - //SM.Debug("Got lastpos :" + msg.allData); - + SM.Debug("Got last pos"); + LastPosmsg lastPos= new LastPosmsg(msg); - //SM.Debug("Got LastPost msg.data:" + msg.data); - for(LastPos posMsg: lastPos.PosList) - { - if(SuperVehHash.get(posMsg.imei) != null) - ((SuperVehicle)SuperVehHash.get(posMsg.imei)).SetDataFromLastPos(posMsg.lat, posMsg.lng, posMsg.timeGMT, posMsg.speed, posMsg.Address, posMsg.isON); + for (LastPos posMsg: lastPos.PosList) { + if (SuperVehHash.get(posMsg.imei) != null) + ((SuperVehicle) SuperVehHash.get(posMsg.imei)).SetDataFromLastPos(posMsg.lat, posMsg.lng, posMsg.timeGMT, posMsg.speed, posMsg.Address, posMsg.isON); } }