Live Page #3

Merged
CiufudeanDani merged 8 commits from feature/live into develop 2022-03-17 08:20:52 +00:00
3 changed files with 22 additions and 41 deletions
Showing only changes of commit 2334dc2e3c - Show all commits

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 emergencyAlarmReceived(int position, double lat, double lng); // --> UpdateEmergencyAlarm
/** Misc */
public AbstractSDParentActivity getParentTab() {
return parentTab;

View File

@ -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;
}

View File

@ -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)
{
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 +++++");
// if (SuperVehHash.get(GPSPos.gpsValue.imei).needUpdate) {
if (AppParams.crtTab == AppParams.Tabs.live) {
SM.Debug("currentActivity instanceof LiveActivity");
try
{
if(liveActivity != null)
try {
if (liveActivity != null)
liveActivity.refreshMap();
}
catch (Exception ex)
{
SM.Debug("Error load hash:"+ex.toString());
}
} 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);
}
}