diff --git a/android/app/src/main/java/com/example/petstoremobile/fragments/listfragments/detailfragments/ProductSupplierDetailFragment.java b/android/app/src/main/java/com/example/petstoremobile/fragments/listfragments/detailfragments/ProductSupplierDetailFragment.java index 770c6b82..6abb918c 100644 --- a/android/app/src/main/java/com/example/petstoremobile/fragments/listfragments/detailfragments/ProductSupplierDetailFragment.java +++ b/android/app/src/main/java/com/example/petstoremobile/fragments/listfragments/detailfragments/ProductSupplierDetailFragment.java @@ -114,9 +114,18 @@ public class ProductSupplierDetailFragment extends Fragment { viewModel.setEditMode(productId, supplierId); preselectedProductId = productId; preselectedSupplierId = supplierId; - + binding.tvPSMode.setText("Edit Product Supplier"); binding.btnDeletePS.setVisibility(View.VISIBLE); + + viewModel.loadProductSupplier().observe(getViewLifecycleOwner(), resource -> { + if (resource == null) return; + if (resource.status == Resource.Status.SUCCESS && resource.data != null) { + if (resource.data.getCost() != null) { + binding.etPSCost.setText(resource.data.getCost().toPlainString()); + } + } + }); } else { binding.tvPSMode.setText("Add Product Supplier"); binding.btnDeletePS.setVisibility(View.GONE); diff --git a/android/app/src/main/java/com/example/petstoremobile/viewmodels/ProductSupplierDetailViewModel.java b/android/app/src/main/java/com/example/petstoremobile/viewmodels/ProductSupplierDetailViewModel.java index 552a99fc..2cbf5036 100644 --- a/android/app/src/main/java/com/example/petstoremobile/viewmodels/ProductSupplierDetailViewModel.java +++ b/android/app/src/main/java/com/example/petstoremobile/viewmodels/ProductSupplierDetailViewModel.java @@ -46,6 +46,10 @@ public class ProductSupplierDetailViewModel extends ViewModel { this.editSupplierId = supplierId; } + public LiveData> loadProductSupplier() { + return psRepository.getProductSupplierById(editProductId, editSupplierId); + } + public boolean isEditing() { return isEditing; } public long getEditProductId() { return editProductId; } public long getEditSupplierId() { return editSupplierId; }