Converted recylerview for Pet, Service, supplier to use DTOs
- swapped Pet,Service,Suppliers to use DTOs instead of the model when loading the list from the backend to advoid conversion of DTO -> models when displaying the list - Added a drawer menu to chatFragment to display a list of conversations the staff can choose to open chat
This commit is contained in:
@@ -0,0 +1,59 @@
|
|||||||
|
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.models.Chat;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ChatAdapter extends RecyclerView.Adapter<ChatAdapter.ChatViewHolder> {
|
||||||
|
|
||||||
|
private List<Chat> chatList;
|
||||||
|
private OnChatClickListener listener;
|
||||||
|
|
||||||
|
public interface OnChatClickListener {
|
||||||
|
void onChatClick(Chat chat);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatAdapter(List<Chat> chatList, OnChatClickListener listener) {
|
||||||
|
this.chatList = chatList;
|
||||||
|
this.listener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@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.itemView.setOnClickListener(v -> listener.onChatClick(chat));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return chatList.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ChatViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
TextView tvCustomerName, tvLastMessage;
|
||||||
|
|
||||||
|
public ChatViewHolder(@NonNull View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
tvCustomerName = itemView.findViewById(R.id.tvCustomerName);
|
||||||
|
tvLastMessage = itemView.findViewById(R.id.tvLastMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,12 +8,12 @@ import android.widget.TextView;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import com.example.petstoremobile.R;
|
import com.example.petstoremobile.R;
|
||||||
import com.example.petstoremobile.models.Pet;
|
import com.example.petstoremobile.dtos.PetDTO;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PetAdapter extends RecyclerView.Adapter<PetAdapter.PetViewHolder> {
|
public class PetAdapter extends RecyclerView.Adapter<PetAdapter.PetViewHolder> {
|
||||||
|
|
||||||
private List<Pet> petList;
|
private List<PetDTO> petList;
|
||||||
private OnPetClickListener petClickListener;
|
private OnPetClickListener petClickListener;
|
||||||
|
|
||||||
// Interface for pet click on recycler view
|
// Interface for pet click on recycler view
|
||||||
@@ -22,7 +22,7 @@ public class PetAdapter extends RecyclerView.Adapter<PetAdapter.PetViewHolder> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Constructor
|
//Constructor
|
||||||
public PetAdapter(List<Pet> petList, OnPetClickListener petClickListener) {
|
public PetAdapter(List<PetDTO> petList, OnPetClickListener petClickListener) {
|
||||||
this.petList = petList;
|
this.petList = petList;
|
||||||
this.petClickListener = petClickListener;
|
this.petClickListener = petClickListener;
|
||||||
}
|
}
|
||||||
@@ -52,16 +52,23 @@ public class PetAdapter extends RecyclerView.Adapter<PetAdapter.PetViewHolder> {
|
|||||||
//populate the row with pet data
|
//populate the row with pet data
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull PetViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull PetViewHolder holder, int position) {
|
||||||
Pet pet = petList.get(position);
|
PetDTO pet = petList.get(position);
|
||||||
|
|
||||||
holder.tvPetName.setText(pet.getPetName());
|
holder.tvPetName.setText(pet.getPetName());
|
||||||
holder.tvPetSpeciesBreed.setText(pet.getPetSpecies() + " - " + pet.getPetBreed());
|
holder.tvPetSpeciesBreed.setText(pet.getPetSpecies() + " - " + pet.getPetBreed());
|
||||||
holder.tvPetAge.setText("Age: " + pet.getPetAge() + " yr(s)");
|
holder.tvPetAge.setText("Age: " + pet.getPetAge() + " yr(s)");
|
||||||
holder.tvPetPrice.setText("$" + String.format("%.2f", pet.getPetPrice()));
|
|
||||||
|
try {
|
||||||
|
double price = Double.parseDouble(pet.getPetPrice());
|
||||||
|
holder.tvPetPrice.setText("$" + String.format("%.2f", price));
|
||||||
|
} catch (Exception e) {
|
||||||
|
holder.tvPetPrice.setText("$" + pet.getPetPrice());
|
||||||
|
}
|
||||||
|
|
||||||
holder.tvPetStatus.setText(pet.getPetStatus());
|
holder.tvPetStatus.setText(pet.getPetStatus());
|
||||||
|
|
||||||
//Set the status color depending on availability. If available, green, otherwise red
|
//Set the status color depending on availability. If available, green, otherwise red
|
||||||
if (pet.getPetStatus().equals("Available")) {
|
if (pet.getPetStatus() != null && pet.getPetStatus().equals("Available")) {
|
||||||
holder.tvPetStatus.setBackgroundColor(Color.parseColor("#4CAF50"));
|
holder.tvPetStatus.setBackgroundColor(Color.parseColor("#4CAF50"));
|
||||||
} else {
|
} else {
|
||||||
holder.tvPetStatus.setBackgroundColor(Color.parseColor("#F44336"));
|
holder.tvPetStatus.setBackgroundColor(Color.parseColor("#F44336"));
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ import android.widget.TextView;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import com.example.petstoremobile.R;
|
import com.example.petstoremobile.R;
|
||||||
import com.example.petstoremobile.models.Service;
|
import com.example.petstoremobile.dtos.ServiceDTO;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ServiceAdapter extends RecyclerView.Adapter<ServiceAdapter.ServiceViewHolder> {
|
public class ServiceAdapter extends RecyclerView.Adapter<ServiceAdapter.ServiceViewHolder> {
|
||||||
|
|
||||||
private List<Service> serviceList;
|
private List<ServiceDTO> serviceList;
|
||||||
private OnServiceClickListener serviceClickListener;
|
private OnServiceClickListener serviceClickListener;
|
||||||
|
|
||||||
// Interface for service click on recycler view
|
// Interface for service click on recycler view
|
||||||
@@ -21,7 +21,7 @@ public class ServiceAdapter extends RecyclerView.Adapter<ServiceAdapter.ServiceV
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Constructor
|
//Constructor
|
||||||
public ServiceAdapter(List<Service> serviceList, OnServiceClickListener serviceClickListener) {
|
public ServiceAdapter(List<ServiceDTO> serviceList, OnServiceClickListener serviceClickListener) {
|
||||||
this.serviceList = serviceList;
|
this.serviceList = serviceList;
|
||||||
this.serviceClickListener = serviceClickListener;
|
this.serviceClickListener = serviceClickListener;
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ public class ServiceAdapter extends RecyclerView.Adapter<ServiceAdapter.ServiceV
|
|||||||
//populate the row with service data
|
//populate the row with service data
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull ServiceViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull ServiceViewHolder holder, int position) {
|
||||||
Service service = serviceList.get(position);
|
ServiceDTO service = serviceList.get(position);
|
||||||
|
|
||||||
holder.tvServiceName.setText(service.getServiceName());
|
holder.tvServiceName.setText(service.getServiceName());
|
||||||
holder.tvServiceDesc.setText(service.getServiceDesc());
|
holder.tvServiceDesc.setText(service.getServiceDesc());
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ import android.widget.TextView;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import com.example.petstoremobile.R;
|
import com.example.petstoremobile.R;
|
||||||
import com.example.petstoremobile.models.Supplier;
|
import com.example.petstoremobile.dtos.SupplierDTO;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SupplierAdapter extends RecyclerView.Adapter<SupplierAdapter.SupplierViewHolder> {
|
public class SupplierAdapter extends RecyclerView.Adapter<SupplierAdapter.SupplierViewHolder> {
|
||||||
|
|
||||||
private List<Supplier> supplierList;
|
private List<SupplierDTO> supplierList;
|
||||||
private OnSupplierClickListener supplierClickListener;
|
private OnSupplierClickListener supplierClickListener;
|
||||||
|
|
||||||
// Interface for supplier click on recycler view
|
// Interface for supplier click on recycler view
|
||||||
@@ -21,7 +21,7 @@ public class SupplierAdapter extends RecyclerView.Adapter<SupplierAdapter.Suppli
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Constructor
|
//Constructor
|
||||||
public SupplierAdapter(List<Supplier> supplierList, OnSupplierClickListener supplierClickListener) {
|
public SupplierAdapter(List<SupplierDTO> supplierList, OnSupplierClickListener supplierClickListener) {
|
||||||
this.supplierList = supplierList;
|
this.supplierList = supplierList;
|
||||||
this.supplierClickListener = supplierClickListener;
|
this.supplierClickListener = supplierClickListener;
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ public class SupplierAdapter extends RecyclerView.Adapter<SupplierAdapter.Suppli
|
|||||||
//populate the row with supplier data
|
//populate the row with supplier data
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull SupplierViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull SupplierViewHolder holder, int position) {
|
||||||
Supplier supplier = supplierList.get(position);
|
SupplierDTO supplier = supplierList.get(position);
|
||||||
|
|
||||||
holder.tvSupCompany.setText(supplier.getSupCompany());
|
holder.tvSupCompany.setText(supplier.getSupCompany());
|
||||||
holder.tvSupContactName.setText(supplier.getSupContactFirstName() + " " + supplier.getSupContactLastName());
|
holder.tvSupContactName.setText(supplier.getSupContactFirstName() + " " + supplier.getSupContactLastName());
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.example.petstoremobile.api;
|
||||||
|
|
||||||
|
import com.example.petstoremobile.dtos.ConversationDTO;
|
||||||
|
import com.example.petstoremobile.dtos.MessageDTO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import retrofit2.Call;
|
||||||
|
import retrofit2.http.Body;
|
||||||
|
import retrofit2.http.GET;
|
||||||
|
import retrofit2.http.POST;
|
||||||
|
import retrofit2.http.Path;
|
||||||
|
|
||||||
|
public interface ChatApi {
|
||||||
|
|
||||||
|
@GET("v1/chat/conversations")
|
||||||
|
Call<List<ConversationDTO>> getAllConversations();
|
||||||
|
|
||||||
|
@GET("v1/chat/conversations/{conversationId}")
|
||||||
|
Call<ConversationDTO> getConversationById(@Path("conversationId") Long conversationId);
|
||||||
|
|
||||||
|
@GET("v1/chat/conversations/{conversationId}/messages")
|
||||||
|
Call<List<MessageDTO>> getMessages(@Path("conversationId") Long conversationId);
|
||||||
|
|
||||||
|
@POST("v1/chat/conversations/{conversationId}/messages")
|
||||||
|
Call<MessageDTO> sendMessage(@Path("conversationId") Long conversationId, @Body MessageDTO message);
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.example.petstoremobile.api;
|
||||||
|
|
||||||
|
import com.example.petstoremobile.dtos.CustomerDTO;
|
||||||
|
import com.example.petstoremobile.dtos.PageResponse;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import retrofit2.Call;
|
||||||
|
import retrofit2.http.GET;
|
||||||
|
import retrofit2.http.Path;
|
||||||
|
import retrofit2.http.Query;
|
||||||
|
|
||||||
|
public interface CustomerApi {
|
||||||
|
|
||||||
|
@GET("v1/customers")
|
||||||
|
Call<PageResponse<CustomerDTO>> getAllCustomers(@Query("page") int page, @Query("size") int size);
|
||||||
|
|
||||||
|
@GET("v1/customers/{customerId}")
|
||||||
|
Call<CustomerDTO> getCustomerById(@Path("customerId") Long customerId);
|
||||||
|
}
|
||||||
@@ -12,8 +12,8 @@ import retrofit2.converter.gson.GsonConverterFactory;
|
|||||||
|
|
||||||
public class RetrofitClient {
|
public class RetrofitClient {
|
||||||
//base URL
|
//base URL
|
||||||
public static final String BASE_URL = "http://10.0.2.2:8080/api/"; //for emulator testing
|
// public static final String BASE_URL = "http://10.0.2.2:8080/api/"; //for emulator testing
|
||||||
// public static final String BASE_URL = "http://10.0.0.200:8080/api/"; //for hardware testing change to computer ip if using hardware to test
|
public static final String BASE_URL = "http://10.0.0.200:8080/api/"; //for hardware testing change to computer ip if using hardware to test
|
||||||
|
|
||||||
private static Retrofit retrofit = null;
|
private static Retrofit retrofit = null;
|
||||||
|
|
||||||
@@ -54,4 +54,12 @@ public class RetrofitClient {
|
|||||||
return getClient(context).create(AuthApi.class);
|
return getClient(context).create(AuthApi.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ChatApi getChatApi(Context context) {
|
||||||
|
return getClient(context).create(ChatApi.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CustomerApi getCustomerApi(Context context) {
|
||||||
|
return getClient(context).create(CustomerApi.class);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
package com.example.petstoremobile.dtos;
|
||||||
|
|
||||||
|
public class ConversationDTO {
|
||||||
|
private Long id;
|
||||||
|
private Long customerId;
|
||||||
|
private Long staffId;
|
||||||
|
private String status;
|
||||||
|
private String mode;
|
||||||
|
private String lastMessage;
|
||||||
|
private String createdAt;
|
||||||
|
private String updatedAt;
|
||||||
|
|
||||||
|
public ConversationDTO() {}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getCustomerId() {
|
||||||
|
return customerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCustomerId(Long customerId) {
|
||||||
|
this.customerId = customerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getStaffId() {
|
||||||
|
return staffId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStaffId(Long staffId) {
|
||||||
|
this.staffId = staffId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMode() {
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMode(String mode) {
|
||||||
|
this.mode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLastMessage() {
|
||||||
|
return lastMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastMessage(String lastMessage) {
|
||||||
|
this.lastMessage = lastMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCreatedAt() {
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedAt(String createdAt) {
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUpdatedAt() {
|
||||||
|
return updatedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdatedAt(String updatedAt) {
|
||||||
|
this.updatedAt = updatedAt;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package com.example.petstoremobile.dtos;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
public class CustomerDTO {
|
||||||
|
@SerializedName("customerId")
|
||||||
|
private Long customerId;
|
||||||
|
|
||||||
|
private String firstName;
|
||||||
|
private String lastName;
|
||||||
|
private String email;
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
public CustomerDTO() {}
|
||||||
|
|
||||||
|
public Long getCustomerId() {
|
||||||
|
return customerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCustomerId(Long customerId) {
|
||||||
|
this.customerId = customerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFirstName() {
|
||||||
|
return firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFirstName(String firstName) {
|
||||||
|
this.firstName = firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLastName() {
|
||||||
|
return lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastName(String lastName) {
|
||||||
|
this.lastName = lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail(String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPhone() {
|
||||||
|
return phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhone(String phone) {
|
||||||
|
this.phone = phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFullName() {
|
||||||
|
return (firstName != null ? firstName : "") + " " + (lastName != null ? lastName : "");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package com.example.petstoremobile.dtos;
|
||||||
|
|
||||||
|
public class MessageDTO {
|
||||||
|
private String id;
|
||||||
|
private String content;
|
||||||
|
private String senderId;
|
||||||
|
private long timestamp;
|
||||||
|
|
||||||
|
public MessageDTO() {}
|
||||||
|
|
||||||
|
public MessageDTO(String content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContent() {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContent(String content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSenderId() {
|
||||||
|
return senderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSenderId(String senderId) {
|
||||||
|
this.senderId = senderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTimestamp() {
|
||||||
|
return timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimestamp(long timestamp) {
|
||||||
|
this.timestamp = timestamp;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,35 +2,156 @@ package com.example.petstoremobile.fragments;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.core.view.GravityCompat;
|
||||||
|
import androidx.drawerlayout.widget.DrawerLayout;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.ImageButton;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.example.petstoremobile.R;
|
import com.example.petstoremobile.R;
|
||||||
|
import com.example.petstoremobile.adapters.ChatAdapter;
|
||||||
|
import com.example.petstoremobile.api.ChatApi;
|
||||||
|
import com.example.petstoremobile.api.CustomerApi;
|
||||||
|
import com.example.petstoremobile.api.RetrofitClient;
|
||||||
|
import com.example.petstoremobile.dtos.ConversationDTO;
|
||||||
|
import com.example.petstoremobile.dtos.CustomerDTO;
|
||||||
|
import com.example.petstoremobile.dtos.PageResponse;
|
||||||
|
import com.example.petstoremobile.models.Chat;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import retrofit2.Call;
|
||||||
|
import retrofit2.Callback;
|
||||||
|
import retrofit2.Response;
|
||||||
|
|
||||||
|
|
||||||
public class ChatFragment extends Fragment {
|
public class ChatFragment extends Fragment implements ChatAdapter.OnChatClickListener {
|
||||||
|
|
||||||
private LinearLayout chatContainer;
|
private LinearLayout chatContainer;
|
||||||
private EditText etMessage;
|
private EditText etMessage;
|
||||||
private ScrollView scrollView;
|
private ScrollView scrollView;
|
||||||
private Button btnSend;
|
private Button btnSend;
|
||||||
|
private ImageButton hamburger;
|
||||||
|
private DrawerLayout drawerLayout;
|
||||||
|
private RecyclerView rvChatList;
|
||||||
|
private ChatAdapter chatAdapter;
|
||||||
|
private List<Chat> chatList = new ArrayList<>();
|
||||||
|
private ChatApi chatApi;
|
||||||
|
private CustomerApi customerApi;
|
||||||
|
private Map<Long, String> customerNames = new HashMap<>();
|
||||||
|
|
||||||
//TODO: Add functionality for sending messages
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
|
||||||
View view = inflater.inflate(R.layout.fragment_chat, container, false);
|
View view = inflater.inflate(R.layout.fragment_chat, container, false);
|
||||||
|
|
||||||
|
chatApi = RetrofitClient.getChatApi(requireContext());
|
||||||
|
customerApi = RetrofitClient.getCustomerApi(requireContext());
|
||||||
|
|
||||||
|
drawerLayout = view.findViewById(R.id.chatDrawerLayout);
|
||||||
|
hamburger = view.findViewById(R.id.btnHamburger);
|
||||||
|
rvChatList = view.findViewById(R.id.rvChatList);
|
||||||
|
|
||||||
|
setupRecyclerView();
|
||||||
|
loadInitialData();
|
||||||
|
|
||||||
|
// Open the local chat drawer when hamburger is clicked
|
||||||
|
hamburger.setOnClickListener(v -> {
|
||||||
|
if (drawerLayout != null) {
|
||||||
|
drawerLayout.openDrawer(GravityCompat.START);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupRecyclerView() {
|
||||||
|
chatAdapter = new ChatAdapter(chatList, this);
|
||||||
|
rvChatList.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
|
rvChatList.setAdapter(chatAdapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadInitialData() {
|
||||||
|
// Fetch all customers (first page, large size to get many)
|
||||||
|
customerApi.getAllCustomers(0, 100).enqueue(new Callback<PageResponse<CustomerDTO>>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(Call<PageResponse<CustomerDTO>> call, Response<PageResponse<CustomerDTO>> response) {
|
||||||
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
|
for (CustomerDTO customer : response.body().getContent()) {
|
||||||
|
customerNames.put(customer.getCustomerId(), customer.getFullName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Then load conversations
|
||||||
|
loadConversations();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Call<PageResponse<CustomerDTO>> call, Throwable t) {
|
||||||
|
Log.e("ChatFragment", "Error loading customers", t);
|
||||||
|
loadConversations(); // Try loading conversations anyway
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadConversations() {
|
||||||
|
chatApi.getAllConversations().enqueue(new Callback<List<ConversationDTO>>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(Call<List<ConversationDTO>> call, Response<List<ConversationDTO>> response) {
|
||||||
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
|
chatList.clear();
|
||||||
|
List<Chat> loadedChats = response.body().stream()
|
||||||
|
.map(dto -> {
|
||||||
|
String name = customerNames.getOrDefault(dto.getCustomerId(), "Customer #" + dto.getCustomerId());
|
||||||
|
return new Chat(
|
||||||
|
String.valueOf(dto.getId()),
|
||||||
|
name,
|
||||||
|
dto.getLastMessage());
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
chatList.addAll(loadedChats);
|
||||||
|
chatAdapter.notifyDataSetChanged();
|
||||||
|
} else {
|
||||||
|
Log.e("ChatFragment", "Failed to load conversations: " + response.message());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Call<List<ConversationDTO>> call, Throwable t) {
|
||||||
|
Log.e("ChatFragment", "Error loading conversations", t);
|
||||||
|
Toast.makeText(getContext(), "Error loading chats", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onChatClick(Chat chat) {
|
||||||
|
// Handle chat selection
|
||||||
|
Toast.makeText(getContext(), "Selected chat: " + chat.getCustomerName(), Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
|
// Close drawer after selection
|
||||||
|
if (drawerLayout != null) {
|
||||||
|
drawerLayout.closeDrawer(GravityCompat.START);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Load actual messages for the selected chat
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,6 @@ import com.example.petstoremobile.dtos.PetDTO;
|
|||||||
import com.example.petstoremobile.fragments.ListFragment;
|
import com.example.petstoremobile.fragments.ListFragment;
|
||||||
import com.example.petstoremobile.fragments.listfragments.detailfragments.PetDetailFragment;
|
import com.example.petstoremobile.fragments.listfragments.detailfragments.PetDetailFragment;
|
||||||
import com.example.petstoremobile.fragments.listfragments.listprofilefragments.PetProfileFragment;
|
import com.example.petstoremobile.fragments.listfragments.listprofilefragments.PetProfileFragment;
|
||||||
import com.example.petstoremobile.models.Pet;
|
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -37,8 +36,8 @@ import retrofit2.Callback;
|
|||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
|
|
||||||
public class PetFragment extends Fragment implements PetAdapter.OnPetClickListener {
|
public class PetFragment extends Fragment implements PetAdapter.OnPetClickListener {
|
||||||
private List<Pet> petList = new ArrayList<>();
|
private List<PetDTO> petList = new ArrayList<>();
|
||||||
private List<Pet> filteredList = new ArrayList<>();
|
private List<PetDTO> filteredList = new ArrayList<>();
|
||||||
private ImageButton hamburger;
|
private ImageButton hamburger;
|
||||||
private PetAdapter adapter;
|
private PetAdapter adapter;
|
||||||
private PetApi api;
|
private PetApi api;
|
||||||
@@ -95,7 +94,7 @@ public class PetFragment extends Fragment implements PetAdapter.OnPetClickListen
|
|||||||
filteredList.addAll(petList);
|
filteredList.addAll(petList);
|
||||||
} else {
|
} else {
|
||||||
String lower = query.toLowerCase();
|
String lower = query.toLowerCase();
|
||||||
for (Pet p : petList) {
|
for (PetDTO p : petList) {
|
||||||
if (p.getPetName().toLowerCase().contains(lower)
|
if (p.getPetName().toLowerCase().contains(lower)
|
||||||
|| p.getPetSpecies().toLowerCase().contains(lower)
|
|| p.getPetSpecies().toLowerCase().contains(lower)
|
||||||
|| p.getPetBreed().toLowerCase().contains(lower)) {
|
|| p.getPetBreed().toLowerCase().contains(lower)) {
|
||||||
@@ -119,14 +118,19 @@ public class PetFragment extends Fragment implements PetAdapter.OnPetClickListen
|
|||||||
|
|
||||||
//Make a bundle to pass data to the profile fragment
|
//Make a bundle to pass data to the profile fragment
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
Pet pet = filteredList.get(position);
|
PetDTO pet = filteredList.get(position);
|
||||||
args.putInt("petId", pet.getPetId());
|
args.putInt("petId", pet.getPetId().intValue());
|
||||||
args.putString("petName", pet.getPetName());
|
args.putString("petName", pet.getPetName());
|
||||||
args.putString("petSpecies", pet.getPetSpecies());
|
args.putString("petSpecies", pet.getPetSpecies());
|
||||||
args.putString("petBreed", pet.getPetBreed());
|
args.putString("petBreed", pet.getPetBreed());
|
||||||
args.putInt("petAge", pet.getPetAge());
|
args.putInt("petAge", pet.getPetAge());
|
||||||
args.putString("petStatus", pet.getPetStatus());
|
args.putString("petStatus", pet.getPetStatus());
|
||||||
args.putDouble("petPrice", pet.getPetPrice());
|
|
||||||
|
try {
|
||||||
|
args.putDouble("petPrice", Double.parseDouble(pet.getPetPrice()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
args.putDouble("petPrice", 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
//send the bundle to the profile fragment to display
|
//send the bundle to the profile fragment to display
|
||||||
profileFragment.setArguments(args);
|
profileFragment.setArguments(args);
|
||||||
@@ -142,7 +146,7 @@ public class PetFragment extends Fragment implements PetAdapter.OnPetClickListen
|
|||||||
private void openPetDetails(int position) {
|
private void openPetDetails(int position) {
|
||||||
PetDetailFragment detailFragment = new PetDetailFragment();
|
PetDetailFragment detailFragment = new PetDetailFragment();
|
||||||
|
|
||||||
//get ListFragment to load the the detail view
|
//get ListFragment to load the detail view
|
||||||
ListFragment listFragment = (ListFragment) getParentFragment();
|
ListFragment listFragment = (ListFragment) getParentFragment();
|
||||||
if (listFragment != null) {
|
if (listFragment != null) {
|
||||||
listFragment.loadFragment(detailFragment);
|
listFragment.loadFragment(detailFragment);
|
||||||
@@ -168,14 +172,7 @@ public class PetFragment extends Fragment implements PetAdapter.OnPetClickListen
|
|||||||
}
|
}
|
||||||
if (response.isSuccessful() && response.body() != null) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
petList.clear();
|
petList.clear();
|
||||||
|
petList.addAll(response.body().getContent());
|
||||||
// Convert to pets
|
|
||||||
List<Pet> pets = response.body().getContent()
|
|
||||||
.stream()
|
|
||||||
.map(Pet::new)
|
|
||||||
.collect(java.util.stream.Collectors.toList());
|
|
||||||
|
|
||||||
petList.addAll(pets);
|
|
||||||
filterPets(etSearch.getText().toString());
|
filterPets(etSearch.getText().toString());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import com.example.petstoremobile.dtos.PageResponse;
|
|||||||
import com.example.petstoremobile.dtos.ServiceDTO;
|
import com.example.petstoremobile.dtos.ServiceDTO;
|
||||||
import com.example.petstoremobile.fragments.ListFragment;
|
import com.example.petstoremobile.fragments.ListFragment;
|
||||||
import com.example.petstoremobile.fragments.listfragments.detailfragments.ServiceDetailFragment;
|
import com.example.petstoremobile.fragments.listfragments.detailfragments.ServiceDetailFragment;
|
||||||
import com.example.petstoremobile.models.Service;
|
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -37,8 +36,8 @@ import retrofit2.Response;
|
|||||||
|
|
||||||
public class ServiceFragment extends Fragment implements ServiceAdapter.OnServiceClickListener {
|
public class ServiceFragment extends Fragment implements ServiceAdapter.OnServiceClickListener {
|
||||||
|
|
||||||
private List<Service> serviceList = new ArrayList<>();
|
private List<ServiceDTO> serviceList = new ArrayList<>();
|
||||||
private List<Service> filteredList = new ArrayList<>();
|
private List<ServiceDTO> filteredList = new ArrayList<>();
|
||||||
private ServiceAdapter adapter;
|
private ServiceAdapter adapter;
|
||||||
private ImageButton hamburger;
|
private ImageButton hamburger;
|
||||||
private ServiceApi api;
|
private ServiceApi api;
|
||||||
@@ -92,7 +91,7 @@ public class ServiceFragment extends Fragment implements ServiceAdapter.OnServic
|
|||||||
filteredList.addAll(serviceList);
|
filteredList.addAll(serviceList);
|
||||||
} else {
|
} else {
|
||||||
String lower = query.toLowerCase();
|
String lower = query.toLowerCase();
|
||||||
for (Service s : serviceList) {
|
for (ServiceDTO s : serviceList) {
|
||||||
if (s.getServiceName().toLowerCase().contains(lower)
|
if (s.getServiceName().toLowerCase().contains(lower)
|
||||||
|| s.getServiceDesc().toLowerCase().contains(lower)) {
|
|| s.getServiceDesc().toLowerCase().contains(lower)) {
|
||||||
filteredList.add(s);
|
filteredList.add(s);
|
||||||
@@ -119,8 +118,8 @@ public class ServiceFragment extends Fragment implements ServiceAdapter.OnServic
|
|||||||
|
|
||||||
//if editing a service, add the service data to the bundle
|
//if editing a service, add the service data to the bundle
|
||||||
if (position != -1) {
|
if (position != -1) {
|
||||||
Service service = filteredList.get(position);
|
ServiceDTO service = filteredList.get(position);
|
||||||
args.putInt("serviceId", service.getServiceId());
|
args.putInt("serviceId", service.getServiceId().intValue());
|
||||||
args.putString("serviceName", service.getServiceName());
|
args.putString("serviceName", service.getServiceName());
|
||||||
args.putString("serviceDesc", service.getServiceDesc());
|
args.putString("serviceDesc", service.getServiceDesc());
|
||||||
args.putInt("serviceDuration", service.getServiceDuration());
|
args.putInt("serviceDuration", service.getServiceDuration());
|
||||||
@@ -158,14 +157,7 @@ public class ServiceFragment extends Fragment implements ServiceAdapter.OnServic
|
|||||||
}
|
}
|
||||||
if (response.isSuccessful() && response.body() != null) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
serviceList.clear();
|
serviceList.clear();
|
||||||
|
serviceList.addAll(response.body().getContent());
|
||||||
// Convert to services
|
|
||||||
List<Service> services = response.body().getContent()
|
|
||||||
.stream()
|
|
||||||
.map(Service::new)
|
|
||||||
.collect(java.util.stream.Collectors.toList());
|
|
||||||
|
|
||||||
serviceList.addAll(services);
|
|
||||||
filterServices(etSearch.getText().toString());
|
filterServices(etSearch.getText().toString());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import com.example.petstoremobile.dtos.PageResponse;
|
|||||||
import com.example.petstoremobile.dtos.SupplierDTO;
|
import com.example.petstoremobile.dtos.SupplierDTO;
|
||||||
import com.example.petstoremobile.fragments.ListFragment;
|
import com.example.petstoremobile.fragments.ListFragment;
|
||||||
import com.example.petstoremobile.fragments.listfragments.detailfragments.SupplierDetailFragment;
|
import com.example.petstoremobile.fragments.listfragments.detailfragments.SupplierDetailFragment;
|
||||||
import com.example.petstoremobile.models.Supplier;
|
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -37,8 +36,8 @@ import retrofit2.Response;
|
|||||||
|
|
||||||
public class SupplierFragment extends Fragment implements SupplierAdapter.OnSupplierClickListener {
|
public class SupplierFragment extends Fragment implements SupplierAdapter.OnSupplierClickListener {
|
||||||
|
|
||||||
private List<Supplier> supplierList = new ArrayList<>();
|
private List<SupplierDTO> supplierList = new ArrayList<>();
|
||||||
private List<Supplier> filteredList = new ArrayList<>();
|
private List<SupplierDTO> filteredList = new ArrayList<>();
|
||||||
private SupplierAdapter adapter;
|
private SupplierAdapter adapter;
|
||||||
private ImageButton hamburger;
|
private ImageButton hamburger;
|
||||||
private SupplierApi api;
|
private SupplierApi api;
|
||||||
@@ -92,7 +91,7 @@ public class SupplierFragment extends Fragment implements SupplierAdapter.OnSupp
|
|||||||
filteredList.addAll(supplierList);
|
filteredList.addAll(supplierList);
|
||||||
} else {
|
} else {
|
||||||
String lower = query.toLowerCase();
|
String lower = query.toLowerCase();
|
||||||
for (Supplier s : supplierList) {
|
for (SupplierDTO s : supplierList) {
|
||||||
if (s.getSupCompany().toLowerCase().contains(lower)
|
if (s.getSupCompany().toLowerCase().contains(lower)
|
||||||
|| s.getSupContactFirstName().toLowerCase().contains(lower)
|
|| s.getSupContactFirstName().toLowerCase().contains(lower)
|
||||||
|| s.getSupContactLastName().toLowerCase().contains(lower)) {
|
|| s.getSupContactLastName().toLowerCase().contains(lower)) {
|
||||||
@@ -120,8 +119,8 @@ public class SupplierFragment extends Fragment implements SupplierAdapter.OnSupp
|
|||||||
|
|
||||||
//if editing a supplier, add the supplier data to the bundle
|
//if editing a supplier, add the supplier data to the bundle
|
||||||
if (position != -1) {
|
if (position != -1) {
|
||||||
Supplier supplier = filteredList.get(position);
|
SupplierDTO supplier = filteredList.get(position);
|
||||||
args.putInt("supId", supplier.getSupId());
|
args.putInt("supId", supplier.getSupId().intValue());
|
||||||
args.putString("supCompany", supplier.getSupCompany());
|
args.putString("supCompany", supplier.getSupCompany());
|
||||||
args.putString("supContactFirstName", supplier.getSupContactFirstName());
|
args.putString("supContactFirstName", supplier.getSupContactFirstName());
|
||||||
args.putString("supContactLastName", supplier.getSupContactLastName());
|
args.putString("supContactLastName", supplier.getSupContactLastName());
|
||||||
@@ -161,14 +160,7 @@ public class SupplierFragment extends Fragment implements SupplierAdapter.OnSupp
|
|||||||
}
|
}
|
||||||
if (response.isSuccessful() && response.body() != null) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
supplierList.clear();
|
supplierList.clear();
|
||||||
|
supplierList.addAll(response.body().getContent());
|
||||||
// Convert to suppliers
|
|
||||||
List<Supplier> suppliers = response.body().getContent()
|
|
||||||
.stream()
|
|
||||||
.map(Supplier::new)
|
|
||||||
.collect(java.util.stream.Collectors.toList());
|
|
||||||
|
|
||||||
supplierList.addAll(suppliers);
|
|
||||||
filterSuppliers(etSearch.getText().toString());
|
filterSuppliers(etSearch.getText().toString());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ public class Adoption {
|
|||||||
return adoptionId;
|
return adoptionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAdoptionId(int adoptionId) {
|
||||||
|
this.adoptionId = adoptionId;
|
||||||
|
}
|
||||||
|
|
||||||
public String getAdopterName() {
|
public String getAdopterName() {
|
||||||
return adopterName;
|
return adopterName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.example.petstoremobile.models;
|
||||||
|
|
||||||
|
public class Chat {
|
||||||
|
private String chatId;
|
||||||
|
private String customerName;
|
||||||
|
private String lastMessage;
|
||||||
|
|
||||||
|
public Chat(String chatId, String customerName, String lastMessage) {
|
||||||
|
this.chatId = chatId;
|
||||||
|
this.customerName = customerName;
|
||||||
|
this.lastMessage = lastMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getChatId() {
|
||||||
|
return chatId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCustomerName() {
|
||||||
|
return customerName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLastMessage() {
|
||||||
|
return lastMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
package com.example.petstoremobile.models;
|
|
||||||
|
|
||||||
import com.example.petstoremobile.dtos.PetDTO;
|
|
||||||
|
|
||||||
public class Pet {
|
|
||||||
private int petId;
|
|
||||||
private String petName;
|
|
||||||
private String petSpecies;
|
|
||||||
private String petBreed;
|
|
||||||
private int petAge;
|
|
||||||
private String petStatus;
|
|
||||||
private double petPrice;
|
|
||||||
|
|
||||||
//constructor
|
|
||||||
public Pet(int petId, String petName, String petSpecies, String petBreed, int petAge, String petStatus, double petPrice) {
|
|
||||||
this.petId = petId;
|
|
||||||
this.petName = petName;
|
|
||||||
this.petSpecies = petSpecies;
|
|
||||||
this.petBreed = petBreed;
|
|
||||||
this.petAge = petAge;
|
|
||||||
this.petStatus = petStatus;
|
|
||||||
this.petPrice = petPrice;
|
|
||||||
}
|
|
||||||
|
|
||||||
//contructor to convert PetDTO to Pet
|
|
||||||
public Pet(PetDTO dto) {
|
|
||||||
this.petId = dto.getPetId().intValue();
|
|
||||||
this.petName = dto.getPetName();
|
|
||||||
this.petSpecies = dto.getPetSpecies();
|
|
||||||
this.petBreed = dto.getPetBreed();
|
|
||||||
this.petAge = dto.getPetAge();
|
|
||||||
this.petStatus = dto.getPetStatus();
|
|
||||||
this.petPrice = Double.parseDouble(dto.getPetPrice());
|
|
||||||
}
|
|
||||||
|
|
||||||
//getter and setters
|
|
||||||
public int getPetId() {
|
|
||||||
return petId;
|
|
||||||
}
|
|
||||||
|
|
||||||
// public void setPetId(int petId) {
|
|
||||||
// this.petId = petId;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public String getPetName() {
|
|
||||||
return petName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPetName(String petName) {
|
|
||||||
this.petName = petName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPetSpecies() {
|
|
||||||
return petSpecies;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPetSpecies(String petSpecies) {
|
|
||||||
this.petSpecies = petSpecies;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPetBreed() {
|
|
||||||
return petBreed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPetBreed(String petBreed) {
|
|
||||||
this.petBreed = petBreed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPetAge() {
|
|
||||||
return petAge;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPetAge(int petAge) {
|
|
||||||
this.petAge = petAge;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPetStatus() {
|
|
||||||
return petStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPetStatus(String petStatus) {
|
|
||||||
this.petStatus = petStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getPetPrice() {
|
|
||||||
return petPrice;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPetPrice(double petPrice) {
|
|
||||||
this.petPrice = petPrice;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
package com.example.petstoremobile.models;
|
|
||||||
|
|
||||||
import com.example.petstoremobile.dtos.ServiceDTO;
|
|
||||||
|
|
||||||
public class Service {
|
|
||||||
private int serviceId;
|
|
||||||
private String serviceName;
|
|
||||||
private String serviceDesc;
|
|
||||||
private int serviceDuration;
|
|
||||||
private double servicePrice;
|
|
||||||
|
|
||||||
// Constructor
|
|
||||||
public Service(int serviceId, String serviceName, String serviceDesc, int serviceDuration, double servicePrice) {
|
|
||||||
this.serviceId = serviceId;
|
|
||||||
this.serviceName = serviceName;
|
|
||||||
this.serviceDesc = serviceDesc;
|
|
||||||
this.serviceDuration = serviceDuration;
|
|
||||||
this.servicePrice = servicePrice;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Service(ServiceDTO dto) {
|
|
||||||
this.serviceId = dto.getServiceId().intValue();
|
|
||||||
this.serviceName = dto.getServiceName();
|
|
||||||
this.serviceDesc = dto.getServiceDesc();
|
|
||||||
this.serviceDuration = dto.getServiceDuration();
|
|
||||||
this.servicePrice = dto.getServicePrice();
|
|
||||||
}
|
|
||||||
|
|
||||||
//getter and setters
|
|
||||||
public int getServiceId() {
|
|
||||||
return serviceId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getServiceName() {
|
|
||||||
return serviceName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setServiceName(String serviceName) {
|
|
||||||
this.serviceName = serviceName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getServiceDesc() {
|
|
||||||
return serviceDesc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setServiceDesc(String serviceDesc) {
|
|
||||||
this.serviceDesc = serviceDesc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getServiceDuration() {
|
|
||||||
return serviceDuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setServiceDuration(int serviceDuration) {
|
|
||||||
this.serviceDuration = serviceDuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getServicePrice() {
|
|
||||||
return servicePrice;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setServicePrice(double servicePrice) {
|
|
||||||
this.servicePrice = servicePrice;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
package com.example.petstoremobile.models;
|
|
||||||
|
|
||||||
import com.example.petstoremobile.dtos.SupplierDTO;
|
|
||||||
|
|
||||||
public class Supplier {
|
|
||||||
private int supId;
|
|
||||||
private String supCompany;
|
|
||||||
private String supContactFirstName;
|
|
||||||
private String supContactLastName;
|
|
||||||
private String supEmail;
|
|
||||||
private String supPhone;
|
|
||||||
|
|
||||||
// Constructor
|
|
||||||
public Supplier(int supId, String supCompany, String supContactFirstName, String supContactLastName, String supEmail, String supPhone) {
|
|
||||||
this.supId = supId;
|
|
||||||
this.supCompany = supCompany;
|
|
||||||
this.supContactFirstName = supContactFirstName;
|
|
||||||
this.supContactLastName = supContactLastName;
|
|
||||||
this.supEmail = supEmail;
|
|
||||||
this.supPhone = supPhone;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Supplier(SupplierDTO dto) {
|
|
||||||
this.supId = dto.getSupId().intValue();
|
|
||||||
this.supCompany = dto.getSupCompany();
|
|
||||||
this.supContactFirstName = dto.getSupContactFirstName();
|
|
||||||
this.supContactLastName = dto.getSupContactLastName();
|
|
||||||
this.supEmail = dto.getSupEmail();
|
|
||||||
this.supPhone = dto.getSupPhone();
|
|
||||||
}
|
|
||||||
|
|
||||||
//getter and setters
|
|
||||||
|
|
||||||
public int getSupId() {
|
|
||||||
return supId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSupCompany() {
|
|
||||||
return supCompany;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSupCompany(String supCompany) {
|
|
||||||
this.supCompany = supCompany;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSupContactFirstName() {
|
|
||||||
return supContactFirstName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSupContactFirstName(String supContactFirstName) {
|
|
||||||
this.supContactFirstName = supContactFirstName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSupContactLastName() {
|
|
||||||
return supContactLastName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSupContactLastName(String supContactLastName) {
|
|
||||||
this.supContactLastName = supContactLastName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSupEmail() {
|
|
||||||
return supEmail;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSupEmail(String supEmail) {
|
|
||||||
this.supEmail = supEmail;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSupPhone() {
|
|
||||||
return supPhone;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSupPhone(String supPhone) {
|
|
||||||
this.supPhone = supPhone;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,69 +1,110 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.drawerlayout.widget.DrawerLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/chatDrawerLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:orientation="vertical"
|
|
||||||
android:background="@color/background_grey">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="56dp"
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:background="@color/background_grey">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="56dp"
|
||||||
|
android:background="@color/primary_dark"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingStart="16dp"
|
||||||
|
android:paddingEnd="16dp">
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/btnHamburger"
|
||||||
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:src="@drawable/baseline_menu_36"
|
||||||
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
|
android:contentDescription="Open menu"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Customer Chat"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:id="@+id/scrollView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:padding="8dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/chatContainer"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="8dp"/>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:background="@color/white">
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etMessage"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:hint="Type a message..."
|
||||||
|
android:inputType="text"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
|
android:textColor="@color/text_dark"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnSend"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Send"
|
||||||
|
android:backgroundTint="@color/accent_coral"
|
||||||
|
android:textColor="@color/white"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/chatListDrawer"
|
||||||
|
android:layout_width="260dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="start"
|
||||||
|
android:orientation="vertical"
|
||||||
android:background="@color/primary_dark"
|
android:background="@color/primary_dark"
|
||||||
android:gravity="center_vertical"
|
android:padding="16dp">
|
||||||
android:paddingStart="16dp"
|
|
||||||
android:paddingEnd="16dp">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Customer Chat"
|
android:text="Active Chats"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
android:textSize="20sp"
|
android:textSize="18sp"
|
||||||
android:textStyle="bold"/>
|
android:textStyle="bold"
|
||||||
|
android:layout_marginBottom="16dp"/>
|
||||||
|
|
||||||
</LinearLayout>
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/rvChatList"
|
||||||
<ScrollView
|
|
||||||
android:id="@+id/scrollView"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:padding="8dp">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/chatContainer"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"/>
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="8dp"/>
|
|
||||||
|
|
||||||
</ScrollView>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:padding="8dp"
|
|
||||||
android:background="@color/white">
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/etMessage"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:hint="Type a message..."
|
|
||||||
android:inputType="text"
|
|
||||||
android:layout_marginEnd="8dp"
|
|
||||||
android:textColor="@color/text_dark"/>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/btnSend"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Send"
|
|
||||||
android:backgroundTint="@color/accent_coral"
|
|
||||||
android:textColor="@color/white"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</androidx.drawerlayout.widget.DrawerLayout>
|
||||||
26
app/src/main/res/layout/item_chat.xml
Normal file
26
app/src/main/res/layout/item_chat.xml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="16dp"
|
||||||
|
android:background="?attr/selectableItemBackground">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvCustomerName"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvLastMessage"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="@color/text_light"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:ellipsize="end" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
Reference in New Issue
Block a user