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
|
||||
if (savedInstanceState == null) {
|
||||
|
|
|
@ -54,6 +54,7 @@ public class ItemStepsAdapter extends RecyclerView.Adapter<ItemStepsAdapter.Item
|
|||
this.items = items;
|
||||
this.imageSelectionListener = listener;
|
||||
|
||||
dropdownOptions.add("0");
|
||||
dropdownOptions.add("1");
|
||||
dropdownOptions.add("2");
|
||||
dropdownOptions.add("3");
|
||||
|
|
|
@ -90,7 +90,7 @@ public class CheckingFragment extends Fragment implements EasyPermissions.Permis
|
|||
uriToByteArrayAsync(
|
||||
getContext(),
|
||||
selectedImage,
|
||||
100, // Target size in KB
|
||||
60, // Target size in KB
|
||||
compressedImage -> {
|
||||
// Handle the compressed image here, e.g., display it
|
||||
requireActivity().runOnUiThread(() -> {
|
||||
|
@ -120,7 +120,7 @@ public class CheckingFragment extends Fragment implements EasyPermissions.Permis
|
|||
uriToByteArrayAsync(
|
||||
getContext(),
|
||||
contentUri,
|
||||
100, // Target size in KB
|
||||
60, // Target size in KB
|
||||
compressedImage -> {
|
||||
// Handle the compressed image here, e.g., display it
|
||||
requireActivity().runOnUiThread(() -> {
|
||||
|
|
|
@ -92,7 +92,7 @@ public class CuttingFragment extends Fragment implements EasyPermissions.Permiss
|
|||
uriToByteArrayAsync(
|
||||
getContext(),
|
||||
selectedImage,
|
||||
100, // Target size in KB
|
||||
60, // Target size in KB
|
||||
compressedImage -> {
|
||||
// Handle the compressed image here, e.g., display it
|
||||
requireActivity().runOnUiThread(() -> {
|
||||
|
@ -122,7 +122,7 @@ public class CuttingFragment extends Fragment implements EasyPermissions.Permiss
|
|||
uriToByteArrayAsync(
|
||||
getContext(),
|
||||
contentUri,
|
||||
100, // Target size in KB
|
||||
60, // Target size in KB
|
||||
compressedImage -> {
|
||||
// Handle the compressed image here, e.g., display it
|
||||
requireActivity().runOnUiThread(() -> {
|
||||
|
|
|
@ -86,7 +86,7 @@ public class HomeFragment extends Fragment implements DepartmentItemAdapter.OnIt
|
|||
locationSiteTextview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
|
||||
Log.e("onItemClick: ","--Site");
|
||||
//Log.e("onItemClick: ","--Site");
|
||||
LocationSite clickedItem = locationSiteList.get(position);
|
||||
unitTextview.setText(null);
|
||||
floorTextview.setText(null);
|
||||
|
@ -112,7 +112,7 @@ public class HomeFragment extends Fragment implements DepartmentItemAdapter.OnIt
|
|||
unitTextview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
Log.e("onItemClick: ","--Unit");
|
||||
//Log.e("onItemClick: ","--Unit");
|
||||
LocationUnit clickedItem = locationUnitListFiltered.get(position);
|
||||
floorTextview.setText(null);
|
||||
//viewModel.setUnit(String.valueOf(clickedItem.getId()));
|
||||
|
@ -140,7 +140,7 @@ public class HomeFragment extends Fragment implements DepartmentItemAdapter.OnIt
|
|||
floorTextview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
|
||||
Log.e("onItemClick: ","--Floor");
|
||||
//Log.e("onItemClick: ","--Floor");
|
||||
LocationFloor clickedItem = locationFloorListFiltered.get(position);
|
||||
//viewModel.setFloor(String.valueOf(clickedItem.getId()));
|
||||
Preference.setMyStringPref(Helper.project_file, Helper.floorId, getActivity(), String.valueOf(clickedItem.getId()));
|
||||
|
@ -292,13 +292,16 @@ public class HomeFragment extends Fragment implements DepartmentItemAdapter.OnIt
|
|||
loginViewModel.getQualityControlData();
|
||||
} else {
|
||||
Log.e("From-Preference: ", "****");
|
||||
if (!Preference.getMyStringPref(Helper.project_file, Helper.departmentName, getActivity()).equalsIgnoreCase("default")) {
|
||||
Log.e("setText: ","*********");
|
||||
|
||||
isFromPrevious = true;
|
||||
|
||||
if (!Preference.getMyStringPref(Helper.project_file, Helper.departmentName, getActivity()).equalsIgnoreCase("default")) {
|
||||
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));
|
||||
}
|
||||
|
||||
if (!Preference.getMyStringPref(Helper.project_file, Helper.floorName, getActivity()).equalsIgnoreCase("default")) {
|
||||
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
|
||||
//departmentList.addAll(viewModel.getDepartmentList());
|
||||
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);
|
||||
// Set up filtered RecyclerView
|
||||
departmentItemAdapter = new DepartmentItemAdapter(filteredList, this, searchEditText, recyclerView);
|
||||
|
@ -320,7 +323,7 @@ public class HomeFragment extends Fragment implements DepartmentItemAdapter.OnIt
|
|||
//location list
|
||||
//locationSiteList.addAll(viewModel.getLocationSiteList());
|
||||
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);
|
||||
locationSiteTextview.setAdapter(locationSitesAdapter);
|
||||
|
@ -328,12 +331,14 @@ public class HomeFragment extends Fragment implements DepartmentItemAdapter.OnIt
|
|||
//unit list
|
||||
//locationUnitList.addAll(viewModel.getUnitList());
|
||||
locationUnitList.addAll(Helper.getList(Helper.homeUnit, getActivity(), LocationUnit.class));
|
||||
Log.e("locationUnitList-size: ", "" + locationUnitList.size());
|
||||
//Log.e("locationUnitList-size: ", "" + locationUnitList.size());
|
||||
|
||||
//floor list
|
||||
//locationFloorList.addAll(viewModel.getFloorList());
|
||||
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);
|
||||
|
||||
|
@ -435,4 +440,50 @@ public class HomeFragment extends Fragment implements DepartmentItemAdapter.OnIt
|
|||
|
||||
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(
|
||||
getContext(),
|
||||
selectedImage,
|
||||
100, // Target size in KB
|
||||
60, // Target size in KB
|
||||
compressedImage -> {
|
||||
// Handle the compressed image here, e.g., display it
|
||||
requireActivity().runOnUiThread(() -> {
|
||||
|
@ -121,7 +121,7 @@ public class PackingFragment extends Fragment implements EasyPermissions.Permiss
|
|||
uriToByteArrayAsync(
|
||||
getContext(),
|
||||
contentUri,
|
||||
100, // Target size in KB
|
||||
60, // Target size in KB
|
||||
compressedImage -> {
|
||||
// Handle the compressed image here, e.g., display it
|
||||
requireActivity().runOnUiThread(() -> {
|
||||
|
|
|
@ -93,7 +93,7 @@ public class StitchingFragment extends Fragment implements EasyPermissions.Permi
|
|||
uriToByteArrayAsync(
|
||||
getContext(),
|
||||
selectedImage,
|
||||
100, // Target size in KB
|
||||
60, // Target size in KB
|
||||
compressedImage -> {
|
||||
// Handle the compressed image here, e.g., display it
|
||||
requireActivity().runOnUiThread(() -> {
|
||||
|
@ -123,7 +123,7 @@ public class StitchingFragment extends Fragment implements EasyPermissions.Permi
|
|||
uriToByteArrayAsync(
|
||||
getContext(),
|
||||
contentUri,
|
||||
100, // Target size in KB
|
||||
60, // Target size in KB
|
||||
compressedImage -> {
|
||||
// Handle the compressed image here, e.g., display it
|
||||
requireActivity().runOnUiThread(() -> {
|
||||
|
|
|
@ -95,7 +95,7 @@ public class SubStoreFragment extends Fragment implements EasyPermissions.Permis
|
|||
uriToByteArrayAsync(
|
||||
getContext(),
|
||||
selectedImage,
|
||||
100, // Target size in KB
|
||||
60, // Target size in KB
|
||||
compressedImage -> {
|
||||
// Handle the compressed image here, e.g., display it
|
||||
requireActivity().runOnUiThread(() -> {
|
||||
|
@ -125,7 +125,7 @@ public class SubStoreFragment extends Fragment implements EasyPermissions.Permis
|
|||
uriToByteArrayAsync(
|
||||
getContext(),
|
||||
contentUri,
|
||||
100, // Target size in KB
|
||||
60, // Target size in KB
|
||||
compressedImage -> {
|
||||
// Handle the compressed image here, e.g., display it
|
||||
requireActivity().runOnUiThread(() -> {
|
||||
|
@ -288,6 +288,7 @@ public class SubStoreFragment extends Fragment implements EasyPermissions.Permis
|
|||
", floorId: " + qualityControl.getFloorId());*/
|
||||
|
||||
homeViewModel.saveQualityControlData(qualityControl);
|
||||
|
||||
} else {
|
||||
dialog.dismiss();
|
||||
}
|
||||
|
|
|
@ -11,6 +11,9 @@ import com.utopiaindustries.qualitycontrol.apiservice.ApiServiceFactory;
|
|||
import com.utopiaindustries.qualitycontrol.models.QualityControlResponse;
|
||||
import com.utopiaindustries.qualitycontrol.models.QualitySaveResponse;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
@ -21,12 +24,14 @@ public class HomeViewModel extends ViewModel {
|
|||
private MutableLiveData<String> errorLiveData;
|
||||
private MutableLiveData<Boolean> isLoading;
|
||||
private ApiService apiService;
|
||||
private final ExecutorService executorService;
|
||||
|
||||
public HomeViewModel() {
|
||||
apiService = ApiServiceFactory.getApiService();
|
||||
userLiveData = new MutableLiveData<>();
|
||||
errorLiveData = new MutableLiveData<>();
|
||||
isLoading = new MutableLiveData<>();
|
||||
this.executorService = Executors.newFixedThreadPool(4);
|
||||
}
|
||||
|
||||
public LiveData<QualitySaveResponse> getUserLiveData() {
|
||||
|
@ -42,7 +47,7 @@ public class HomeViewModel extends ViewModel {
|
|||
return errorLiveData;
|
||||
}
|
||||
|
||||
public void saveQualityControlData(QualityControl qualityControl) {
|
||||
/*public void saveQualityControlData(QualityControl qualityControl) {
|
||||
isLoading.setValue(true);
|
||||
apiService.saveQualityControlReport(qualityControl).enqueue(new Callback<QualitySaveResponse>() {
|
||||
@Override
|
||||
|
@ -64,6 +69,31 @@ public class HomeViewModel extends ViewModel {
|
|||
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() {
|
||||
|
@ -73,4 +103,11 @@ public class HomeViewModel extends ViewModel {
|
|||
public LiveData<String> getError() {
|
||||
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_marginEnd="10dp"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true"
|
||||
android:hint="Remarks"
|
||||
android:imeOptions="actionDone"
|
||||
android:layout_toEndOf="@+id/tv_percentage"
|
||||
|
|
Loading…
Reference in New Issue