Feedback:

1- Draft Report Presented carton correction
2- Section correction
3- Add Hand Feel Not OK fields
main
saad.siddiq 2025-04-19 12:39:05 +05:00
parent 938794cb7d
commit 53f3380d93
5 changed files with 331 additions and 179 deletions

View File

@ -45,6 +45,8 @@ public class InspectionReportItem implements Serializable {
private double minorQualityLevel;
private double majorQualityLevel;
private long handFeelNotOkay;
private int levelMajorDefects;
private int levelMinorDefects;
@ -65,6 +67,7 @@ public class InspectionReportItem implements Serializable {
private String fnsku;
private String section;
private String sectionForDraft;
public long getId() {
return id;
@ -266,6 +269,14 @@ public class InspectionReportItem implements Serializable {
this.sampleSize = sampleSize;
}
public long getHandFeelNotOkay() {
return handFeelNotOkay;
}
public void setHandFeelNotOkay(long handFeelNotOkay) {
this.handFeelNotOkay = handFeelNotOkay;
}
public String getDateAdded() {
return dateAdded;
}
@ -426,6 +437,14 @@ public void setLevelMinorDefects(int levelMinorDefects) {
this.section = section;
}
public String getSectionForDraft() {
return sectionForDraft;
}
public void setSectionForDraft(String sectionForDraft) {
this.sectionForDraft = sectionForDraft;
}
public List<byte[]> getDimensionImages() {
return dimensionImages;
}

View File

@ -75,18 +75,16 @@ public class NetworkService extends Service {
private void pushDataToInternet() {
ReportRepository repository = new ReportRepository( this );
List<InspectionReportWrapper> reportWrappers = repository.findAllUnsynced();
Log.e("ReportWrappers-Size: ",""+reportWrappers.size());
InspectionReportService service = InspectionReportService.getInstance();
try {
List<InspectionReport> reports = getReports( reportWrappers );
Log.e("Reports.size(): ",""+reports.size());
int size = reports.size();
if( size > 0 ){
NotificationHelper.showNotification(
/*NotificationHelper.showNotification(
this,
"Uploading Reports",
String.format(" %d report(s) uploading..", reports.size() )
);
);*/
for ( InspectionReport report : reports ){
service.saveReport(report, new SaveReportCallback() {
@Override
@ -95,6 +93,10 @@ public class NetworkService extends Service {
repository.updateSyncStatus( report.getWrapperId() );
// remove file
FileUtils.deleteFile( report.getFilePath() );
NotificationHelper.showNotification(
NetworkService.this,
"Report Status", "1 Report uploaded successfully");
}
@Override
public void onFailure(Throwable throwable) {
@ -102,11 +104,11 @@ public class NetworkService extends Service {
}
});
}
NotificationHelper.showNotification(
/*NotificationHelper.showNotification(
this,
"Uploading Reports",
String.format(" %d report(s) uploaded successfully..", reports.size() )
);
);*/
}
} catch ( Exception e ) {
e.printStackTrace();

View File

@ -85,6 +85,7 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
private InspectionReportService inspectionReportService;
private EditText aqlSampleSize, cartonWeight, cartonLength, cartonWidth, cartonHeight;
private EditText packWeight, packLength, packWidth, packHeight;
private EditText etHandFeelNotOk, etHandFeelOk, etHandFeelPercent;
TextView txtTesting;
List<String> sizes = Collections.singletonList("[Size]");
@ -120,6 +121,10 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
//System.out.println(inspectionReport);
store.setReport(inspectionReport);
//System.out.println("Report-SKU: " + store.getReport().getItems().get(0).getFnsku());
inspectionLevel = String.valueOf(store.getReport().getItems().get(0).getInspectionLevel());
qualityLevelMajor = String.valueOf(store.getReport().getItems().get(0).getMajorQualityLevel());
qualityLevelMinor = String.valueOf(store.getReport().getItems().get(0).getMinorQualityLevel());
}
initializeViews(view);
@ -340,7 +345,7 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
});
//onTextChanges logic implementation
//box = 1, itemPerBox, pieces
//box = 1, itemPerBox, pieces // Item Selected Details
boxCartonSelected.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@ -351,7 +356,7 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
public void onTextChanged(CharSequence s, int start, int before, int count) {
try {
int packsCount = 0, piecesCount = 0;
int boxCount = Integer.parseInt(s.toString());
int boxCount = (int) Double.parseDouble(s.toString());
if (itemPerBox.getText().toString().isEmpty() || pieces.getText().toString().isEmpty()) {
Toast.makeText(getContext(), "Enter Item/Pieces Per box", Toast.LENGTH_SHORT).show();
} else {
@ -360,17 +365,16 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
int totalPacks = boxCount * packsCount;
int totalPieces = totalPacks * piecesCount;
Log.e("totalPacks: ",""+totalPacks);
Log.e("totalPieces: ",""+totalPieces);
itemPerBoxSelected.setText(String.valueOf(totalPacks));
store.getReport().getItems().get(0).setPacksSelected(Long.parseLong(String.valueOf(totalPacks)));
//store.getReport().getItems().get(0).setPacksSelected(Long.parseLong(String.valueOf(totalPacks)));
piecesSelected.setText(String.valueOf(totalPieces));
store.getReport().getItems().get(0).setPiecesSelected(Long.parseLong(String.valueOf(totalPieces)));
//store.getReport().getItems().get(0).setPiecesSelected(Long.parseLong(String.valueOf(totalPieces)));
}
store.getReport().getItems().get(0).setCartonsSelected(Long.parseLong(s.toString()));
store.getReport().getItems().get(0).setCartonsSelected(Float.parseFloat(s.toString()));
} catch (Exception e) {
e.printStackTrace();
store.getReport().getItems().get(0).setCartonsSelected(0);
}
}
@ -499,9 +503,9 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
try {
//calculate aql sample size
//Log.e("ItemPresentedDetails-pieces: ", "" + s.toString());
//Log.e("ItemPresentedDetails-inspectionLevel: ", "" + inspectionLevel);
if (!s.toString().isEmpty()) {
Log.e("ItemPresentedDetails-pieces: ", "" + s.toString());
Log.e("ItemPresentedDetails-inspectionLevel: ", "" + inspectionLevel);
if (!s.toString().isEmpty() && s.toString() != null) {
trackSampleCode(Integer.parseInt(s.toString()), (int) Double.parseDouble(inspectionLevel), Double.parseDouble(qualityLevelMajor), Double.parseDouble(qualityLevelMinor));
}
}
@ -713,6 +717,33 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
}
});
etHandFeelNotOk.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
try {
int sampleSize = Integer.parseInt(aqlSampleSize.getText().toString());
int handFeelNotOk = Integer.parseInt(s.toString());
int handFeelOk = sampleSize - handFeelNotOk;
etHandFeelOk.setText(String.valueOf(handFeelOk));
double percent = (double) handFeelNotOk / sampleSize * 100;
etHandFeelPercent.setText(String.format("%s%%", percent));
store.getReport().getItems().get(0).setHandFeelNotOkay(Long.parseLong(s.toString()));
} catch (Exception e) {
store.getReport().getItems().get(0).setHandFeelNotOkay(0);
}
}
@Override
public void afterTextChanged(Editable s) {
}
});
// generalRemarks.addTextChangedListener(new TextWatcher() {
// @Override
@ -931,9 +962,11 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
boxCarton.setText(boxCartonText);
packagingDetails.setText(packagingDetailsText);
Log.e("Carton: ",""+String.valueOf(store.getReport().getItems().get(0).getCartonsSelected()));
boxCartonSelected.setText(String.valueOf(store.getReport().getItems().get(0).getCartonsSelected()));
itemPerBoxSelected.setText(String.valueOf(store.getReport().getItems().get(0).getPacksSelected()));
piecesSelected.setText(String.valueOf(store.getReport().getItems().get(0).getPiecesSelected()));
//itemPerBoxSelected.setText(String.valueOf(store.getReport().getItems().get(0).getPacksSelected()));
//piecesSelected.setText(String.valueOf(store.getReport().getItems().get(0).getPiecesSelected()));
checkedBoxCartonSelected.setText(String.valueOf(store.getReport().getItems().get(0).getCheckedCartonsSelected()));
//checkedItemPerBoxSelected.setText(String.valueOf(store.getReport().getItems().get(0).getCheckedPacksSelected()));
@ -1080,6 +1113,9 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
boxCartonSelected = view.findViewById(R.id.box_carton_selected);
itemPerBoxSelected = view.findViewById(R.id.item_per_box_selected);
piecesSelected = view.findViewById(R.id.pieces_selected);
etHandFeelNotOk = view.findViewById(R.id.et_hand_feel_not_ok);
etHandFeelOk = view.findViewById(R.id.et_hand_feel_ok);
etHandFeelPercent = view.findViewById(R.id.et_not_ok_percent);
txtTesting = view.findViewById(R.id.txtTesting);

View File

@ -68,6 +68,7 @@ import com.utopiaindustries.qualitychecker.utils.ImageUriHolder;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@ -78,16 +79,16 @@ import retrofit2.Response;
public class ThirdStepFragment extends Fragment implements View.OnClickListener {
private NavController navController;
private Button backBtn,nextBtn,openDimensionDialog, btnDraft;
private ImageButton imagePicker, deleteImage ;
private Button backBtn, nextBtn, openDimensionDialog, btnDraft;
private ImageButton imagePicker, deleteImage;
private TextView profileName;
private ImageView profileImage;
private InspectionReportService inspectionReportService;
private RecyclerView vocRecyclerView,itemDimensionsRecyclerView;
private RecyclerView vocRecyclerView, itemDimensionsRecyclerView;
private Store store;
private Spinner resultSpinner, sectionSpinner;
private ApiService apiService;
private EditText generalRemarks, etQualityAuditor, etProdRepresentative, etQcRepresentative,etFloor;
private EditText generalRemarks, etQualityAuditor, etProdRepresentative, etQcRepresentative, etFloor;
private static final int MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE = 100;
private static final int MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 101;
private static final int MY_PERMISSIONS_REQUEST_CAMERA = 102;
@ -98,51 +99,48 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
private ImageAdapter imageAdapter;
private RecyclerView imageRecyclerView;
private TextView minorCountTv,majorCountTv,criticalCountTv, txtMajor, txtMinor;
String[] sectionArray = {"Comforter & Mattress Pad",
"Bedding",
"Blanket & Table Linen",
"Pillow",
"Terry Towel",
"Garments & Mattress Protector"};
private TextView minorCountTv, majorCountTv, criticalCountTv, txtMajor, txtMinor;
ArrayList<String> sectionArrayList = new ArrayList<>();
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_third_step , container, false );
View view = inflater.inflate(R.layout.fragment_third_step, container, false);
inspectionReportService = InspectionReportService.getInstance();
store = Store.getInstance();
apiService = ApiServiceFactory.getApiService();
initializeViews( view );
initializeViews(view);
checkPermissions();
populateViews();
setOnClickListeners();
updateProfileViews();
vocRecyclerView.setLayoutManager( new LinearLayoutManager( getContext() ) );
itemDimensionsRecyclerView.setLayoutManager( new LinearLayoutManager( getContext() ) );
vocRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
itemDimensionsRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
String asin = store.getReport().getItems().get(0).getAsin();
apiService.fetchVocs( asin ).enqueue(
apiService.fetchVocs(asin).enqueue(
new Callback<List<VoiceOfCustomer>>() {
@Override
public void onResponse(Call<List<VoiceOfCustomer>> call,
Response<List<VoiceOfCustomer>> response) {
if( response.isSuccessful() && response.body() != null ){
VocAdapter adapter = new VocAdapter( response.body(), getContext() );
vocRecyclerView.setAdapter( adapter );
if (response.isSuccessful() && response.body() != null) {
VocAdapter adapter = new VocAdapter(response.body(), getContext());
vocRecyclerView.setAdapter(adapter);
}
}
@Override
public void onFailure(Call<List<VoiceOfCustomer>> call, Throwable t) {
System.out.println( t.getMessage() );
System.out.println(t.getMessage());
}
}
);
ItemDimensionAdapter adapter = new ItemDimensionAdapter( store.getReport().getItems().get(0).getDimensions() );
itemDimensionsRecyclerView.setAdapter( adapter );
ItemDimensionAdapter adapter = new ItemDimensionAdapter(store.getReport().getItems().get(0).getDimensions());
itemDimensionsRecyclerView.setAdapter(adapter);
etQcRepresentative.addTextChangedListener(new TextWatcher() {
@Override
@ -153,9 +151,9 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
try {
store.getReport().setQcRepresentative( s.toString() );
} catch ( Exception e ){
store.getReport().setQcRepresentative( "");
store.getReport().setQcRepresentative(s.toString());
} catch (Exception e) {
store.getReport().setQcRepresentative("");
}
}
@ -174,9 +172,9 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
try {
store.getReport().setFloor( s.toString() );
} catch ( Exception e ){
store.getReport().setFloor( "");
store.getReport().setFloor(s.toString());
} catch (Exception e) {
store.getReport().setFloor("");
}
}
@ -195,9 +193,9 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
try {
store.getReport().setProductionRepresentative( s.toString() );
} catch ( Exception e ){
store.getReport().setProductionRepresentative( "");
store.getReport().setProductionRepresentative(s.toString());
} catch (Exception e) {
store.getReport().setProductionRepresentative("");
}
}
@ -216,9 +214,9 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
try {
store.getReport().setQualityAuditor( s.toString() );
} catch ( Exception e ){
store.getReport().setQualityAuditor( "");
store.getReport().setQualityAuditor(s.toString());
} catch (Exception e) {
store.getReport().setQualityAuditor("");
}
}
@ -237,9 +235,9 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
try {
store.getReport().setGeneralRemarks( s.toString() );
} catch ( Exception e ){
store.getReport().setGeneralRemarks( "");
store.getReport().setGeneralRemarks(s.toString());
} catch (Exception e) {
store.getReport().setGeneralRemarks("");
}
}
@ -249,7 +247,7 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
}
});
imagePicker.setOnClickListener( new View.OnClickListener() {
imagePicker.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -260,15 +258,15 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
builder.setItems(options, (dialog, which) -> {
switch (which) {
case 0:
Log.e("Gallery","**********");
Intent intent = new Intent( Intent.ACTION_GET_CONTENT );
intent.addCategory( Intent.CATEGORY_OPENABLE );
intent.setType( "image/*" );
Log.e("Gallery", "**********");
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("image/*");
//startActivityForResult( intent, GALLERY_REQUEST );
( ( Activity ) getContext() ).startActivityForResult( intent, GALLERY_REQUEST );
((Activity) getContext()).startActivityForResult(intent, GALLERY_REQUEST);
break;
case 1:
Log.e("Camera: ","***********");
Log.e("Camera: ", "***********");
Intent camera_intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File imageFile = new File(getContext().getExternalFilesDir(Environment.DIRECTORY_PICTURES), "captured_image.jpg");
Uri imageUri = FileProvider.getUriForFile(getContext(), getContext().getPackageName() + ".fileprovider", imageFile);
@ -276,7 +274,7 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
ImageUriHolder.getInstance().setImageUri(imageUri);
camera_intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
//startActivityForResult(camera_intent, CAMERA_REQUEST);
( ( Activity ) getContext() ).startActivityForResult( camera_intent, CAMERA_REQUEST );
((Activity) getContext()).startActivityForResult(camera_intent, CAMERA_REQUEST);
break;
}
});
@ -289,15 +287,14 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
}
});
deleteImage.setOnClickListener( new View.OnClickListener() {
deleteImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!store.getReport().getItems().get(0).getDimensionImages().isEmpty()) {
store.getReport().getItems().get(0).getDimensionImages().remove(store.getReport().getItems().get(0).getDimensionImages().size() - 1);
updateImageAdapter(store.getReport().getItems().get(0).getDimensionImages());
}
else {
} else {
System.out.println("The list is empty");
}
}
@ -310,8 +307,7 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
if (requestCode == CAMERA_REQUEST) {
Uri selectedImageUri = ImageUriHolder.getInstance().getImageUri();
saveImage(selectedImageUri);
}
else if (requestCode == GALLERY_REQUEST) {
} else if (requestCode == GALLERY_REQUEST) {
Uri selectedImageUri = data.getData();
assert selectedImageUri != null;
saveImage(selectedImageUri);
@ -354,14 +350,14 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
@Override
public void onClick(View v) {
navController = Navigation.findNavController( requireView() );
if( v.getId() == R.id.button_left_frag_3 ){
navController.navigate( R.id.action_thirdStepFragment_to_secondStepFragment );
navController = Navigation.findNavController(requireView());
if (v.getId() == R.id.button_left_frag_3) {
navController.navigate(R.id.action_thirdStepFragment_to_secondStepFragment);
}
if (v.getId() == R.id.button_draft_third) {
//--
if (store.getReport() != null) {
inspectionReportService.saveDraftInLocalDb( getContext(), store.getReport(), new SaveDraftReportCallback() {
inspectionReportService.saveDraftInLocalDb(getContext(), store.getReport(), new SaveDraftReportCallback() {
@Override
public void onSuccess() {
Handler handler = new Handler(Looper.getMainLooper());
@ -397,35 +393,35 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
//---
}
if( v.getId() == R.id.button_right_frag_3 ){
if (v.getId() == R.id.button_right_frag_3) {
saveReportDialog();
}
if( v.getId() == R.id.button_open_dimension ){
if (v.getId() == R.id.button_open_dimension) {
openDimensionDialog();
}
}
private void saveReportDialog(){
LayoutInflater inflater = LayoutInflater.from( getContext() );
View dialogView = inflater.inflate( R.layout.save_report_dialog, null);
private void saveReportDialog() {
LayoutInflater inflater = LayoutInflater.from(getContext());
View dialogView = inflater.inflate(R.layout.save_report_dialog, null);
// progress bar
ProgressBar progressBar = dialogView.findViewById( R.id.save_report_progress );
ProgressBar progressBar = dialogView.findViewById(R.id.save_report_progress);
AlertDialog.Builder builder = new AlertDialog.Builder( Objects.requireNonNull(getContext()) );
builder.setView( dialogView )
AlertDialog.Builder builder = new AlertDialog.Builder(Objects.requireNonNull(getContext()));
builder.setView(dialogView)
.setTitle("So you want to save report?")
.setPositiveButton( "Save",(dialog, which) -> {
.setPositiveButton("Save", (dialog, which) -> {
progressBar.setVisibility(View.VISIBLE);
NotificationHelper.showNotification(Objects.requireNonNull(getContext()),
"Utopia QA App",
"Report is saving keep patience...");
inspectionReportService.saveInLocalDb( getContext(), store.getReport(), new SaveReportCallback() {
inspectionReportService.saveInLocalDb(getContext(), store.getReport(), new SaveReportCallback() {
@Override
public void onSuccess() {
Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> {
Log.e("Report-ToString: ",""+store.getReport().toString());
Log.e("Report-ToString: ", "" + store.getReport().toString());
SharedPreferences sharedPreferences = getContext().getSharedPreferences("login_prefs", Context.MODE_PRIVATE);
long draftReportId = Long.parseLong(sharedPreferences.getString("draftReportId", null));
@ -458,41 +454,41 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
});
// Show the dialog
AlertDialog dialog = builder.create();
progressBar.setVisibility( View.GONE );
progressBar.setVisibility(View.GONE);
dialog.show();
}
private void openDimensionDialog() {
LayoutInflater inflater = LayoutInflater.from( getContext() );
View dialogView = inflater.inflate( R.layout.dimension_dialog, null);
LayoutInflater inflater = LayoutInflater.from(getContext());
View dialogView = inflater.inflate(R.layout.dimension_dialog, null);
// recycler view
RecyclerView dimensionRecyclerView = dialogView.findViewById( R.id.dimension_recycler_view );
LinearLayoutManager layoutManager = new LinearLayoutManager( getContext() );
dimensionRecyclerView.setLayoutManager( layoutManager );
RecyclerView dimensionRecyclerView = dialogView.findViewById(R.id.dimension_recycler_view);
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
dimensionRecyclerView.setLayoutManager(layoutManager);
// set adapter
DimensionAdapter dimensionAdapter = new DimensionAdapter( store.getDimensions(),
DimensionAdapter dimensionAdapter = new DimensionAdapter(store.getDimensions(),
store.getDimensionList(),
store.getItemUnits() );
dimensionRecyclerView.setAdapter( dimensionAdapter );
AlertDialog.Builder builder = new AlertDialog.Builder( Objects.requireNonNull( getContext() ));
store.getItemUnits());
dimensionRecyclerView.setAdapter(dimensionAdapter);
AlertDialog.Builder builder = new AlertDialog.Builder(Objects.requireNonNull(getContext()));
builder.setView(dialogView)
.setTitle("Select Dimensions")
.setPositiveButton( "Save",(dialog, which) -> {
.setPositiveButton("Save", (dialog, which) -> {
calculateDimensions();
dialog.dismiss();
} )
})
.setNegativeButton("Cancel", (dialog, which) -> {
// Handle Cancel button click
dialog.dismiss();
});
Button addItemBtn = dialogView.findViewById( R.id.add_dimension_item );
Button addItemBtn = dialogView.findViewById(R.id.add_dimension_item);
addItemBtn.setOnClickListener(v -> {
int position = store.getDimensions().size();
store.getDimensions().add( new InspectionItemDimension() );
dimensionAdapter.notifyItemInserted( position );
dimensionRecyclerView.smoothScrollToPosition( position );
store.getDimensions().add(new InspectionItemDimension());
dimensionAdapter.notifyItemInserted(position);
dimensionRecyclerView.smoothScrollToPosition(position);
});
@ -500,35 +496,35 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
AlertDialog dialog = builder.create();
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
layoutParams.copyFrom( dialog.getWindow().getAttributes() );
layoutParams.copyFrom(dialog.getWindow().getAttributes());
layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
dialog.getWindow().setAttributes(layoutParams);
dialog.show();
// After show, clear the flags and set the soft input mode
Objects.requireNonNull(dialog.getWindow()).clearFlags( WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM );
dialog.getWindow().setSoftInputMode( WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE );
Objects.requireNonNull(dialog.getWindow()).clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
@SuppressLint("DefaultLocale")
private void populateViews(){
generalRemarks.setText( store.getReport().getGeneralRemarks() );
private void populateViews() {
generalRemarks.setText(store.getReport().getGeneralRemarks());
etQualityAuditor.setText(store.getReport().getQualityAuditor());
etProdRepresentative.setText(store.getReport().getProductionRepresentative());
etQcRepresentative.setText(store.getReport().getQcRepresentative());
etFloor.setText(store.getReport().getFloor());
ArrayAdapter<String> adapter = new ArrayAdapter<>( getContext(),
ArrayAdapter<String> adapter = new ArrayAdapter<>(getContext(),
android.R.layout.simple_spinner_item,
inspectionReportService.getReportResult() );
resultSpinner.setAdapter( adapter );
inspectionReportService.getReportResult());
resultSpinner.setAdapter(adapter);
resultSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String result = parent.getItemAtPosition( position ).toString();
store.getReport().setReportResult( result );
String result = parent.getItemAtPosition(position).toString();
store.getReport().setReportResult(result);
}
@Override
@ -537,17 +533,18 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
}
});
ArrayAdapter<String> adapter2 = new ArrayAdapter<>( getContext(),
ArrayAdapter<String> adapter2 = new ArrayAdapter<>(getContext(),
android.R.layout.simple_spinner_item,
sectionArray );
sectionSpinner.setAdapter( adapter2 );
sectionArrayList);
sectionSpinner.setAdapter(adapter2);
sectionSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String result = parent.getItemAtPosition( position ).toString().trim().replace(" ", "");
store.getReport().getItems().get(0).setSection( result.trim() );
Log.e("Section: ",""+result);
String result = parent.getItemAtPosition(position).toString().trim().replace(" ", "");
store.getReport().getItems().get(0).setSection(result.trim());
store.getReport().getItems().get(0).setSectionForDraft(parent.getItemAtPosition(position).toString());
Log.e("Section: ", "" + result);
}
@Override
@ -556,77 +553,88 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
}
});
minorCountTv.setText( String.valueOf(0) );
majorCountTv.setText( String.valueOf(0) ) ;
criticalCountTv.setText( String.valueOf(0) );
minorCountTv.setText(String.valueOf(0));
majorCountTv.setText(String.valueOf(0));
criticalCountTv.setText(String.valueOf(0));
InspectionReport inspectionReport = store.getReport();
if( Objects.nonNull( inspectionReport ) && inspectionReport.getItems() != null &&
! inspectionReport.getItems().isEmpty() &&
! inspectionReport.getItems().get(0).getCheckPoints().isEmpty() ) {
if (Objects.nonNull(inspectionReport) && inspectionReport.getItems() != null &&
!inspectionReport.getItems().isEmpty() &&
!inspectionReport.getItems().get(0).getCheckPoints().isEmpty()) {
int minor = 0;
int major = 0;
int crirical = 0;
for (InspectionItemCheckPoint itemCp : inspectionReport.getItems().get(0).getCheckPoints()) {
for( int i = 0 ; i< itemCp.getDefectSeverites().size() ; i++ ){
String status = itemCp.getDefectSeverites().get( i );
System.out.println( status);
for (int i = 0; i < itemCp.getDefectSeverites().size(); i++) {
String status = itemCp.getDefectSeverites().get(i);
System.out.println(status);
float quantity = itemCp.getQuantities().get(i);
if( status.equalsIgnoreCase("minor") ){
if (status.equalsIgnoreCase("minor")) {
minor += (int) quantity;
} ;
if( status.equalsIgnoreCase("major") ){
}
;
if (status.equalsIgnoreCase("major")) {
major += (int) quantity;
}
if( status.equalsIgnoreCase("critical") ) {
if (status.equalsIgnoreCase("critical")) {
crirical += (int) quantity;
}
}
}
minorCountTv.setText( String.format("Minor : %d", minor ) );
majorCountTv.setText( String.format("Major : %d", major ) ) ;
criticalCountTv.setText( String.format("Critical : %d", crirical ) );
minorCountTv.setText(String.format("Minor : %d", minor));
majorCountTv.setText(String.format("Major : %d", major));
criticalCountTv.setText(String.format("Critical : %d", crirical));
double majorInspection = store.getReport().getItems().get(0).getLevelMajorDefects();
double minorInspection = store.getReport().getItems().get(0).getLevelMinorDefects();
if((double) minor <= minorInspection
if ((double) minor <= minorInspection
&& (double) major <= majorInspection
&& (double) crirical == 0) {
//resultStatus.setText("PASSED");
String defaultSelection = "PASSED";
int defaultIndexResultIndex = inspectionReportService.getReportResult().indexOf( defaultSelection );
resultSpinner.setSelection( defaultIndexResultIndex );
int defaultIndexResultIndex = inspectionReportService.getReportResult().indexOf(defaultSelection);
resultSpinner.setSelection(defaultIndexResultIndex);
store.getReport().setReportResult("PASSED");
//resultStatus.setTextColor(ContextCompat.getColor(requireContext(),R.color.success));
//resultStatus.setBackgroundResource( R.drawable.passed_bg );
}
else{
} else {
//resultStatus.setText("FAILED");
//resultStatus.setTextColor(ContextCompat.getColor(requireContext(),R.color.red));
String defaultSelection = "FAILED";
int defaultIndexResultIndex = inspectionReportService.getReportResult().indexOf( defaultSelection );
resultSpinner.setSelection( defaultIndexResultIndex );
int defaultIndexResultIndex = inspectionReportService.getReportResult().indexOf(defaultSelection);
resultSpinner.setSelection(defaultIndexResultIndex);
store.getReport().setReportResult("FAILED");
//resultStatus.setBackgroundResource( R.drawable.failed_bg );
}
//Log.e("majorCount: ",""+majorInspection);
//Log.e("minorCount: ",""+minorInspection);
txtMajor.setText(String.format("Major : %s/%d", (int)majorInspection, (int)(majorInspection + 1)));
txtMinor.setText(String.format("Minor : %s/%d", (int)minorInspection, (int)(minorInspection + 1)));
txtMajor.setText(String.format("Major : %s/%d", (int) majorInspection, (int) (majorInspection + 1)));
txtMinor.setText(String.format("Minor : %s/%d", (int) minorInspection, (int) (minorInspection + 1)));
}
if (!store.getReport().getItems().get(0).getDimensionImages().isEmpty()) {
updateImageAdapter(store.getReport().getItems().get(0).getDimensionImages());
}
SharedPreferences sharedPreferences = getContext().getSharedPreferences("login_prefs", Context.MODE_PRIVATE);
long draftReportId = Long.parseLong(sharedPreferences.getString("draftReportId", null));
if (draftReportId > 0) {
Log.e("draft-Report-ID: ",""+draftReportId);
String selectedString = store.getReport().getItems().get(0).getSectionForDraft();
Log.e("draft-Report-selected: ",""+selectedString);
int index = sectionArrayList.indexOf(selectedString);
Log.e("draft-index: ",""+index);
sectionSpinner.setSelection(index);
}
}
private void calculateDimensions(){
private void calculateDimensions() {
List<InspectionItemDimension> dimensions = store.getDimensions();
System.out.println( dimensions );
System.out.println(dimensions);
// List<InspectionItemDimension> newDimensions = new ArrayList<>();
try {
// if(! dimensions.isEmpty() ){
@ -638,27 +646,27 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
// InspectionItemDimension newDimen = getInspectionItemDimension( entry );
// newDimensions.add( newDimen );
// }
store.getReport().getItems().get(0).setDimensions( dimensions );
ItemDimensionAdapter adapter = new ItemDimensionAdapter( dimensions );
itemDimensionsRecyclerView.setAdapter( adapter );
} catch ( NullPointerException ex ){
Toast.makeText( getContext() , "Please fill the required Fields", Toast.LENGTH_LONG ).show();
store.getReport().getItems().get(0).setDimensions(dimensions);
ItemDimensionAdapter adapter = new ItemDimensionAdapter(dimensions);
itemDimensionsRecyclerView.setAdapter(adapter);
} catch (NullPointerException ex) {
Toast.makeText(getContext(), "Please fill the required Fields", Toast.LENGTH_LONG).show();
}
}
@NonNull
private static InspectionItemDimension getInspectionItemDimension( Map.Entry<String, List<InspectionItemDimension>> entry ) {
private static InspectionItemDimension getInspectionItemDimension(Map.Entry<String, List<InspectionItemDimension>> entry) {
float required = 0f;
float actual = 0f;
float difference = 0f;
String unit = null;
float size = entry.getValue().size();
for( InspectionItemDimension dimen : entry.getValue() ){
for (InspectionItemDimension dimen : entry.getValue()) {
required += dimen.getRequired();
actual += dimen.getActual();
difference += dimen.getDifference();
if( unit == null ){
if (unit == null) {
unit = dimen.getUnit();
}
}
@ -676,25 +684,25 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
);
}
private void initializeViews( View view ){
backBtn = view.findViewById( R.id.button_left_frag_3 );
nextBtn = view.findViewById( R.id.button_right_frag_3 );
private void initializeViews(View view) {
backBtn = view.findViewById(R.id.button_left_frag_3);
nextBtn = view.findViewById(R.id.button_right_frag_3);
btnDraft = view.findViewById(R.id.button_draft_third);
imagePicker = view.findViewById(R.id.image_picker);
deleteImage = view.findViewById(R.id.delete_image);
imageRecyclerView = view.findViewById(R.id.imageRecyclerView);
openDimensionDialog = view.findViewById( R.id.button_open_dimension );
profileImage = view.findViewById( R.id.third_step_profile_image );
profileName = view.findViewById( R.id.third_profile_name );
vocRecyclerView = view.findViewById( R.id.voc_recyclerview );
resultSpinner = view.findViewById( R.id.result_spinner );
openDimensionDialog = view.findViewById(R.id.button_open_dimension);
profileImage = view.findViewById(R.id.third_step_profile_image);
profileName = view.findViewById(R.id.third_profile_name);
vocRecyclerView = view.findViewById(R.id.voc_recyclerview);
resultSpinner = view.findViewById(R.id.result_spinner);
sectionSpinner = view.findViewById(R.id.section_spinner);
//resultStatus = view.findViewById( R.id.result_status);
generalRemarks = view.findViewById( R.id.general_remarks );
itemDimensionsRecyclerView = view.findViewById( R.id.item_dimensions_recyclerview );
minorCountTv = view.findViewById( R.id.minor_count );
majorCountTv = view.findViewById( R.id.major_count );
criticalCountTv = view.findViewById( R.id.critical_count );
generalRemarks = view.findViewById(R.id.general_remarks);
itemDimensionsRecyclerView = view.findViewById(R.id.item_dimensions_recyclerview);
minorCountTv = view.findViewById(R.id.minor_count);
majorCountTv = view.findViewById(R.id.major_count);
criticalCountTv = view.findViewById(R.id.critical_count);
etQualityAuditor = view.findViewById(R.id.et_quality_auditor);
etProdRepresentative = view.findViewById(R.id.et_prod_represent);
etQcRepresentative = view.findViewById(R.id.et_qc_represent);
@ -702,20 +710,28 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
txtMinor = view.findViewById(R.id.txt_minor);
etFloor = view.findViewById(R.id.et_floor);
}
private void setOnClickListeners(){
nextBtn.setOnClickListener( this );
backBtn.setOnClickListener( this );
btnDraft.setOnClickListener( this);
openDimensionDialog.setOnClickListener( this);
sectionArrayList.add("Comforter & Mattress Pad");
sectionArrayList.add("Bedding");
sectionArrayList.add("Blanket & Table Linen");
sectionArrayList.add("Pillow");
sectionArrayList.add("Terry Towel");
sectionArrayList.add("Garments & Mattress Protector");
}
private void updateProfileViews( ) throws NullPointerException{
private void setOnClickListeners() {
nextBtn.setOnClickListener(this);
backBtn.setOnClickListener(this);
btnDraft.setOnClickListener(this);
openDimensionDialog.setOnClickListener(this);
}
private void updateProfileViews() throws NullPointerException {
SharedPreferences sharedPreferences = getActivity().getSharedPreferences("login_prefs", Context.MODE_PRIVATE);
profileName.setText( sharedPreferences.getString("name", null ) );
Glide.with( getContext() )
.load( store.getProfileImage( ) )
.into( profileImage );
profileName.setText(sharedPreferences.getString("name", null));
Glide.with(getContext())
.load(store.getProfileImage())
.into(profileImage);
}
// PERMISSIONS

View File

@ -515,6 +515,85 @@
android:visibility="gone"
android:layout_margin="5dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:layout_marginTop="6dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp"
android:background="@drawable/box_border"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="11dp"
android:padding="5dp"
android:orientation="horizontal">
<TextView
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text="Hand Feel Not OK"
android:textColor="@color/black"
android:textStyle="bold" />
<TextView
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text="Hand Feel OK"
android:textColor="@color/black"
android:textStyle="bold" />
<TextView
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text="Hand Feel Not OK %"
android:textColor="@color/black"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:orientation="horizontal"
android:paddingBottom="5dp">
<EditText
android:id="@+id/et_hand_feel_not_ok"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:hint="Hand Feel Not OK"
android:imeOptions="actionDone"
android:inputType="numberDecimal" />
<EditText
android:id="@+id/et_hand_feel_ok"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:hint="Hand Feel OK"
android:enabled="false"
android:imeOptions="actionNext"
android:inputType="numberDecimal" />
<EditText
android:id="@+id/et_not_ok_percent"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:hint="Not OK %"
android:enabled="false"
android:imeOptions="actionNext"
android:inputType="numberDecimal" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"