added pending status on pets andiord, also made pets automatically switch to pending when an adoption is in pending

This commit is contained in:
Alex
2026-04-13 17:12:41 -06:00
parent 9fdb3087da
commit 688a04c3bc
5 changed files with 23 additions and 7 deletions

View File

@@ -104,10 +104,20 @@ public class PetAdapter extends RecyclerView.Adapter<PetAdapter.PetViewHolder> i
binding.tvPetStatus.setText(pet.getPetStatus());
//Set the status color depending on availability. If available, green, otherwise red
if (pet.getPetStatus() != null && pet.getPetStatus().equals("Available")) {
binding.tvPetStatus.setBackgroundColor(Color.parseColor("#4CAF50"));
if (pet.getPetStatus() != null) {
switch (pet.getPetStatus()) {
case "Available":
binding.tvPetStatus.setBackgroundColor(Color.parseColor("#4CAF50"));
break;
case "Pending":
binding.tvPetStatus.setBackgroundColor(Color.parseColor("#FF9800"));
break;
default:
binding.tvPetStatus.setBackgroundColor(Color.parseColor("#F44336"));
break;
}
} else {
binding.tvPetStatus.setBackgroundColor(Color.parseColor("#F44336"));
binding.tvPetStatus.setBackgroundColor(Color.parseColor("#9E9E9E"));
}
// Load pet image using Glide

View File

@@ -136,7 +136,7 @@ public class PetFragment extends Fragment implements PetAdapter.OnPetClickListen
}
private void setupStatusFilter() {
String[] statuses = {"All Statuses", "Available", "Adopted", "Owned"};
String[] statuses = {"All Statuses", "Available", "Adopted", "Owned", "Pending"};
SpinnerUtils.setupStringFilterSpinner(requireContext(), binding.spinnerStatus, statuses, this::loadPetData);
}

View File

@@ -25,6 +25,7 @@ public class PetDetailViewModel extends ViewModel {
private static final String STATUS_AVAILABLE = "Available";
private static final String STATUS_ADOPTED = "Adopted";
private static final String STATUS_OWNED = "Owned";
private static final String STATUS_PENDING = "Pending";
private final PetRepository petRepository;
private final CustomerRepository customerRepository;
@@ -253,6 +254,7 @@ public class PetDetailViewModel extends ViewModel {
String normalized = status.trim();
if (STATUS_ADOPTED.equalsIgnoreCase(normalized)) return STATUS_ADOPTED;
if (STATUS_OWNED.equalsIgnoreCase(normalized)) return STATUS_OWNED;
if (STATUS_PENDING.equalsIgnoreCase(normalized)) return STATUS_PENDING;
return STATUS_AVAILABLE;
}
@@ -290,7 +292,7 @@ public class PetDetailViewModel extends ViewModel {
public boolean isStoreEnabled = true;
public String modeTitle = "Add Pet";
public String saveButtonText = "Add";
public String[] availableStatuses = new String[]{STATUS_AVAILABLE, STATUS_ADOPTED, STATUS_OWNED};
public String[] availableStatuses = new String[]{STATUS_AVAILABLE, STATUS_ADOPTED, STATUS_OWNED, STATUS_PENDING};
public String selectedStatus = STATUS_AVAILABLE;
public String selectedSpecies = null;
public Long selectedCustomerId = null;