Fixed bug where it navigates back to petprofile after deleting the pet
This commit is contained in:
@@ -102,7 +102,7 @@ public class PetDetailFragment extends Fragment {
|
|||||||
if (resource.status == Resource.Status.SUCCESS) {
|
if (resource.status == Resource.Status.SUCCESS) {
|
||||||
ActivityLogger.logChange(requireContext(), "Pet", "UPDATED", petId);
|
ActivityLogger.logChange(requireContext(), "Pet", "UPDATED", petId);
|
||||||
Toast.makeText(getContext(), "Pet updated successfully!", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getContext(), "Pet updated successfully!", Toast.LENGTH_SHORT).show();
|
||||||
navigateBack();
|
navigateToPetList();
|
||||||
} else if (resource.status == Resource.Status.ERROR) {
|
} else if (resource.status == Resource.Status.ERROR) {
|
||||||
Toast.makeText(getContext(), "Error: " + resource.message, Toast.LENGTH_SHORT).show();
|
Toast.makeText(getContext(), "Error: " + resource.message, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
@@ -113,7 +113,7 @@ public class PetDetailFragment extends Fragment {
|
|||||||
if (resource.status == Resource.Status.SUCCESS) {
|
if (resource.status == Resource.Status.SUCCESS) {
|
||||||
ActivityLogger.log(requireContext(), "Added new Pet: " + name);
|
ActivityLogger.log(requireContext(), "Added new Pet: " + name);
|
||||||
Toast.makeText(getContext(), "Pet added successfully!", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getContext(), "Pet added successfully!", Toast.LENGTH_SHORT).show();
|
||||||
navigateBack();
|
navigateToPetList();
|
||||||
} else if (resource.status == Resource.Status.ERROR) {
|
} else if (resource.status == Resource.Status.ERROR) {
|
||||||
Toast.makeText(getContext(), "Error: " + resource.message, Toast.LENGTH_SHORT).show();
|
Toast.makeText(getContext(), "Error: " + resource.message, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
@@ -130,13 +130,20 @@ public class PetDetailFragment extends Fragment {
|
|||||||
if (resource.status == Resource.Status.SUCCESS) {
|
if (resource.status == Resource.Status.SUCCESS) {
|
||||||
ActivityLogger.logChange(requireContext(), "Pet", "DELETED", petId);
|
ActivityLogger.logChange(requireContext(), "Pet", "DELETED", petId);
|
||||||
Toast.makeText(getContext(), "Pet deleted successfully!", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getContext(), "Pet deleted successfully!", Toast.LENGTH_SHORT).show();
|
||||||
navigateBack();
|
navigateToPetList();
|
||||||
} else if (resource.status == Resource.Status.ERROR) {
|
} else if (resource.status == Resource.Status.ERROR) {
|
||||||
Toast.makeText(getContext(), "Delete failed: " + resource.message, Toast.LENGTH_SHORT).show();
|
Toast.makeText(getContext(), "Delete failed: " + resource.message, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Navigates back to the pet list screen.
|
||||||
|
*/
|
||||||
|
private void navigateToPetList() {
|
||||||
|
NavHostFragment.findNavController(this).popBackStack(R.id.nav_pet, false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Navigates back to the previous screen.
|
* Navigates back to the previous screen.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user