Close chat #169
@@ -1,11 +1,11 @@
|
||||
package com.example.petstoremobile.adapters;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.view.*;
|
||||
import android.widget.TextView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.example.petstoremobile.R;
|
||||
import com.example.petstoremobile.databinding.ItemAdoptionBinding;
|
||||
import com.example.petstoremobile.dtos.AdoptionDTO;
|
||||
import java.util.List;
|
||||
|
||||
@@ -24,50 +24,46 @@ public class AdoptionAdapter extends RecyclerView.Adapter<AdoptionAdapter.Adopti
|
||||
}
|
||||
|
||||
public static class AdoptionViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView tvCustomerName, tvPetName, tvDate, tvFee, tvStatus;
|
||||
final ItemAdoptionBinding binding;
|
||||
|
||||
public AdoptionViewHolder(@NonNull View v) {
|
||||
super(v);
|
||||
tvCustomerName = v.findViewById(R.id.tvAdoptionCustomerName);
|
||||
tvPetName = v.findViewById(R.id.tvAdoptionPetName);
|
||||
tvDate = v.findViewById(R.id.tvAdoptionDate);
|
||||
tvFee = v.findViewById(R.id.tvAdoptionFee);
|
||||
tvStatus = v.findViewById(R.id.tvAdoptionStatus);
|
||||
public AdoptionViewHolder(@NonNull ItemAdoptionBinding binding) {
|
||||
super(binding.getRoot());
|
||||
this.binding = binding;
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public AdoptionViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.item_adoption, parent, false);
|
||||
return new AdoptionViewHolder(v);
|
||||
ItemAdoptionBinding binding = ItemAdoptionBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
||||
return new AdoptionViewHolder(binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull AdoptionViewHolder holder, int position) {
|
||||
AdoptionDTO a = adoptionList.get(position);
|
||||
ItemAdoptionBinding binding = holder.binding;
|
||||
|
||||
holder.tvCustomerName.setText(a.getCustomerName() != null ? a.getCustomerName() : "");
|
||||
holder.tvPetName.setText("Pet: " + (a.getPetName() != null ? a.getPetName() : ""));
|
||||
holder.tvDate.setText("Date: " + (a.getAdoptionDate() != null ? a.getAdoptionDate() : ""));
|
||||
holder.tvFee.setText(a.getAdoptionFee() != null ? "$" + a.getAdoptionFee() : "");
|
||||
binding.tvAdoptionCustomerName.setText(a.getCustomerName() != null ? a.getCustomerName() : "");
|
||||
binding.tvAdoptionPetName.setText("Pet: " + (a.getPetName() != null ? a.getPetName() : ""));
|
||||
binding.tvAdoptionDate.setText("Date: " + (a.getAdoptionDate() != null ? a.getAdoptionDate() : ""));
|
||||
binding.tvAdoptionFee.setText(a.getAdoptionFee() != null ? "$" + a.getAdoptionFee() : "");
|
||||
|
||||
String status = a.getAdoptionStatus() != null ? a.getAdoptionStatus() : "";
|
||||
holder.tvStatus.setText(status);
|
||||
binding.tvAdoptionStatus.setText(status);
|
||||
|
||||
switch (status) {
|
||||
case "Completed":
|
||||
holder.tvStatus.setBackgroundColor(Color.parseColor("#4CAF50"));
|
||||
binding.tvAdoptionStatus.setBackgroundColor(Color.parseColor("#4CAF50"));
|
||||
break;
|
||||
case "Pending":
|
||||
holder.tvStatus.setBackgroundColor(Color.parseColor("#FF9800"));
|
||||
binding.tvAdoptionStatus.setBackgroundColor(Color.parseColor("#FF9800"));
|
||||
break;
|
||||
case "Rejected":
|
||||
holder.tvStatus.setBackgroundColor(Color.parseColor("#F44336"));
|
||||
binding.tvAdoptionStatus.setBackgroundColor(Color.parseColor("#F44336"));
|
||||
break;
|
||||
default:
|
||||
holder.tvStatus.setBackgroundColor(Color.parseColor("#9E9E9E"));
|
||||
binding.tvAdoptionStatus.setBackgroundColor(Color.parseColor("#9E9E9E"));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,12 +2,10 @@ package com.example.petstoremobile.adapters;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.example.petstoremobile.R;
|
||||
import com.example.petstoremobile.databinding.ItemAppointmentBinding;
|
||||
import com.example.petstoremobile.dtos.AppointmentDTO;
|
||||
import java.util.List;
|
||||
|
||||
@@ -27,50 +25,48 @@ public class AppointmentAdapter extends RecyclerView.Adapter<AppointmentAdapter.
|
||||
}
|
||||
|
||||
public static class AppointmentViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView tvCustomerName, tvPetName, tvServiceType, tvDateTime, tvAppointmentStatus;
|
||||
private final ItemAppointmentBinding binding;
|
||||
|
||||
public AppointmentViewHolder(@NonNull View v) {
|
||||
super(v);
|
||||
tvCustomerName = v.findViewById(R.id.tvCustomerName);
|
||||
tvPetName = v.findViewById(R.id.tvApptPetName);
|
||||
tvServiceType = v.findViewById(R.id.tvServiceType);
|
||||
tvDateTime = v.findViewById(R.id.tvDateTime);
|
||||
tvAppointmentStatus = v.findViewById(R.id.tvAppointmentStatus);
|
||||
public AppointmentViewHolder(@NonNull ItemAppointmentBinding binding) {
|
||||
super(binding.getRoot());
|
||||
this.binding = binding;
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public AppointmentViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_appointment, parent, false);
|
||||
return new AppointmentViewHolder(v);
|
||||
ItemAppointmentBinding binding = ItemAppointmentBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
||||
return new AppointmentViewHolder(binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull AppointmentViewHolder holder, int position) {
|
||||
AppointmentDTO a = appointmentList.get(position);
|
||||
ItemAppointmentBinding binding = holder.binding;
|
||||
|
||||
holder.tvCustomerName.setText(a.getCustomerName() != null ? a.getCustomerName() : "");
|
||||
holder.tvPetName.setText("Pet: " + (a.getPetName() != null ? a.getPetName() : ""));
|
||||
holder.tvServiceType.setText(a.getServiceType() != null ? a.getServiceType() : "");
|
||||
holder.tvDateTime.setText((a.getAppointmentDate() != null ? a.getAppointmentDate() : "") +
|
||||
binding.tvCustomerName.setText(a.getCustomerName() != null ? a.getCustomerName() : "");
|
||||
binding.tvApptPetName.setText("Pet: " + (a.getPetName() != null ? a.getPetName() : ""));
|
||||
binding.tvServiceType.setText(a.getServiceType() != null ? a.getServiceType() : "");
|
||||
binding.tvStaffName.setText("Staff: " + (a.getEmployeeName() != null ? a.getEmployeeName() : "Unassigned"));
|
||||
binding.tvDateTime.setText((a.getAppointmentDate() != null ? a.getAppointmentDate() : "") +
|
||||
" at " + (a.getAppointmentTime() != null ? a.getAppointmentTime() : ""));
|
||||
|
||||
String status = a.getStatus() != null ? a.getStatus() : "";
|
||||
holder.tvAppointmentStatus.setText(status);
|
||||
binding.tvAppointmentStatus.setText(status);
|
||||
|
||||
switch (status.toUpperCase()) {
|
||||
case "BOOKED":
|
||||
holder.tvAppointmentStatus.setBackgroundColor(Color.parseColor("#2196F3")); // blue
|
||||
binding.tvAppointmentStatus.setBackgroundColor(Color.parseColor("#2196F3")); // blue
|
||||
break;
|
||||
case "COMPLETED":
|
||||
holder.tvAppointmentStatus.setBackgroundColor(Color.parseColor("#4CAF50")); // green
|
||||
binding.tvAppointmentStatus.setBackgroundColor(Color.parseColor("#4CAF50")); // green
|
||||
break;
|
||||
case "CANCELLED":
|
||||
holder.tvAppointmentStatus.setBackgroundColor(Color.parseColor("#F44336")); // red
|
||||
binding.tvAppointmentStatus.setBackgroundColor(Color.parseColor("#F44336")); // red
|
||||
break;
|
||||
default:
|
||||
holder.tvAppointmentStatus.setBackgroundColor(Color.parseColor("#9E9E9E")); // gray
|
||||
binding.tvAppointmentStatus.setBackgroundColor(Color.parseColor("#9E9E9E")); // gray
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -81,4 +77,4 @@ public class AppointmentAdapter extends RecyclerView.Adapter<AppointmentAdapter.
|
||||
public int getItemCount() {
|
||||
return appointmentList.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,12 @@
|
||||
package com.example.petstoremobile.adapters;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.petstoremobile.R;
|
||||
import com.example.petstoremobile.databinding.ItemChatBinding;
|
||||
import com.example.petstoremobile.models.Chat;
|
||||
|
||||
import java.util.List;
|
||||
@@ -30,15 +28,15 @@ public class ChatAdapter extends RecyclerView.Adapter<ChatAdapter.ChatViewHolder
|
||||
@NonNull
|
||||
@Override
|
||||
public ChatViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_chat, parent, false);
|
||||
return new ChatViewHolder(view);
|
||||
ItemChatBinding binding = ItemChatBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
||||
return new ChatViewHolder(binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ChatViewHolder holder, int position) {
|
||||
Chat chat = chatList.get(position);
|
||||
holder.tvCustomerName.setText(chat.getCustomerName());
|
||||
holder.tvLastMessage.setText(chat.getLastMessage());
|
||||
holder.binding.tvCustomerName.setText(chat.getCustomerName());
|
||||
holder.binding.tvLastMessage.setText(chat.getLastMessage());
|
||||
holder.itemView.setOnClickListener(v -> listener.onChatClick(chat));
|
||||
}
|
||||
|
||||
@@ -48,12 +46,11 @@ public class ChatAdapter extends RecyclerView.Adapter<ChatAdapter.ChatViewHolder
|
||||
}
|
||||
|
||||
public static class ChatViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView tvCustomerName, tvLastMessage;
|
||||
final ItemChatBinding binding;
|
||||
|
||||
public ChatViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
tvCustomerName = itemView.findViewById(R.id.tvCustomerName);
|
||||
tvLastMessage = itemView.findViewById(R.id.tvLastMessage);
|
||||
public ChatViewHolder(@NonNull ItemChatBinding binding) {
|
||||
super(binding.getRoot());
|
||||
this.binding = binding;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,13 +4,11 @@ import android.graphics.Color;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.petstoremobile.R;
|
||||
import com.example.petstoremobile.databinding.ItemInventoryBinding;
|
||||
import com.example.petstoremobile.dtos.InventoryDTO;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -35,68 +33,61 @@ public class InventoryAdapter extends RecyclerView.Adapter<InventoryAdapter.Inve
|
||||
}
|
||||
|
||||
public static class InventoryViewHolder extends RecyclerView.ViewHolder {
|
||||
// Matches desktop table columns: Inventory ID, Product ID, Product Name,
|
||||
// Quantity
|
||||
TextView tvInventoryId, tvProdId, tvProductName, tvQuantity;
|
||||
CheckBox checkBox;
|
||||
final ItemInventoryBinding binding;
|
||||
|
||||
public InventoryViewHolder(@NonNull View v) {
|
||||
super(v);
|
||||
tvInventoryId = v.findViewById(R.id.tvInventoryId);
|
||||
tvProdId = v.findViewById(R.id.tvProdId);
|
||||
tvProductName = v.findViewById(R.id.tvProductName);
|
||||
tvQuantity = v.findViewById(R.id.tvQuantity);
|
||||
checkBox = v.findViewById(R.id.cbSelectInventory);
|
||||
public InventoryViewHolder(@NonNull ItemInventoryBinding binding) {
|
||||
super(binding.getRoot());
|
||||
this.binding = binding;
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public InventoryViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.item_inventory, parent, false);
|
||||
return new InventoryViewHolder(v);
|
||||
ItemInventoryBinding binding = ItemInventoryBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
||||
return new InventoryViewHolder(binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull InventoryViewHolder holder, int position) {
|
||||
InventoryDTO inv = inventoryList.get(position);
|
||||
ItemInventoryBinding binding = holder.binding;
|
||||
|
||||
// Column: Inventory ID
|
||||
String invIdStr = inv.getInventoryId() != null ? String.valueOf(inv.getInventoryId()) : "—";
|
||||
holder.tvInventoryId.setText("Inv ID: " + invIdStr);
|
||||
binding.tvInventoryId.setText("Inv ID: " + invIdStr);
|
||||
|
||||
// Column: Product ID
|
||||
String prodIdStr = inv.getProdId() != null ? String.valueOf(inv.getProdId()) : "—";
|
||||
holder.tvProdId.setText("Prod ID: " + prodIdStr);
|
||||
binding.tvProdId.setText("Prod ID: " + prodIdStr);
|
||||
|
||||
// Column: Product Name
|
||||
holder.tvProductName.setText(inv.getProductName() != null ? inv.getProductName() : "—");
|
||||
binding.tvProductName.setText(inv.getProductName() != null ? inv.getProductName() : "—");
|
||||
|
||||
// Column: Quantity
|
||||
int qty = inv.getQuantity() != null ? inv.getQuantity() : 0;
|
||||
holder.tvQuantity.setText(String.valueOf(qty));
|
||||
binding.tvQuantity.setText(String.valueOf(qty));
|
||||
|
||||
// Low stock = red, normal = green (like desktop reorder concept)
|
||||
if (qty <= 5) {
|
||||
holder.tvQuantity.setTextColor(Color.parseColor("#F44336"));
|
||||
binding.tvQuantity.setTextColor(Color.parseColor("#F44336"));
|
||||
} else {
|
||||
holder.tvQuantity.setTextColor(Color.parseColor("#4CAF50"));
|
||||
binding.tvQuantity.setTextColor(Color.parseColor("#4CAF50"));
|
||||
}
|
||||
|
||||
// Bulk delete selection mode
|
||||
if (selectionMode) {
|
||||
holder.checkBox.setVisibility(View.VISIBLE);
|
||||
holder.checkBox.setChecked(inv.getInventoryId() != null
|
||||
binding.cbSelectInventory.setVisibility(View.VISIBLE);
|
||||
binding.cbSelectInventory.setChecked(inv.getInventoryId() != null
|
||||
&& selectedIds.contains(inv.getInventoryId()));
|
||||
} else {
|
||||
holder.checkBox.setVisibility(View.GONE);
|
||||
holder.checkBox.setChecked(false);
|
||||
binding.cbSelectInventory.setVisibility(View.GONE);
|
||||
binding.cbSelectInventory.setChecked(false);
|
||||
}
|
||||
|
||||
holder.itemView.setOnClickListener(v -> {
|
||||
if (selectionMode) {
|
||||
toggleSelection(inv.getInventoryId(), holder.checkBox);
|
||||
toggleSelection(inv.getInventoryId(), binding.cbSelectInventory);
|
||||
} else {
|
||||
clickListener.onInventoryClick(holder.getAdapterPosition());
|
||||
}
|
||||
@@ -105,14 +96,14 @@ public class InventoryAdapter extends RecyclerView.Adapter<InventoryAdapter.Inve
|
||||
holder.itemView.setOnLongClickListener(v -> {
|
||||
if (!selectionMode) {
|
||||
selectionMode = true;
|
||||
toggleSelection(inv.getInventoryId(), holder.checkBox);
|
||||
toggleSelection(inv.getInventoryId(), binding.cbSelectInventory);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
private void toggleSelection(Long id, CheckBox checkBox) {
|
||||
private void toggleSelection(Long id, android.widget.CheckBox checkBox) {
|
||||
if (id == null)
|
||||
return;
|
||||
if (selectedIds.contains(id)) {
|
||||
|
||||
@@ -12,6 +12,8 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
import com.bumptech.glide.load.model.GlideUrl;
|
||||
import com.bumptech.glide.load.model.LazyHeaders;
|
||||
import com.example.petstoremobile.R;
|
||||
import com.example.petstoremobile.databinding.ItemMessageReceivedBinding;
|
||||
import com.example.petstoremobile.databinding.ItemMessageSentBinding;
|
||||
import com.example.petstoremobile.models.Message;
|
||||
import java.util.List;
|
||||
|
||||
@@ -51,11 +53,11 @@ public class MessageAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
LayoutInflater inf = LayoutInflater.from(parent.getContext());
|
||||
if (viewType == TYPE_SENT) {
|
||||
View v = inf.inflate(R.layout.item_message_sent, parent, false);
|
||||
return new SentHolder(v);
|
||||
ItemMessageSentBinding binding = ItemMessageSentBinding.inflate(inf, parent, false);
|
||||
return new SentHolder(binding);
|
||||
} else {
|
||||
View v = inf.inflate(R.layout.item_message_received, parent, false);
|
||||
return new ReceivedHolder(v);
|
||||
ItemMessageReceivedBinding binding = ItemMessageReceivedBinding.inflate(inf, parent, false);
|
||||
return new ReceivedHolder(binding);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,32 +71,26 @@ public class MessageAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||
@Override public int getItemCount() { return messages.size(); }
|
||||
|
||||
static class SentHolder extends RecyclerView.ViewHolder {
|
||||
TextView tvMessage, tvAttachmentName;
|
||||
ImageView ivAttachment;
|
||||
SentHolder(View v) {
|
||||
super(v);
|
||||
tvMessage = v.findViewById(R.id.tvMessageContent);
|
||||
tvAttachmentName = v.findViewById(R.id.tvAttachmentName);
|
||||
ivAttachment = v.findViewById(R.id.ivAttachment);
|
||||
final ItemMessageSentBinding binding;
|
||||
SentHolder(ItemMessageSentBinding binding) {
|
||||
super(binding.getRoot());
|
||||
this.binding = binding;
|
||||
}
|
||||
void bind(Message m, String token) {
|
||||
tvMessage.setText(m.getContent());
|
||||
displayAttachment(m, ivAttachment, tvAttachmentName, token);
|
||||
binding.tvMessageContent.setText(m.getContent());
|
||||
displayAttachment(m, binding.ivAttachment, binding.tvAttachmentName, token);
|
||||
}
|
||||
}
|
||||
|
||||
static class ReceivedHolder extends RecyclerView.ViewHolder {
|
||||
TextView tvMessage, tvAttachmentName;
|
||||
ImageView ivAttachment;
|
||||
ReceivedHolder(View v) {
|
||||
super(v);
|
||||
tvMessage = v.findViewById(R.id.tvMessageContent);
|
||||
tvAttachmentName = v.findViewById(R.id.tvAttachmentName);
|
||||
ivAttachment = v.findViewById(R.id.ivAttachment);
|
||||
final ItemMessageReceivedBinding binding;
|
||||
ReceivedHolder(ItemMessageReceivedBinding binding) {
|
||||
super(binding.getRoot());
|
||||
this.binding = binding;
|
||||
}
|
||||
void bind(Message m, String token) {
|
||||
tvMessage.setText(m.getContent());
|
||||
displayAttachment(m, ivAttachment, tvAttachmentName, token);
|
||||
binding.tvMessageContent.setText(m.getContent());
|
||||
displayAttachment(m, binding.ivAttachment, binding.tvAttachmentName, token);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,15 +2,13 @@ package com.example.petstoremobile.adapters;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.petstoremobile.R;
|
||||
import com.example.petstoremobile.api.PetApi;
|
||||
import com.example.petstoremobile.databinding.ItemPetBinding;
|
||||
import com.example.petstoremobile.dtos.PetDTO;
|
||||
import com.example.petstoremobile.utils.GlideUtils;
|
||||
import java.util.List;
|
||||
@@ -43,17 +41,11 @@ public class PetAdapter extends RecyclerView.Adapter<PetAdapter.PetViewHolder> {
|
||||
|
||||
// Get the controls of each row in recycler view
|
||||
public static class PetViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView tvPetName, tvPetSpeciesBreed, tvPetAge, tvPetPrice, tvPetStatus;
|
||||
ImageView ivPetProfile;
|
||||
private final ItemPetBinding binding;
|
||||
|
||||
public PetViewHolder(@NonNull View v) {
|
||||
super(v);
|
||||
tvPetName = v.findViewById(R.id.tvPetName);
|
||||
tvPetSpeciesBreed = v.findViewById(R.id.tvPetSpeciesBreed);
|
||||
tvPetAge = v.findViewById(R.id.tvPetAge);
|
||||
tvPetPrice = v.findViewById(R.id.tvPetPrice);
|
||||
tvPetStatus = v.findViewById(R.id.tvPetStatus);
|
||||
ivPetProfile = v.findViewById(R.id.ivPetProfile);
|
||||
public PetViewHolder(@NonNull ItemPetBinding binding) {
|
||||
super(binding.getRoot());
|
||||
this.binding = binding;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,41 +53,42 @@ public class PetAdapter extends RecyclerView.Adapter<PetAdapter.PetViewHolder> {
|
||||
@NonNull
|
||||
@Override
|
||||
public PetViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_pet, parent, false);
|
||||
return new PetViewHolder(v);
|
||||
ItemPetBinding binding = ItemPetBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
||||
return new PetViewHolder(binding);
|
||||
}
|
||||
|
||||
//populate the row with pet data
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull PetViewHolder holder, int position) {
|
||||
PetDTO pet = petList.get(position);
|
||||
ItemPetBinding binding = holder.binding;
|
||||
|
||||
holder.tvPetName.setText(pet.getPetName());
|
||||
holder.tvPetSpeciesBreed.setText(pet.getPetSpecies() + " - " + pet.getPetBreed());
|
||||
holder.tvPetAge.setText("Age: " + pet.getPetAge() + " yr(s)");
|
||||
binding.tvPetName.setText(pet.getPetName());
|
||||
binding.tvPetSpeciesBreed.setText(pet.getPetSpecies() + " - " + pet.getPetBreed());
|
||||
binding.tvPetAge.setText("Age: " + pet.getPetAge() + " yr(s)");
|
||||
|
||||
Double price = pet.getPetPrice();
|
||||
if (price != null) {
|
||||
holder.tvPetPrice.setText("$" + String.format("%.2f", price));
|
||||
binding.tvPetPrice.setText("$" + String.format("%.2f", price));
|
||||
} else {
|
||||
holder.tvPetPrice.setText("$0.00");
|
||||
binding.tvPetPrice.setText("$0.00");
|
||||
}
|
||||
|
||||
holder.tvPetStatus.setText(pet.getPetStatus());
|
||||
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")) {
|
||||
holder.tvPetStatus.setBackgroundColor(Color.parseColor("#4CAF50"));
|
||||
binding.tvPetStatus.setBackgroundColor(Color.parseColor("#4CAF50"));
|
||||
} else {
|
||||
holder.tvPetStatus.setBackgroundColor(Color.parseColor("#F44336"));
|
||||
binding.tvPetStatus.setBackgroundColor(Color.parseColor("#F44336"));
|
||||
}
|
||||
|
||||
// Load pet image using Glide
|
||||
if (baseUrl != null) {
|
||||
String imageUrl = baseUrl + String.format(PetApi.PET_IMAGE_PATH, pet.getPetId());
|
||||
GlideUtils.loadImageWithTokenCircle(holder.itemView.getContext(), holder.ivPetProfile, imageUrl, token, R.drawable.placeholder);
|
||||
GlideUtils.loadImageWithTokenCircle(holder.itemView.getContext(), binding.ivPetProfile, imageUrl, token, R.drawable.placeholder);
|
||||
} else {
|
||||
holder.ivPetProfile.setImageResource(R.drawable.placeholder);
|
||||
binding.ivPetProfile.setImageResource(R.drawable.placeholder);
|
||||
}
|
||||
|
||||
//when a row is clicked, open the detail view
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.example.petstoremobile.adapters;
|
||||
|
||||
import android.view.*;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.petstoremobile.R;
|
||||
import com.example.petstoremobile.api.ProductApi;
|
||||
import com.example.petstoremobile.databinding.ItemProductBinding;
|
||||
import com.example.petstoremobile.dtos.ProductDTO;
|
||||
import com.example.petstoremobile.utils.GlideUtils;
|
||||
import java.util.List;
|
||||
@@ -37,41 +36,37 @@ public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.ProductV
|
||||
}
|
||||
|
||||
public static class ProductViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView tvName, tvCategory, tvDesc, tvPrice;
|
||||
ImageView ivProductImage;
|
||||
final ItemProductBinding binding;
|
||||
|
||||
public ProductViewHolder(@NonNull View v) {
|
||||
super(v);
|
||||
tvName = v.findViewById(R.id.tvProductName);
|
||||
tvCategory = v.findViewById(R.id.tvProductCategory);
|
||||
tvDesc = v.findViewById(R.id.tvProductDesc);
|
||||
tvPrice = v.findViewById(R.id.tvProductPrice);
|
||||
ivProductImage = v.findViewById(R.id.ivProductImage);
|
||||
public ProductViewHolder(@NonNull ItemProductBinding binding) {
|
||||
super(binding.getRoot());
|
||||
this.binding = binding;
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ProductViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.item_product, parent, false);
|
||||
return new ProductViewHolder(v);
|
||||
ItemProductBinding binding = ItemProductBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
||||
return new ProductViewHolder(binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ProductViewHolder holder, int position) {
|
||||
ProductDTO p = productList.get(position);
|
||||
holder.tvName.setText(p.getProdName() != null ? p.getProdName() : "");
|
||||
holder.tvCategory.setText("Category: " + (p.getCategoryName() != null ? p.getCategoryName() : ""));
|
||||
holder.tvDesc.setText(p.getProdDesc() != null ? p.getProdDesc() : "");
|
||||
holder.tvPrice.setText(p.getProdPrice() != null ? "$" + p.getProdPrice() : "");
|
||||
ItemProductBinding binding = holder.binding;
|
||||
|
||||
binding.tvProductName.setText(p.getProdName() != null ? p.getProdName() : "");
|
||||
binding.tvProductCategory.setText("Category: " + (p.getCategoryName() != null ? p.getCategoryName() : ""));
|
||||
binding.tvProductDesc.setText(p.getProdDesc() != null ? p.getProdDesc() : "");
|
||||
binding.tvProductPrice.setText(p.getProdPrice() != null ? "$" + p.getProdPrice() : "");
|
||||
|
||||
// Load product image using Glide
|
||||
if (baseUrl != null) {
|
||||
String imageUrl = baseUrl + String.format(ProductApi.PRODUCT_IMAGE_PATH, p.getProdId());
|
||||
GlideUtils.loadImageWithTokenCircle(holder.itemView.getContext(), holder.ivProductImage, imageUrl, token, R.drawable.placeholder);
|
||||
GlideUtils.loadImageWithTokenCircle(holder.itemView.getContext(), binding.ivProductImage, imageUrl, token, R.drawable.placeholder);
|
||||
} else {
|
||||
holder.ivProductImage.setImageResource(R.drawable.placeholder);
|
||||
binding.ivProductImage.setImageResource(R.drawable.placeholder);
|
||||
}
|
||||
|
||||
holder.itemView.setOnClickListener(v -> listener.onProductClick(position));
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.example.petstoremobile.adapters;
|
||||
|
||||
import android.view.*;
|
||||
import android.widget.TextView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.example.petstoremobile.R;
|
||||
import com.example.petstoremobile.databinding.ItemProductSupplierBinding;
|
||||
import com.example.petstoremobile.dtos.ProductSupplierDTO;
|
||||
import java.util.List;
|
||||
|
||||
@@ -23,30 +23,29 @@ public class ProductSupplierAdapter extends RecyclerView.Adapter<ProductSupplier
|
||||
}
|
||||
|
||||
public static class PSViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView tvProductName, tvSupplierName, tvCost;
|
||||
final ItemProductSupplierBinding binding;
|
||||
|
||||
public PSViewHolder(@NonNull View v) {
|
||||
super(v);
|
||||
tvProductName = v.findViewById(R.id.tvPSProductName);
|
||||
tvSupplierName = v.findViewById(R.id.tvPSSupplierName);
|
||||
tvCost = v.findViewById(R.id.tvPSCost);
|
||||
public PSViewHolder(@NonNull ItemProductSupplierBinding binding) {
|
||||
super(binding.getRoot());
|
||||
this.binding = binding;
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public PSViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.item_product_supplier, parent, false);
|
||||
return new PSViewHolder(v);
|
||||
ItemProductSupplierBinding binding = ItemProductSupplierBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
||||
return new PSViewHolder(binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull PSViewHolder holder, int position) {
|
||||
ProductSupplierDTO ps = list.get(position);
|
||||
holder.tvProductName.setText(ps.getProductName() != null ? ps.getProductName() : "");
|
||||
holder.tvSupplierName.setText("Supplier: " + (ps.getSupplierName() != null ? ps.getSupplierName() : ""));
|
||||
holder.tvCost.setText(ps.getCost() != null ? "Cost: $" + ps.getCost() : "");
|
||||
ItemProductSupplierBinding binding = holder.binding;
|
||||
|
||||
binding.tvPSProductName.setText(ps.getProductName() != null ? ps.getProductName() : "");
|
||||
binding.tvPSSupplierName.setText("Supplier: " + (ps.getSupplierName() != null ? ps.getSupplierName() : ""));
|
||||
binding.tvPSCost.setText(ps.getCost() != null ? "Cost: $" + ps.getCost() : "");
|
||||
holder.itemView.setOnClickListener(v -> listener.onProductSupplierClick(position));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.example.petstoremobile.adapters;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.view.*;
|
||||
import android.widget.TextView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.example.petstoremobile.R;
|
||||
import com.example.petstoremobile.databinding.ItemPurchaseOrderBinding;
|
||||
import com.example.petstoremobile.dtos.PurchaseOrderDTO;
|
||||
import java.util.List;
|
||||
|
||||
@@ -24,47 +24,45 @@ public class PurchaseOrderAdapter extends RecyclerView.Adapter<PurchaseOrderAdap
|
||||
}
|
||||
|
||||
public static class POViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView tvId, tvSupplier, tvDate, tvStatus;
|
||||
final ItemPurchaseOrderBinding binding;
|
||||
|
||||
public POViewHolder(@NonNull View v) {
|
||||
super(v);
|
||||
tvId = v.findViewById(R.id.tvPOId);
|
||||
tvSupplier = v.findViewById(R.id.tvPOSupplier);
|
||||
tvDate = v.findViewById(R.id.tvPODate);
|
||||
tvStatus = v.findViewById(R.id.tvPOStatus);
|
||||
public POViewHolder(@NonNull ItemPurchaseOrderBinding binding) {
|
||||
super(binding.getRoot());
|
||||
this.binding = binding;
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public POViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.item_purchase_order, parent, false);
|
||||
return new POViewHolder(v);
|
||||
ItemPurchaseOrderBinding binding = ItemPurchaseOrderBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
||||
return new POViewHolder(binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull POViewHolder holder, int position) {
|
||||
PurchaseOrderDTO po = list.get(position);
|
||||
holder.tvId.setText("PO #" + (po.getPurchaseOrderId() != null ? po.getPurchaseOrderId() : ""));
|
||||
holder.tvSupplier.setText("Supplier: " + (po.getSupplierName() != null ? po.getSupplierName() : ""));
|
||||
holder.tvDate.setText("Date: " + (po.getOrderDate() != null ? po.getOrderDate() : ""));
|
||||
ItemPurchaseOrderBinding binding = holder.binding;
|
||||
|
||||
binding.tvPOId.setText("PO #" + (po.getPurchaseOrderId() != null ? po.getPurchaseOrderId() : ""));
|
||||
binding.tvPOSupplier.setText("Supplier: " + (po.getSupplierName() != null ? po.getSupplierName() : ""));
|
||||
binding.tvPODate.setText("Date: " + (po.getOrderDate() != null ? po.getOrderDate() : ""));
|
||||
|
||||
String status = po.getStatus() != null ? po.getStatus() : "";
|
||||
holder.tvStatus.setText(status);
|
||||
binding.tvPOStatus.setText(status);
|
||||
|
||||
switch (status) {
|
||||
case "Completed":
|
||||
holder.tvStatus.setBackgroundColor(Color.parseColor("#4CAF50"));
|
||||
binding.tvPOStatus.setBackgroundColor(Color.parseColor("#4CAF50"));
|
||||
break;
|
||||
case "Pending":
|
||||
holder.tvStatus.setBackgroundColor(Color.parseColor("#FF9800"));
|
||||
binding.tvPOStatus.setBackgroundColor(Color.parseColor("#FF9800"));
|
||||
break;
|
||||
case "Cancelled":
|
||||
holder.tvStatus.setBackgroundColor(Color.parseColor("#F44336"));
|
||||
binding.tvPOStatus.setBackgroundColor(Color.parseColor("#F44336"));
|
||||
break;
|
||||
default:
|
||||
holder.tvStatus.setBackgroundColor(Color.parseColor("#9E9E9E"));
|
||||
binding.tvPOStatus.setBackgroundColor(Color.parseColor("#9E9E9E"));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,9 @@ import android.graphics.Color;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.example.petstoremobile.R;
|
||||
import com.example.petstoremobile.databinding.ItemSaleBinding;
|
||||
import com.example.petstoremobile.models.Sale;
|
||||
import java.util.List;
|
||||
|
||||
@@ -26,46 +25,41 @@ public class SaleAdapter extends RecyclerView.Adapter<SaleAdapter.SaleViewHolder
|
||||
}
|
||||
|
||||
public static class SaleViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView tvSaleId, tvItemName, tvEmployeeName, tvSaleDate, tvTotal, tvPaymentMethod, tvRefundBadge;
|
||||
final ItemSaleBinding binding;
|
||||
|
||||
public SaleViewHolder(@NonNull View v) {
|
||||
super(v);
|
||||
tvSaleId = v.findViewById(R.id.tvSaleId);
|
||||
tvItemName = v.findViewById(R.id.tvSaleItemName);
|
||||
tvEmployeeName = v.findViewById(R.id.tvSaleEmployee);
|
||||
tvSaleDate = v.findViewById(R.id.tvSaleDate);
|
||||
tvTotal = v.findViewById(R.id.tvSaleTotal);
|
||||
tvPaymentMethod = v.findViewById(R.id.tvSalePayment);
|
||||
tvRefundBadge = v.findViewById(R.id.tvRefundBadge);
|
||||
public SaleViewHolder(@NonNull ItemSaleBinding binding) {
|
||||
super(binding.getRoot());
|
||||
this.binding = binding;
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public SaleViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_sale, parent, false);
|
||||
return new SaleViewHolder(v);
|
||||
ItemSaleBinding binding = ItemSaleBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
||||
return new SaleViewHolder(binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull SaleViewHolder holder, int position) {
|
||||
Sale sale = saleList.get(position);
|
||||
ItemSaleBinding binding = holder.binding;
|
||||
|
||||
holder.tvSaleId.setText("ID: " + sale.getSaleId());
|
||||
holder.tvItemName.setText(sale.getItemName());
|
||||
holder.tvEmployeeName.setText("By: " + sale.getEmployeeName());
|
||||
holder.tvSaleDate.setText(sale.getSaleDate());
|
||||
holder.tvTotal.setText("$" + String.format("%.2f", sale.getTotal()));
|
||||
holder.tvPaymentMethod.setText(sale.getPaymentMethod());
|
||||
binding.tvSaleId.setText("ID: " + sale.getSaleId());
|
||||
binding.tvSaleItemName.setText(sale.getItemName());
|
||||
binding.tvSaleEmployee.setText("By: " + sale.getEmployeeName());
|
||||
binding.tvSaleDate.setText(sale.getSaleDate());
|
||||
binding.tvSaleTotal.setText("$" + String.format("%.2f", sale.getTotal()));
|
||||
binding.tvSalePayment.setText(sale.getPaymentMethod());
|
||||
|
||||
// Show refund badge if it's a refund
|
||||
if (sale.isRefund()) {
|
||||
holder.tvRefundBadge.setVisibility(View.VISIBLE);
|
||||
holder.tvRefundBadge.setBackgroundColor(Color.parseColor("#F44336"));
|
||||
holder.tvTotal.setTextColor(Color.parseColor("#F44336"));
|
||||
binding.tvRefundBadge.setVisibility(View.VISIBLE);
|
||||
binding.tvRefundBadge.setBackgroundColor(Color.parseColor("#F44336"));
|
||||
binding.tvSaleTotal.setTextColor(Color.parseColor("#F44336"));
|
||||
} else {
|
||||
holder.tvRefundBadge.setVisibility(View.GONE);
|
||||
holder.tvTotal.setTextColor(Color.parseColor("#4CAF50"));
|
||||
binding.tvRefundBadge.setVisibility(View.GONE);
|
||||
binding.tvSaleTotal.setTextColor(Color.parseColor("#4CAF50"));
|
||||
}
|
||||
|
||||
holder.itemView.setOnClickListener(v -> saleClickListener.onSaleClick(position));
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package com.example.petstoremobile.adapters;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.example.petstoremobile.R;
|
||||
import com.example.petstoremobile.databinding.ItemServiceBinding;
|
||||
import com.example.petstoremobile.dtos.ServiceDTO;
|
||||
import java.util.List;
|
||||
|
||||
@@ -28,14 +26,11 @@ public class ServiceAdapter extends RecyclerView.Adapter<ServiceAdapter.ServiceV
|
||||
|
||||
// Get the controls of each row in recycler view
|
||||
public static class ServiceViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView tvServiceName, tvServiceDesc, tvServiceDuration, tvServicePrice;
|
||||
final ItemServiceBinding binding;
|
||||
|
||||
public ServiceViewHolder(@NonNull View v) {
|
||||
super(v);
|
||||
tvServiceName = v.findViewById(R.id.tvServiceName);
|
||||
tvServiceDesc = v.findViewById(R.id.tvServiceDesc);
|
||||
tvServiceDuration = v.findViewById(R.id.tvServiceDuration);
|
||||
tvServicePrice = v.findViewById(R.id.tvServicePrice);
|
||||
public ServiceViewHolder(@NonNull ItemServiceBinding binding) {
|
||||
super(binding.getRoot());
|
||||
this.binding = binding;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,19 +38,20 @@ public class ServiceAdapter extends RecyclerView.Adapter<ServiceAdapter.ServiceV
|
||||
@NonNull
|
||||
@Override
|
||||
public ServiceViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_service, parent, false);
|
||||
return new ServiceViewHolder(v);
|
||||
ItemServiceBinding binding = ItemServiceBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
||||
return new ServiceViewHolder(binding);
|
||||
}
|
||||
|
||||
//populate the row with service data
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ServiceViewHolder holder, int position) {
|
||||
ServiceDTO service = serviceList.get(position);
|
||||
ItemServiceBinding binding = holder.binding;
|
||||
|
||||
holder.tvServiceName.setText(service.getServiceName());
|
||||
holder.tvServiceDesc.setText(service.getServiceDesc());
|
||||
holder.tvServiceDuration.setText("Duration: " + service.getServiceDuration() + " min");
|
||||
holder.tvServicePrice.setText("$" + String.format("%.2f", service.getServicePrice()));
|
||||
binding.tvServiceName.setText(service.getServiceName());
|
||||
binding.tvServiceDesc.setText(service.getServiceDesc());
|
||||
binding.tvServiceDuration.setText("Duration: " + service.getServiceDuration() + " min");
|
||||
binding.tvServicePrice.setText("$" + String.format("%.2f", service.getServicePrice()));
|
||||
|
||||
//when a row is clicked, open the detail view
|
||||
holder.itemView.setOnClickListener(v -> serviceClickListener.onServiceClick(position));
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package com.example.petstoremobile.adapters;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.example.petstoremobile.R;
|
||||
import com.example.petstoremobile.databinding.ItemSupplierBinding;
|
||||
import com.example.petstoremobile.dtos.SupplierDTO;
|
||||
import java.util.List;
|
||||
|
||||
@@ -28,14 +26,11 @@ public class SupplierAdapter extends RecyclerView.Adapter<SupplierAdapter.Suppli
|
||||
|
||||
// Get the controls of each row in recycler view
|
||||
public static class SupplierViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView tvSupCompany, tvSupContactName, tvSupEmail, tvSupPhone;
|
||||
final ItemSupplierBinding binding;
|
||||
|
||||
public SupplierViewHolder(@NonNull View v) {
|
||||
super(v);
|
||||
tvSupCompany = v.findViewById(R.id.tvSupCompany);
|
||||
tvSupContactName = v.findViewById(R.id.tvSupContactName);
|
||||
tvSupEmail = v.findViewById(R.id.tvSupEmail);
|
||||
tvSupPhone = v.findViewById(R.id.tvSupPhone);
|
||||
public SupplierViewHolder(@NonNull ItemSupplierBinding binding) {
|
||||
super(binding.getRoot());
|
||||
this.binding = binding;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,19 +38,20 @@ public class SupplierAdapter extends RecyclerView.Adapter<SupplierAdapter.Suppli
|
||||
@NonNull
|
||||
@Override
|
||||
public SupplierViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_supplier, parent, false);
|
||||
return new SupplierViewHolder(v);
|
||||
ItemSupplierBinding binding = ItemSupplierBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
||||
return new SupplierViewHolder(binding);
|
||||
}
|
||||
|
||||
//populate the row with supplier data
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull SupplierViewHolder holder, int position) {
|
||||
SupplierDTO supplier = supplierList.get(position);
|
||||
ItemSupplierBinding binding = holder.binding;
|
||||
|
||||
holder.tvSupCompany.setText(supplier.getSupCompany());
|
||||
holder.tvSupContactName.setText(supplier.getSupContactFirstName() + " " + supplier.getSupContactLastName());
|
||||
holder.tvSupEmail.setText(supplier.getSupEmail());
|
||||
holder.tvSupPhone.setText(supplier.getSupPhone());
|
||||
binding.tvSupCompany.setText(supplier.getSupCompany());
|
||||
binding.tvSupContactName.setText(supplier.getSupContactFirstName() + " " + supplier.getSupContactLastName());
|
||||
binding.tvSupEmail.setText(supplier.getSupEmail());
|
||||
binding.tvSupPhone.setText(supplier.getSupPhone());
|
||||
|
||||
//when a row is clicked, open the detail view
|
||||
holder.itemView.setOnClickListener(v -> supplierClickListener.onSupplierClick(position));
|
||||
|
||||
@@ -55,6 +55,15 @@
|
||||
android:textColor="#666666"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvStaffName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp"
|
||||
android:text="Staff: name"
|
||||
android:textColor="#666666"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvDateTime"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
Reference in New Issue
Block a user