Compare commits

...

2 Commits

2 changed files with 36 additions and 20 deletions

View File

@ -11,9 +11,11 @@ import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
@ -52,6 +54,7 @@ public class HistoryActivity extends AppCompatActivity implements OnMapReadyCall
private final ArrayList<Vehicle> allVehicle = new ArrayList<>();
private final ArrayList<String> allVehicleNames = new ArrayList<>();
private final SimpleDateFormat sdf = new SimpleDateFormat("MMMM dd yyyy");
private boolean showVehicles = true;
@Override
@ -111,6 +114,21 @@ public class HistoryActivity extends AppCompatActivity implements OnMapReadyCall
}
});
LinearLayout slideLayout = findViewById(R.id.slidelayout);
LinearLayout linearLayoutVehicles = findViewById(R.id.layoutBig);
ImageView slideLayoutImageView = findViewById(R.id.slideLayoutImage);
slideLayout.setOnClickListener(v -> {
if (showVehicles) {
linearLayoutVehicles.setVisibility(View.GONE);
slideLayoutImageView.setImageResource(R.drawable.arrow_right);
showVehicles = false;
} else {
linearLayoutVehicles.setVisibility(View.VISIBLE);
slideLayoutImageView.setImageResource(R.drawable.arrow_left);
showVehicles = true;
}
});
setDate();
}

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);
}
/**