make marker move

This commit is contained in:
CiufudeanDani 2022-03-15 17:42:58 +02:00
parent 3da44593dd
commit 2334dc2e3c
3 changed files with 22 additions and 41 deletions

View File

@ -24,7 +24,6 @@ public abstract class AbstractLiveActivity extends AppCompatActivity {
public abstract void vehicleStatusReceived(long imei, int opCode, int status); // --> UpdateOptions public abstract void vehicleStatusReceived(long imei, int opCode, int status); // --> UpdateOptions
public abstract void emergencyAlarmReceived(int position, double lat, double lng); // --> UpdateEmergencyAlarm public abstract void emergencyAlarmReceived(int position, double lat, double lng); // --> UpdateEmergencyAlarm
/** Misc */ /** Misc */
public AbstractSDParentActivity getParentTab() { public AbstractSDParentActivity getParentTab() {
return parentTab; return parentTab;

View File

@ -471,7 +471,7 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
for (int i = 0; i < displayedVehicles.size(); i++) { for (int i = 0; i < displayedVehicles.size(); i++) {
if (displayedVehicles.get(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) { if (tmpSuper != null) {
LatLng newLocation = new LatLng(tmpSuper.lat, tmpSuper.lng); LatLng newLocation = new LatLng(tmpSuper.lat, tmpSuper.lng);
@ -481,7 +481,6 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
markerOptions.icon(markerIcon); markerOptions.icon(markerIcon);
Marker marker = this.googleMap.addMarker(markerOptions); 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); pollReceived(position,lat,lng);
} }
public void updatePosition(int pos) { public void updatePosition(int pos) {
contextMenuPosition = pos; contextMenuPosition = pos;
} }

View File

@ -1237,35 +1237,24 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
GPSmsg GPSPos= new GPSmsg(msg); GPSmsg GPSPos= new GPSmsg(msg);
//SM.Debug("Got new GPS pos data:" + GPSPos.data); //SM.Debug("Got new GPS 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); ((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(SuperVehHash.get(GPSPos.gpsValue.imei).needUpdate) if (AppParams.crtTab == AppParams.Tabs.live) {
{ SM.Debug("currentActivity instanceof LiveActivity");
try {
//list for live if (liveActivity != null)
if(AppParams.crtTab == AppParams.Tabs.live) liveActivity.refreshMap();
{ } catch (Exception ex) {
//SM.Debug("+++++ duda +++++"); SM.Debug("Error load hash: "+ ex);
SM.Debug("currentActivity instanceof LiveActivity"); }
try
{
if(liveActivity != null)
liveActivity.refreshMap();
}
catch (Exception ex)
{
SM.Debug("Error load hash:"+ex.toString());
} }
} // }
}
} }
} }
@Override @Override
public void onPollReceived(TCPEvent event) public void onPollReceived(TCPEvent event) {
{
SM.Debug("Got POLL GPS message"); SM.Debug("Got POLL GPS message");
TCPmsg msg= event.msg(); TCPmsg msg= event.msg();
GPSmsg GPSPos= new GPSmsg(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); mess = "LAT:"+Double.toString(GPSPos.gpsValue.lat)+" LNG:"+Double.toString(GPSPos.gpsValue.lng);
SM.Debug("Got new Poll pos data:" + GPSPos.data); 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); ((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 //if is not check i need to force check to put on the map
Boolean forceChecked =false; Boolean forceChecked =false;
if (!SuperVehHash.get(GPSPos.gpsValue.imei).needUpdate) if (!SuperVehHash.get(GPSPos.gpsValue.imei).needUpdate) {
{
SuperVehHash.get(GPSPos.gpsValue.imei).needUpdate =true; SuperVehHash.get(GPSPos.gpsValue.imei).needUpdate =true;
forceChecked =true; forceChecked =true;
} }
@ -1525,15 +1512,12 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
@Override @Override
public void onLastPositionsReceived(TCPEvent event) { public void onLastPositionsReceived(TCPEvent event) {
TCPmsg msg= event.msg(); TCPmsg msg= event.msg();
SM.Debug("Got lastpos"); SM.Debug("Got last pos");
//SM.Debug("Got lastpos :" + msg.allData);
LastPosmsg lastPos= new LastPosmsg(msg); LastPosmsg lastPos= new LastPosmsg(msg);
//SM.Debug("Got LastPost msg.data:" + msg.data); for (LastPos posMsg: lastPos.PosList) {
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);
if(SuperVehHash.get(posMsg.imei) != null)
((SuperVehicle)SuperVehHash.get(posMsg.imei)).SetDataFromLastPos(posMsg.lat, posMsg.lng, posMsg.timeGMT, posMsg.speed, posMsg.Address, posMsg.isON);
} }
} }