remove dead code
This commit is contained in:
@@ -26,7 +26,6 @@ import com.example.petstoremobile.dtos.InventoryDTO;
|
|||||||
import com.example.petstoremobile.dtos.InventoryRequest;
|
import com.example.petstoremobile.dtos.InventoryRequest;
|
||||||
import com.example.petstoremobile.dtos.PageResponse;
|
import com.example.petstoremobile.dtos.PageResponse;
|
||||||
import com.example.petstoremobile.dtos.ProductDTO;
|
import com.example.petstoremobile.dtos.ProductDTO;
|
||||||
import com.example.petstoremobile.fragments.listfragments.InventoryFragment;
|
|
||||||
import com.example.petstoremobile.utils.ErrorUtils;
|
import com.example.petstoremobile.utils.ErrorUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -52,7 +51,6 @@ public class InventoryDetailFragment extends Fragment {
|
|||||||
|
|
||||||
@Inject InventoryApi inventoryApi;
|
@Inject InventoryApi inventoryApi;
|
||||||
@Inject ProductApi productApi;
|
@Inject ProductApi productApi;
|
||||||
private InventoryFragment inventoryFragment;
|
|
||||||
|
|
||||||
private boolean isEditing = false;
|
private boolean isEditing = false;
|
||||||
private long inventoryId = -1;
|
private long inventoryId = -1;
|
||||||
@@ -68,13 +66,6 @@ public class InventoryDetailFragment extends Fragment {
|
|||||||
private final List<ProductDTO> productSuggestions = new ArrayList<>();
|
private final List<ProductDTO> productSuggestions = new ArrayList<>();
|
||||||
private ArrayAdapter<String> dropdownAdapter;
|
private ArrayAdapter<String> dropdownAdapter;
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the parent inventory fragment to notify of changes.
|
|
||||||
*/
|
|
||||||
public void setInventoryFragment(InventoryFragment fragment) {
|
|
||||||
this.inventoryFragment = fragment;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
@@ -270,7 +261,7 @@ public class InventoryDetailFragment extends Fragment {
|
|||||||
setButtonsEnabled(true);
|
setButtonsEnabled(true);
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
Toast.makeText(getContext(), "Inventory updated", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getContext(), "Inventory updated", Toast.LENGTH_SHORT).show();
|
||||||
notifyParentAndGoBack();
|
navigateBack();
|
||||||
} else {
|
} else {
|
||||||
ErrorUtils.showErrorMessage(getContext(), response, "Update failed");
|
ErrorUtils.showErrorMessage(getContext(), response, "Update failed");
|
||||||
}
|
}
|
||||||
@@ -289,7 +280,7 @@ public class InventoryDetailFragment extends Fragment {
|
|||||||
setButtonsEnabled(true);
|
setButtonsEnabled(true);
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
Toast.makeText(getContext(), "Inventory created", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getContext(), "Inventory created", Toast.LENGTH_SHORT).show();
|
||||||
notifyParentAndGoBack();
|
navigateBack();
|
||||||
} else {
|
} else {
|
||||||
ErrorUtils.showErrorMessage(getContext(), response, "Create failed");
|
ErrorUtils.showErrorMessage(getContext(), response, "Create failed");
|
||||||
}
|
}
|
||||||
@@ -327,7 +318,7 @@ public class InventoryDetailFragment extends Fragment {
|
|||||||
setButtonsEnabled(true);
|
setButtonsEnabled(true);
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
Toast.makeText(getContext(), "Inventory deleted", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getContext(), "Inventory deleted", Toast.LENGTH_SHORT).show();
|
||||||
notifyParentAndGoBack();
|
navigateBack();
|
||||||
} else {
|
} else {
|
||||||
ErrorUtils.showErrorMessage(getContext(), response, "Delete failed");
|
ErrorUtils.showErrorMessage(getContext(), response, "Delete failed");
|
||||||
}
|
}
|
||||||
@@ -341,15 +332,6 @@ public class InventoryDetailFragment extends Fragment {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Notifies the parent fragment of a change and navigates back.
|
|
||||||
*/
|
|
||||||
private void notifyParentAndGoBack() {
|
|
||||||
if (inventoryFragment != null)
|
|
||||||
inventoryFragment.onInventoryChanged();
|
|
||||||
navigateBack();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Navigates back to the previous fragment.
|
* Navigates back to the previous fragment.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import android.widget.Toast;
|
|||||||
import com.example.petstoremobile.R;
|
import com.example.petstoremobile.R;
|
||||||
import com.example.petstoremobile.api.ServiceApi;
|
import com.example.petstoremobile.api.ServiceApi;
|
||||||
import com.example.petstoremobile.dtos.ServiceDTO;
|
import com.example.petstoremobile.dtos.ServiceDTO;
|
||||||
import com.example.petstoremobile.fragments.listfragments.ServiceFragment;
|
|
||||||
import com.example.petstoremobile.utils.ActivityLogger;
|
import com.example.petstoremobile.utils.ActivityLogger;
|
||||||
import com.example.petstoremobile.utils.ErrorUtils;
|
import com.example.petstoremobile.utils.ErrorUtils;
|
||||||
import com.example.petstoremobile.utils.InputValidator;
|
import com.example.petstoremobile.utils.InputValidator;
|
||||||
@@ -41,17 +40,9 @@ public class ServiceDetailFragment extends Fragment {
|
|||||||
private Button btnSaveService, btnDeleteService, btnBack;
|
private Button btnSaveService, btnDeleteService, btnBack;
|
||||||
private int serviceId;
|
private int serviceId;
|
||||||
private boolean isEditing = false;
|
private boolean isEditing = false;
|
||||||
private ServiceFragment serviceFragment;
|
|
||||||
|
|
||||||
@Inject ServiceApi serviceApi;
|
@Inject ServiceApi serviceApi;
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the parent service fragment to notify of changes.
|
|
||||||
*/
|
|
||||||
public void setServiceFragment(ServiceFragment fragment) {
|
|
||||||
this.serviceFragment = fragment;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
@@ -207,7 +198,7 @@ public class ServiceDetailFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set UI components from the layout.
|
* Initializes UI components from the layout.
|
||||||
*/
|
*/
|
||||||
private void initViews(View view) {
|
private void initViews(View view) {
|
||||||
tvMode = view.findViewById(R.id.tvMode);
|
tvMode = view.findViewById(R.id.tvMode);
|
||||||
@@ -220,4 +211,4 @@ public class ServiceDetailFragment extends Fragment {
|
|||||||
btnDeleteService = view.findViewById(R.id.btnDeleteService);
|
btnDeleteService = view.findViewById(R.id.btnDeleteService);
|
||||||
btnBack = view.findViewById(R.id.btnBack);
|
btnBack = view.findViewById(R.id.btnBack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.example.petstoremobile.viewmodels;
|
package com.example.petstoremobile.viewmodels;
|
||||||
|
|
||||||
import androidx.lifecycle.LiveData;
|
import androidx.lifecycle.LiveData;
|
||||||
import androidx.lifecycle.MutableLiveData;
|
|
||||||
import androidx.lifecycle.ViewModel;
|
import androidx.lifecycle.ViewModel;
|
||||||
|
|
||||||
import com.example.petstoremobile.dtos.PageResponse;
|
import com.example.petstoremobile.dtos.PageResponse;
|
||||||
@@ -17,7 +16,6 @@ import okhttp3.MultipartBody;
|
|||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
public class PetViewModel extends ViewModel {
|
public class PetViewModel extends ViewModel {
|
||||||
private final PetRepository repository;
|
private final PetRepository repository;
|
||||||
private final MutableLiveData<Long> _petId = new MutableLiveData<>();
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public PetViewModel(PetRepository repository) {
|
public PetViewModel(PetRepository repository) {
|
||||||
|
|||||||
Reference in New Issue
Block a user