when selecting a unit from the grid it should be centered with the info bubble opened

This commit is contained in:
CiufudeanDani 2022-04-08 18:40:20 +03:00
parent dcceb360e9
commit f4db909dcb
1 changed files with 18 additions and 20 deletions

View File

@ -89,7 +89,7 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
private boolean isAck = false;
private boolean showVehicle = true;
private int contextMenuPosition;
private int vehStatus;
private int vehStatus, lastItemClicked;
private int position; // vehStatus = vehicle status received from apps
/* Live Vehicle GridView */
@ -255,7 +255,7 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
}
// refresh UI
displayVehicle(true, LAT_OUTLIMIT, LNG_OUTLIMIT);
displayVehicle(LAT_OUTLIMIT, LNG_OUTLIMIT);
});
displayButton = findViewById(R.id.buttonDisplay);
@ -286,11 +286,11 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
}
// refresh UI
displayVehicle(true, LAT_OUTLIMIT, LNG_OUTLIMIT);
displayVehicle(LAT_OUTLIMIT, LNG_OUTLIMIT);
});
// display Vehicles
displayVehicle(true, LAT_OUTLIMIT, LNG_OUTLIMIT);
displayVehicle(LAT_OUTLIMIT, LNG_OUTLIMIT);
// register to receive broadcasts
registerBroadcastIntents();
@ -373,7 +373,7 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
// clear previous vehicles
SM.Debug("onResume");
displayVehicle(true, LAT_OUTLIMIT, LNG_OUTLIMIT);
displayVehicle(LAT_OUTLIMIT, LNG_OUTLIMIT);
}
final Runnable cancelLoadingDialogRUN = LiveActivity.this::cancelLoadingDialog;
@ -442,7 +442,7 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
});
}
public void displayVehicle(boolean withZoom, double latZoom, double lngZoom) {
public void displayVehicle(double latZoom, double lngZoom) {
if (googleMap != null) {
String openWindow = "";
for (Marker marker : markers) {
@ -464,7 +464,7 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
markerOptions.icon(markerIcon);
Marker marker = this.googleMap.addMarker(markerOptions);
if (openWindow.equals(marker.getTitle())) {
if (openWindow.equals(marker.getTitle()) || i == lastItemClicked) {
marker.showInfoWindow();
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(newLocation, 14));
}
@ -474,10 +474,7 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
}
}
}
}
public void showOpenedBalloon(boolean demo) {
//TODO: add show balloon
lastItemClicked = 0;
}
private BitmapDescriptor getProperBitmap(int largeIcon, String text) {
@ -654,7 +651,7 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
}
// Create runnable for posting
final Runnable updateMapResults = () -> displayVehicle(false, LAT_OUTLIMIT, LNG_OUTLIMIT);
final Runnable updateMapResults = () -> displayVehicle(LAT_OUTLIMIT, LNG_OUTLIMIT);
// Create runnable for posting
final Runnable updatePollResults = () -> {
@ -664,7 +661,7 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
adapter.changeDisplayed(position, true);
}
displayVehicle(true, latPoll, lngPoll); };
displayVehicle(latPoll, lngPoll); };
// Create runnable for posting
final Runnable updateOptionsRUN = this::updateOptionsUI;
@ -682,8 +679,9 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
* @param view View in which will do the modifications
*/
private void itemClick(int position, View view) {
lastItemClicked = position;
// change displayed state
displayedVehicles.set(position, !Boolean.TRUE.equals(displayedVehicles.get(position)));
displayedVehicles.set(position, !displayedVehicles.get(position));
// change in the adapter
adapter.changeDisplayed(position, displayedVehicles.get(position));
@ -697,15 +695,15 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
viewLive.imgViewChecked.setImageResource(R.drawable.unchecked);
// check if all values are identical
boolean identical = true;
for (Boolean displ : displayedVehicles)
if (displ != displayedVehicles.get(0)) {
identical = false;
boolean allDisplayed = true;
for (Boolean displayed : displayedVehicles)
if (!displayed) {
allDisplayed = false;
break;
}
// change image when all values are identical
if (identical && displayedVehicles.get(0)) {
if (allDisplayed) {
imageViewCheckAll.setSelected(true);
imageViewCheckAll.setBackgroundResource(R.drawable.check_all);
} else {
@ -714,7 +712,7 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
}
// display vehicle
displayVehicle(true, LAT_OUTLIMIT, LNG_OUTLIMIT);
displayVehicle(LAT_OUTLIMIT, LNG_OUTLIMIT);
}
/**