Feedback implemented
parent
c50bc5eed6
commit
3becd62c12
|
@ -86,20 +86,6 @@ public class HomeActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//btnNext = findViewById(R.id.btn_next);
|
|
||||||
|
|
||||||
// Initialize fragments
|
|
||||||
/*fragmentList.add(new HomeFragment());
|
|
||||||
fragmentList.add(new CuttingFragment());
|
|
||||||
fragmentList.add(new StitchingFragment());
|
|
||||||
fragmentList.add(new CheckingFragment());
|
|
||||||
fragmentList.add(new PackingFragment());
|
|
||||||
fragmentList.add(new SubStoreFragment());*/
|
|
||||||
|
|
||||||
// Load the first fragment
|
|
||||||
//loadFragment(fragmentList.get(currentFragmentIndex));
|
|
||||||
|
|
||||||
/*btnNext.setOnClickListener(v -> navigateNext());*/
|
|
||||||
|
|
||||||
// Load the first fragment only if there's no saved instance
|
// Load the first fragment only if there's no saved instance
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
|
|
|
@ -54,6 +54,7 @@ public class ItemStepsAdapter extends RecyclerView.Adapter<ItemStepsAdapter.Item
|
||||||
this.items = items;
|
this.items = items;
|
||||||
this.imageSelectionListener = listener;
|
this.imageSelectionListener = listener;
|
||||||
|
|
||||||
|
dropdownOptions.add("0");
|
||||||
dropdownOptions.add("1");
|
dropdownOptions.add("1");
|
||||||
dropdownOptions.add("2");
|
dropdownOptions.add("2");
|
||||||
dropdownOptions.add("3");
|
dropdownOptions.add("3");
|
||||||
|
|
|
@ -90,7 +90,7 @@ public class CheckingFragment extends Fragment implements EasyPermissions.Permis
|
||||||
uriToByteArrayAsync(
|
uriToByteArrayAsync(
|
||||||
getContext(),
|
getContext(),
|
||||||
selectedImage,
|
selectedImage,
|
||||||
100, // Target size in KB
|
60, // Target size in KB
|
||||||
compressedImage -> {
|
compressedImage -> {
|
||||||
// Handle the compressed image here, e.g., display it
|
// Handle the compressed image here, e.g., display it
|
||||||
requireActivity().runOnUiThread(() -> {
|
requireActivity().runOnUiThread(() -> {
|
||||||
|
@ -120,7 +120,7 @@ public class CheckingFragment extends Fragment implements EasyPermissions.Permis
|
||||||
uriToByteArrayAsync(
|
uriToByteArrayAsync(
|
||||||
getContext(),
|
getContext(),
|
||||||
contentUri,
|
contentUri,
|
||||||
100, // Target size in KB
|
60, // Target size in KB
|
||||||
compressedImage -> {
|
compressedImage -> {
|
||||||
// Handle the compressed image here, e.g., display it
|
// Handle the compressed image here, e.g., display it
|
||||||
requireActivity().runOnUiThread(() -> {
|
requireActivity().runOnUiThread(() -> {
|
||||||
|
|
|
@ -92,7 +92,7 @@ public class CuttingFragment extends Fragment implements EasyPermissions.Permiss
|
||||||
uriToByteArrayAsync(
|
uriToByteArrayAsync(
|
||||||
getContext(),
|
getContext(),
|
||||||
selectedImage,
|
selectedImage,
|
||||||
100, // Target size in KB
|
60, // Target size in KB
|
||||||
compressedImage -> {
|
compressedImage -> {
|
||||||
// Handle the compressed image here, e.g., display it
|
// Handle the compressed image here, e.g., display it
|
||||||
requireActivity().runOnUiThread(() -> {
|
requireActivity().runOnUiThread(() -> {
|
||||||
|
@ -122,7 +122,7 @@ public class CuttingFragment extends Fragment implements EasyPermissions.Permiss
|
||||||
uriToByteArrayAsync(
|
uriToByteArrayAsync(
|
||||||
getContext(),
|
getContext(),
|
||||||
contentUri,
|
contentUri,
|
||||||
100, // Target size in KB
|
60, // Target size in KB
|
||||||
compressedImage -> {
|
compressedImage -> {
|
||||||
// Handle the compressed image here, e.g., display it
|
// Handle the compressed image here, e.g., display it
|
||||||
requireActivity().runOnUiThread(() -> {
|
requireActivity().runOnUiThread(() -> {
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class HomeFragment extends Fragment implements DepartmentItemAdapter.OnIt
|
||||||
locationSiteTextview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
locationSiteTextview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
|
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
|
||||||
Log.e("onItemClick: ","--Site");
|
//Log.e("onItemClick: ","--Site");
|
||||||
LocationSite clickedItem = locationSiteList.get(position);
|
LocationSite clickedItem = locationSiteList.get(position);
|
||||||
unitTextview.setText(null);
|
unitTextview.setText(null);
|
||||||
floorTextview.setText(null);
|
floorTextview.setText(null);
|
||||||
|
@ -112,7 +112,7 @@ public class HomeFragment extends Fragment implements DepartmentItemAdapter.OnIt
|
||||||
unitTextview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
unitTextview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
Log.e("onItemClick: ","--Unit");
|
//Log.e("onItemClick: ","--Unit");
|
||||||
LocationUnit clickedItem = locationUnitListFiltered.get(position);
|
LocationUnit clickedItem = locationUnitListFiltered.get(position);
|
||||||
floorTextview.setText(null);
|
floorTextview.setText(null);
|
||||||
//viewModel.setUnit(String.valueOf(clickedItem.getId()));
|
//viewModel.setUnit(String.valueOf(clickedItem.getId()));
|
||||||
|
@ -140,7 +140,7 @@ public class HomeFragment extends Fragment implements DepartmentItemAdapter.OnIt
|
||||||
floorTextview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
floorTextview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
|
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
|
||||||
Log.e("onItemClick: ","--Floor");
|
//Log.e("onItemClick: ","--Floor");
|
||||||
LocationFloor clickedItem = locationFloorListFiltered.get(position);
|
LocationFloor clickedItem = locationFloorListFiltered.get(position);
|
||||||
//viewModel.setFloor(String.valueOf(clickedItem.getId()));
|
//viewModel.setFloor(String.valueOf(clickedItem.getId()));
|
||||||
Preference.setMyStringPref(Helper.project_file, Helper.floorId, getActivity(), String.valueOf(clickedItem.getId()));
|
Preference.setMyStringPref(Helper.project_file, Helper.floorId, getActivity(), String.valueOf(clickedItem.getId()));
|
||||||
|
@ -287,18 +287,21 @@ public class HomeFragment extends Fragment implements DepartmentItemAdapter.OnIt
|
||||||
if (Preference.getMyStringPref(Helper.project_file, Helper.firstTimeApiCall, getActivity()).equalsIgnoreCase("false") ||
|
if (Preference.getMyStringPref(Helper.project_file, Helper.firstTimeApiCall, getActivity()).equalsIgnoreCase("false") ||
|
||||||
Preference.getMyStringPref(Helper.project_file, Helper.firstTimeApiCall, getActivity()).equalsIgnoreCase("default")) {
|
Preference.getMyStringPref(Helper.project_file, Helper.firstTimeApiCall, getActivity()).equalsIgnoreCase("default")) {
|
||||||
|
|
||||||
Log.e("From-Service: ","****");
|
Log.e("From-Service: ", "****");
|
||||||
|
|
||||||
loginViewModel.getQualityControlData();
|
loginViewModel.getQualityControlData();
|
||||||
} else {
|
} else {
|
||||||
Log.e("From-Preference: ","****");
|
Log.e("From-Preference: ", "****");
|
||||||
|
isFromPrevious = true;
|
||||||
if (!Preference.getMyStringPref(Helper.project_file, Helper.departmentName, getActivity()).equalsIgnoreCase("default")) {
|
if (!Preference.getMyStringPref(Helper.project_file, Helper.departmentName, getActivity()).equalsIgnoreCase("default")) {
|
||||||
Log.e("setText: ","*********");
|
|
||||||
|
|
||||||
isFromPrevious = true;
|
|
||||||
|
|
||||||
locationSiteTextview.post(() -> locationSiteTextview.setText(Preference.getMyStringPref(Helper.project_file, Helper.locationSiteName, getActivity()), false));
|
locationSiteTextview.post(() -> locationSiteTextview.setText(Preference.getMyStringPref(Helper.project_file, Helper.locationSiteName, getActivity()), false));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Preference.getMyStringPref(Helper.project_file, Helper.unitName, getActivity()).equalsIgnoreCase("default")) {
|
||||||
unitTextview.post(() -> unitTextview.setText(Preference.getMyStringPref(Helper.project_file, Helper.unitName, getActivity()), false));
|
unitTextview.post(() -> unitTextview.setText(Preference.getMyStringPref(Helper.project_file, Helper.unitName, getActivity()), false));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Preference.getMyStringPref(Helper.project_file, Helper.floorName, getActivity()).equalsIgnoreCase("default")) {
|
||||||
floorTextview.post(() -> floorTextview.setText(Preference.getMyStringPref(Helper.project_file, Helper.floorName, getActivity()), false));
|
floorTextview.post(() -> floorTextview.setText(Preference.getMyStringPref(Helper.project_file, Helper.floorName, getActivity()), false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,7 +313,7 @@ public class HomeFragment extends Fragment implements DepartmentItemAdapter.OnIt
|
||||||
//department list
|
//department list
|
||||||
//departmentList.addAll(viewModel.getDepartmentList());
|
//departmentList.addAll(viewModel.getDepartmentList());
|
||||||
departmentList.addAll(Helper.getList(Helper.homeDepartment, getActivity(), Department.class));
|
departmentList.addAll(Helper.getList(Helper.homeDepartment, getActivity(), Department.class));
|
||||||
Log.e("departmentList-size: ", "" + departmentList.size());
|
//Log.e("departmentList-size: ", "" + departmentList.size());
|
||||||
filteredList = new ArrayList<>(departmentList);
|
filteredList = new ArrayList<>(departmentList);
|
||||||
// Set up filtered RecyclerView
|
// Set up filtered RecyclerView
|
||||||
departmentItemAdapter = new DepartmentItemAdapter(filteredList, this, searchEditText, recyclerView);
|
departmentItemAdapter = new DepartmentItemAdapter(filteredList, this, searchEditText, recyclerView);
|
||||||
|
@ -320,7 +323,7 @@ public class HomeFragment extends Fragment implements DepartmentItemAdapter.OnIt
|
||||||
//location list
|
//location list
|
||||||
//locationSiteList.addAll(viewModel.getLocationSiteList());
|
//locationSiteList.addAll(viewModel.getLocationSiteList());
|
||||||
locationSiteList.addAll(Helper.getList(Helper.homeSite, getActivity(), LocationSite.class));
|
locationSiteList.addAll(Helper.getList(Helper.homeSite, getActivity(), LocationSite.class));
|
||||||
Log.e("locationSiteList-size: ", "" + locationSiteList.size());
|
//Log.e("locationSiteList-size: ", "" + locationSiteList.size());
|
||||||
|
|
||||||
locationSitesAdapter = new LocationSitesAdapter(getActivity(), locationSiteList);
|
locationSitesAdapter = new LocationSitesAdapter(getActivity(), locationSiteList);
|
||||||
locationSiteTextview.setAdapter(locationSitesAdapter);
|
locationSiteTextview.setAdapter(locationSitesAdapter);
|
||||||
|
@ -328,12 +331,14 @@ public class HomeFragment extends Fragment implements DepartmentItemAdapter.OnIt
|
||||||
//unit list
|
//unit list
|
||||||
//locationUnitList.addAll(viewModel.getUnitList());
|
//locationUnitList.addAll(viewModel.getUnitList());
|
||||||
locationUnitList.addAll(Helper.getList(Helper.homeUnit, getActivity(), LocationUnit.class));
|
locationUnitList.addAll(Helper.getList(Helper.homeUnit, getActivity(), LocationUnit.class));
|
||||||
Log.e("locationUnitList-size: ", "" + locationUnitList.size());
|
//Log.e("locationUnitList-size: ", "" + locationUnitList.size());
|
||||||
|
|
||||||
//floor list
|
//floor list
|
||||||
//locationFloorList.addAll(viewModel.getFloorList());
|
//locationFloorList.addAll(viewModel.getFloorList());
|
||||||
locationFloorList.addAll(Helper.getList(Helper.homeFloor, getActivity(), LocationFloor.class));
|
locationFloorList.addAll(Helper.getList(Helper.homeFloor, getActivity(), LocationFloor.class));
|
||||||
Log.e("locationFloorList-size: ", "" + locationFloorList.size());
|
//Log.e("locationFloorList-size: ", "" + locationFloorList.size());
|
||||||
|
|
||||||
|
loadDropdownsOnBack();
|
||||||
|
|
||||||
recyclerView.setVisibility(View.GONE);
|
recyclerView.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
@ -435,4 +440,50 @@ public class HomeFragment extends Fragment implements DepartmentItemAdapter.OnIt
|
||||||
|
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void loadDropdownsOnBack() {
|
||||||
|
|
||||||
|
int locationSiteId;
|
||||||
|
int unitId;
|
||||||
|
|
||||||
|
//load unit dropdown
|
||||||
|
if (!Preference.getMyStringPref(Helper.project_file, Helper.locationSiteId, getActivity()).equalsIgnoreCase("default")) {
|
||||||
|
locationSiteId = Integer.parseInt(Preference.getMyStringPref(Helper.project_file, Helper.locationSiteId, getActivity()));
|
||||||
|
|
||||||
|
if (!locationUnitList.isEmpty()) {
|
||||||
|
List<LocationUnit> filteredUnitItems = locationUnitList.stream()
|
||||||
|
.filter(item -> Objects.equals(item.getSiteId(), locationSiteId))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
locationUnitListFiltered.clear();
|
||||||
|
locationUnitListFiltered.addAll(filteredUnitItems);
|
||||||
|
unitAdapter = new UnitAdapter(getActivity(), filteredUnitItems);
|
||||||
|
unitTextview.setAdapter(unitAdapter);
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
locationSiteId = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//load floor dropdown
|
||||||
|
if (!Preference.getMyStringPref(Helper.project_file, Helper.unitId, getActivity()).equalsIgnoreCase("default")) {
|
||||||
|
unitId = Integer.parseInt(Preference.getMyStringPref(Helper.project_file, Helper.unitId, getActivity()));
|
||||||
|
|
||||||
|
if (!locationFloorList.isEmpty()) {
|
||||||
|
List<LocationFloor> filteredFloorsList = locationFloorList.stream()
|
||||||
|
.filter(floor -> floor.getSiteId() == locationSiteId && Objects.equals(floor.getUnitId(), unitId))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
locationFloorListFiltered.clear();
|
||||||
|
locationFloorListFiltered.addAll(filteredFloorsList);
|
||||||
|
floorAdapter = new FloorAdapter(getActivity(), filteredFloorsList);
|
||||||
|
floorTextview.setAdapter(floorAdapter);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
unitId = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -91,7 +91,7 @@ public class PackingFragment extends Fragment implements EasyPermissions.Permiss
|
||||||
uriToByteArrayAsync(
|
uriToByteArrayAsync(
|
||||||
getContext(),
|
getContext(),
|
||||||
selectedImage,
|
selectedImage,
|
||||||
100, // Target size in KB
|
60, // Target size in KB
|
||||||
compressedImage -> {
|
compressedImage -> {
|
||||||
// Handle the compressed image here, e.g., display it
|
// Handle the compressed image here, e.g., display it
|
||||||
requireActivity().runOnUiThread(() -> {
|
requireActivity().runOnUiThread(() -> {
|
||||||
|
@ -121,7 +121,7 @@ public class PackingFragment extends Fragment implements EasyPermissions.Permiss
|
||||||
uriToByteArrayAsync(
|
uriToByteArrayAsync(
|
||||||
getContext(),
|
getContext(),
|
||||||
contentUri,
|
contentUri,
|
||||||
100, // Target size in KB
|
60, // Target size in KB
|
||||||
compressedImage -> {
|
compressedImage -> {
|
||||||
// Handle the compressed image here, e.g., display it
|
// Handle the compressed image here, e.g., display it
|
||||||
requireActivity().runOnUiThread(() -> {
|
requireActivity().runOnUiThread(() -> {
|
||||||
|
|
|
@ -93,7 +93,7 @@ public class StitchingFragment extends Fragment implements EasyPermissions.Permi
|
||||||
uriToByteArrayAsync(
|
uriToByteArrayAsync(
|
||||||
getContext(),
|
getContext(),
|
||||||
selectedImage,
|
selectedImage,
|
||||||
100, // Target size in KB
|
60, // Target size in KB
|
||||||
compressedImage -> {
|
compressedImage -> {
|
||||||
// Handle the compressed image here, e.g., display it
|
// Handle the compressed image here, e.g., display it
|
||||||
requireActivity().runOnUiThread(() -> {
|
requireActivity().runOnUiThread(() -> {
|
||||||
|
@ -123,7 +123,7 @@ public class StitchingFragment extends Fragment implements EasyPermissions.Permi
|
||||||
uriToByteArrayAsync(
|
uriToByteArrayAsync(
|
||||||
getContext(),
|
getContext(),
|
||||||
contentUri,
|
contentUri,
|
||||||
100, // Target size in KB
|
60, // Target size in KB
|
||||||
compressedImage -> {
|
compressedImage -> {
|
||||||
// Handle the compressed image here, e.g., display it
|
// Handle the compressed image here, e.g., display it
|
||||||
requireActivity().runOnUiThread(() -> {
|
requireActivity().runOnUiThread(() -> {
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class SubStoreFragment extends Fragment implements EasyPermissions.Permis
|
||||||
uriToByteArrayAsync(
|
uriToByteArrayAsync(
|
||||||
getContext(),
|
getContext(),
|
||||||
selectedImage,
|
selectedImage,
|
||||||
100, // Target size in KB
|
60, // Target size in KB
|
||||||
compressedImage -> {
|
compressedImage -> {
|
||||||
// Handle the compressed image here, e.g., display it
|
// Handle the compressed image here, e.g., display it
|
||||||
requireActivity().runOnUiThread(() -> {
|
requireActivity().runOnUiThread(() -> {
|
||||||
|
@ -125,7 +125,7 @@ public class SubStoreFragment extends Fragment implements EasyPermissions.Permis
|
||||||
uriToByteArrayAsync(
|
uriToByteArrayAsync(
|
||||||
getContext(),
|
getContext(),
|
||||||
contentUri,
|
contentUri,
|
||||||
100, // Target size in KB
|
60, // Target size in KB
|
||||||
compressedImage -> {
|
compressedImage -> {
|
||||||
// Handle the compressed image here, e.g., display it
|
// Handle the compressed image here, e.g., display it
|
||||||
requireActivity().runOnUiThread(() -> {
|
requireActivity().runOnUiThread(() -> {
|
||||||
|
@ -149,7 +149,7 @@ public class SubStoreFragment extends Fragment implements EasyPermissions.Permis
|
||||||
Uri selectedImage = result.getData().getData();
|
Uri selectedImage = result.getData().getData();
|
||||||
if (selectedImage != null) {
|
if (selectedImage != null) {
|
||||||
//imageView.setImageURI(selectedImage);
|
//imageView.setImageURI(selectedImage);
|
||||||
// Log.e("Selected-Image: ", "" + selectedImage);
|
// Log.e("Selected-Image: ", "" + selectedImage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -270,14 +270,14 @@ public class SubStoreFragment extends Fragment implements EasyPermissions.Permis
|
||||||
tempList.addAll(Helper.getArrayList(Helper.listChecking, getActivity()));
|
tempList.addAll(Helper.getArrayList(Helper.listChecking, getActivity()));
|
||||||
tempList.addAll(Helper.getArrayList(Helper.listPacking, getActivity()));
|
tempList.addAll(Helper.getArrayList(Helper.listPacking, getActivity()));
|
||||||
tempList.addAll(Helper.getArrayList(Helper.listSubStore, getActivity()));
|
tempList.addAll(Helper.getArrayList(Helper.listSubStore, getActivity()));
|
||||||
String generatedBy = Preference.getMyStringPref(Helper.project_file,Helper.logInUser,getActivity());
|
String generatedBy = Preference.getMyStringPref(Helper.project_file, Helper.logInUser, getActivity());
|
||||||
|
|
||||||
/*Log.e("AdapterData-1", "siteID: " + siteID +
|
/*Log.e("AdapterData-1", "siteID: " + siteID +
|
||||||
", unitId: " + unitId +
|
", unitId: " + unitId +
|
||||||
", departId: " + departId +
|
", departId: " + departId +
|
||||||
", floorId: " + floorId);*/
|
", floorId: " + floorId);*/
|
||||||
|
|
||||||
QualityControl qualityControl = new QualityControl(generatedBy,siteID,unitId,departId,floorId,tempList);
|
QualityControl qualityControl = new QualityControl(generatedBy, siteID, unitId, departId, floorId, tempList);
|
||||||
|
|
||||||
/*Log.e("---------------","-----------------");
|
/*Log.e("---------------","-----------------");
|
||||||
|
|
||||||
|
@ -288,6 +288,7 @@ public class SubStoreFragment extends Fragment implements EasyPermissions.Permis
|
||||||
", floorId: " + qualityControl.getFloorId());*/
|
", floorId: " + qualityControl.getFloorId());*/
|
||||||
|
|
||||||
homeViewModel.saveQualityControlData(qualityControl);
|
homeViewModel.saveQualityControlData(qualityControl);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
|
@ -353,11 +354,11 @@ public class SubStoreFragment extends Fragment implements EasyPermissions.Permis
|
||||||
Preference.remove(Helper.project_file, Helper.floorId, getActivity());
|
Preference.remove(Helper.project_file, Helper.floorId, getActivity());
|
||||||
Preference.remove(Helper.project_file, Helper.floorName, getActivity());
|
Preference.remove(Helper.project_file, Helper.floorName, getActivity());
|
||||||
|
|
||||||
Helper.RemoveArrayList(Helper.listCutting,getActivity());
|
Helper.RemoveArrayList(Helper.listCutting, getActivity());
|
||||||
Helper.RemoveArrayList(Helper.listStitching,getActivity());
|
Helper.RemoveArrayList(Helper.listStitching, getActivity());
|
||||||
Helper.RemoveArrayList(Helper.listChecking,getActivity());
|
Helper.RemoveArrayList(Helper.listChecking, getActivity());
|
||||||
Helper.RemoveArrayList(Helper.listPacking,getActivity());
|
Helper.RemoveArrayList(Helper.listPacking, getActivity());
|
||||||
Helper.RemoveArrayList(Helper.listSubStore,getActivity());
|
Helper.RemoveArrayList(Helper.listSubStore, getActivity());
|
||||||
|
|
||||||
//Preference.setMyStringPref(Helper.project_file, Helper.InProcess, getActivity(), "false");
|
//Preference.setMyStringPref(Helper.project_file, Helper.InProcess, getActivity(), "false");
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,9 @@ import com.utopiaindustries.qualitycontrol.apiservice.ApiServiceFactory;
|
||||||
import com.utopiaindustries.qualitycontrol.models.QualityControlResponse;
|
import com.utopiaindustries.qualitycontrol.models.QualityControlResponse;
|
||||||
import com.utopiaindustries.qualitycontrol.models.QualitySaveResponse;
|
import com.utopiaindustries.qualitycontrol.models.QualitySaveResponse;
|
||||||
|
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
|
@ -21,12 +24,14 @@ public class HomeViewModel extends ViewModel {
|
||||||
private MutableLiveData<String> errorLiveData;
|
private MutableLiveData<String> errorLiveData;
|
||||||
private MutableLiveData<Boolean> isLoading;
|
private MutableLiveData<Boolean> isLoading;
|
||||||
private ApiService apiService;
|
private ApiService apiService;
|
||||||
|
private final ExecutorService executorService;
|
||||||
|
|
||||||
public HomeViewModel() {
|
public HomeViewModel() {
|
||||||
apiService = ApiServiceFactory.getApiService();
|
apiService = ApiServiceFactory.getApiService();
|
||||||
userLiveData = new MutableLiveData<>();
|
userLiveData = new MutableLiveData<>();
|
||||||
errorLiveData = new MutableLiveData<>();
|
errorLiveData = new MutableLiveData<>();
|
||||||
isLoading = new MutableLiveData<>();
|
isLoading = new MutableLiveData<>();
|
||||||
|
this.executorService = Executors.newFixedThreadPool(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<QualitySaveResponse> getUserLiveData() {
|
public LiveData<QualitySaveResponse> getUserLiveData() {
|
||||||
|
@ -42,7 +47,7 @@ public class HomeViewModel extends ViewModel {
|
||||||
return errorLiveData;
|
return errorLiveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveQualityControlData(QualityControl qualityControl) {
|
/*public void saveQualityControlData(QualityControl qualityControl) {
|
||||||
isLoading.setValue(true);
|
isLoading.setValue(true);
|
||||||
apiService.saveQualityControlReport(qualityControl).enqueue(new Callback<QualitySaveResponse>() {
|
apiService.saveQualityControlReport(qualityControl).enqueue(new Callback<QualitySaveResponse>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -64,6 +69,31 @@ public class HomeViewModel extends ViewModel {
|
||||||
errorLiveData.setValue(t.getMessage());
|
errorLiveData.setValue(t.getMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public void saveQualityControlData(QualityControl qualityControl) {
|
||||||
|
isLoading.setValue(true); // Notify UI that the task is starting
|
||||||
|
|
||||||
|
// Execute the task in the background
|
||||||
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
// Synchronous network call
|
||||||
|
Response<QualitySaveResponse> response = apiService.saveQualityControlReport(qualityControl).execute();
|
||||||
|
|
||||||
|
// Switch to the main thread to update LiveData
|
||||||
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
|
userLiveData.postValue(response.body());
|
||||||
|
} else {
|
||||||
|
errorLiveData.postValue(response.message());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Handle errors
|
||||||
|
errorLiveData.postValue(e.getMessage());
|
||||||
|
} finally {
|
||||||
|
// Hide the loading spinner
|
||||||
|
isLoading.postValue(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<QualitySaveResponse> getUser() {
|
public LiveData<QualitySaveResponse> getUser() {
|
||||||
|
@ -73,4 +103,11 @@ public class HomeViewModel extends ViewModel {
|
||||||
public LiveData<String> getError() {
|
public LiveData<String> getError() {
|
||||||
return errorLiveData;
|
return errorLiveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCleared() {
|
||||||
|
super.onCleared();
|
||||||
|
// Shut down the executor service to prevent memory leaks
|
||||||
|
executorService.shutdown();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,7 @@
|
||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
android:layout_marginEnd="10dp"
|
android:layout_marginEnd="10dp"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
|
android:singleLine="true"
|
||||||
android:hint="Remarks"
|
android:hint="Remarks"
|
||||||
android:imeOptions="actionDone"
|
android:imeOptions="actionDone"
|
||||||
android:layout_toEndOf="@+id/tv_percentage"
|
android:layout_toEndOf="@+id/tv_percentage"
|
||||||
|
|
Loading…
Reference in New Issue