Add license plate to view

This commit is contained in:
tl 2022-07-01 13:13:40 +02:00
parent 2fc0c4c532
commit 336b0bb57a
4 changed files with 30 additions and 24 deletions

View File

@ -142,14 +142,15 @@ public class ShowVehiclesAndDevicesFragment extends AbstractFragment {
Vehicle vehicle = listVehicles.get(position);
holder.itemView.setTag(vehicle);
holder.itemView.setOnClickListener(v -> {
Log.d(ShowVehiclesAndDevicesFragment.class.getSimpleName(), "Edit " + vehicle.getName());
Log.d(ShowVehiclesAndDevicesFragment.class.getSimpleName(), "Edit " + vehicle.getLicensePlate());
launcherEditVehicle.launch(ActivityBaseDetailContent.getVehicleDetailInstance(getActivity(), vehicle.getVin()));
});
//holder.img.setImageResource(vehicle.getBitmap());
holder.tvDetails.setText(vehicle.getName());
holder.tvLicensePlate.setText(vehicle.getLicensePlate());
holder.tvVin.setText(vehicle.getVin());
holder.imageButton.setOnClickListener(v -> {
holder.tvDetails.setText(getString(R.string.X_Y, vehicle.getBrand(), vehicle.getModel()));
holder.btnDelete.setOnClickListener(v -> {
var dialog = UIUtils.showConfirmationDialog(getContext(), (dialog1, which) -> {
model.deleteVehicle(vehicle);
@ -169,16 +170,18 @@ public class ShowVehiclesAndDevicesFragment extends AbstractFragment {
class ViewHolder extends RecyclerView.ViewHolder {
final ImageView img;
final TextView tvLicensePlate;
final TextView tvVin;
final TextView tvDetails;
final ImageButton imageButton;
final ImageButton btnDelete;
ViewHolder(View view) {
super(view);
img = view.findViewById(R.id.img);
tvDetails = view.findViewById(R.id.tvDetails);
tvLicensePlate = view.findViewById(R.id.tvLicensePlate);
tvVin = view.findViewById(R.id.tvVin);
imageButton = view.findViewById(R.id.btnDelete);
tvDetails = view.findViewById(R.id.tvDetails);
btnDelete = view.findViewById(R.id.btnDelete);
}
}
}

View File

@ -1,20 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/tvVin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/green"
android:textStyle="bold" />
android:id="@+id/tvLicensePlate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/green"
android:textStyle="bold"/>
<TextView
android:id="@+id/tvDetails"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:id="@+id/tvDetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/tvVin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"/>
</LinearLayout>

View File

@ -188,6 +188,7 @@
<string name="btn_logout">Logout</string>
<string name="btn_find">Find</string>
<string name="btn_store">Store</string>
<string name="X_Y">%1$s %2$s</string>
<!--string-array name="languages">
<item>english</item>

View File

@ -38,10 +38,6 @@ public class Vehicle implements Serializable {
this.registrationDate = item.registrationDate;
}
public String getName() {
return brand + " " + model + " " + licensePlate;
}
public boolean equalsIdentification(Vehicle vehicle) {
return vin.equals(vehicle.vin) || licensePlate.equals(vehicle.licensePlate);