- qa feedback implemented
parent
c199cc5421
commit
52b4e006c2
|
@ -3,13 +3,12 @@ package com.utopiaindustries.qualitychecker.apiservice;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
|
|
||||||
import okhttp3.OkHttpClient;
|
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
import retrofit2.converter.gson.GsonConverterFactory;
|
import retrofit2.converter.gson.GsonConverterFactory;
|
||||||
|
|
||||||
public class RetrofitClient {
|
public class RetrofitClient {
|
||||||
private final static String BASE_URL = "https://portal.utopiaindustries.pk/uind/";
|
// private final static String BASE_URL = "https://portal.utopiaindustries.pk/uind/";
|
||||||
// private final static String BASE_URL = "http://192.168.91.16:8080/uind/";
|
private final static String BASE_URL = "http://192.168.91.16:8080/uind/";
|
||||||
|
|
||||||
private static Retrofit retrofit;
|
private static Retrofit retrofit;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.utopiaindustries.qualitychecker.models;
|
package com.utopiaindustries.qualitychecker.models;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class InspectionItemCheckPoint {
|
public class InspectionItemCheckPoint {
|
||||||
|
@ -11,13 +12,12 @@ public class InspectionItemCheckPoint {
|
||||||
private boolean checked;
|
private boolean checked;
|
||||||
private String remarks;
|
private String remarks;
|
||||||
// wrapper
|
// wrapper
|
||||||
private String defectSeverity;
|
private List<String> defectSeverites;
|
||||||
private InspectionItemDefect defect;
|
private List<String> defectTitles;
|
||||||
|
private List<Float> quantities;
|
||||||
|
private List<InspectionItemDefect> defects;
|
||||||
private byte[] file;
|
private byte[] file;
|
||||||
private String imagePath;
|
private String imagePath;
|
||||||
|
|
||||||
private String defectTitle;
|
|
||||||
|
|
||||||
private UUID uuid;
|
private UUID uuid;
|
||||||
|
|
||||||
public InspectionItemCheckPoint(){
|
public InspectionItemCheckPoint(){
|
||||||
|
@ -72,24 +72,14 @@ public class InspectionItemCheckPoint {
|
||||||
this.file = file;
|
this.file = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDefectSeverity() {
|
|
||||||
return defectSeverity;
|
|
||||||
|
public List<InspectionItemDefect> getDefects(){
|
||||||
|
return defects;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefectSeverity(String defectSeverity) {
|
public void setDefects(List<InspectionItemDefect> defects) {
|
||||||
this.defectSeverity = defectSeverity;
|
this.defects = defects;
|
||||||
}
|
|
||||||
|
|
||||||
public void setDefect(InspectionItemDefect defect) {
|
|
||||||
this.defect = defect;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDefectTitle() {
|
|
||||||
return defectTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDefectTitle(String defectTitle) {
|
|
||||||
this.defectTitle = defectTitle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getImagePath() {
|
public String getImagePath() {
|
||||||
|
@ -104,6 +94,30 @@ public class InspectionItemCheckPoint {
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getDefectSeverites() {
|
||||||
|
return defectSeverites;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefectSeverites(List<String> defectSeverites) {
|
||||||
|
this.defectSeverites = defectSeverites;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getDefectTitles() {
|
||||||
|
return defectTitles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefectTitles(List<String> defectTitles) {
|
||||||
|
this.defectTitles = defectTitles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Float> getQuantities() {
|
||||||
|
return quantities;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQuantities(List<Float> quantities) {
|
||||||
|
this.quantities = quantities;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "InspectionItemCheckPoint{" +
|
return "InspectionItemCheckPoint{" +
|
||||||
|
@ -112,11 +126,9 @@ public class InspectionItemCheckPoint {
|
||||||
", title='" + title + '\'' +
|
", title='" + title + '\'' +
|
||||||
", checked=" + checked +
|
", checked=" + checked +
|
||||||
", remarks='" + remarks + '\'' +
|
", remarks='" + remarks + '\'' +
|
||||||
", defectSeverity='" + defectSeverity + '\'' +
|
", defects=" + defects +
|
||||||
", defect=" + defect +
|
|
||||||
", file=" + Arrays.toString(file) +
|
", file=" + Arrays.toString(file) +
|
||||||
", imagePath='" + imagePath + '\'' +
|
", imagePath='" + imagePath + '\'' +
|
||||||
", defectTitle='" + defectTitle + '\'' +
|
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ public class InspectionItemDefect {
|
||||||
private long cpId;
|
private long cpId;
|
||||||
private String title;
|
private String title;
|
||||||
private String defectSeverity;
|
private String defectSeverity;
|
||||||
|
private float quantity;
|
||||||
// wrapper
|
// wrapper
|
||||||
private byte[] file;
|
private byte[] file;
|
||||||
|
|
||||||
|
@ -43,6 +44,14 @@ public class InspectionItemDefect {
|
||||||
this.defectSeverity = defectSeverity;
|
this.defectSeverity = defectSeverity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float getQuantity() {
|
||||||
|
return quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQuantity(float quantity) {
|
||||||
|
this.quantity = quantity;
|
||||||
|
}
|
||||||
|
|
||||||
public byte[] getFile() {
|
public byte[] getFile() {
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ public class VoiceOfCustomer {
|
||||||
private String pcxHealth;
|
private String pcxHealth;
|
||||||
private String imageUrl;
|
private String imageUrl;
|
||||||
private String asin;
|
private String asin;
|
||||||
|
private String mostCommonReturnReasonBucket;
|
||||||
|
|
||||||
public String getFnsku() {
|
public String getFnsku() {
|
||||||
return fnsku;
|
return fnsku;
|
||||||
|
@ -66,6 +67,13 @@ public class VoiceOfCustomer {
|
||||||
this.itemName = itemName;
|
this.itemName = itemName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getMostCommonReturnReasonBucket() {
|
||||||
|
return mostCommonReturnReasonBucket;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMostCommonReturnReasonBucket(String mostCommonReturnReasonBucket) {
|
||||||
|
this.mostCommonReturnReasonBucket = mostCommonReturnReasonBucket;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -75,6 +83,9 @@ public class VoiceOfCustomer {
|
||||||
", itemName='" + itemName + '\'' +
|
", itemName='" + itemName + '\'' +
|
||||||
", fnsku='" + fnsku + '\'' +
|
", fnsku='" + fnsku + '\'' +
|
||||||
", pcxHealth='" + pcxHealth + '\'' +
|
", pcxHealth='" + pcxHealth + '\'' +
|
||||||
|
", imageUrl='" + imageUrl + '\'' +
|
||||||
|
", asin='" + asin + '\'' +
|
||||||
|
", mostCommonReturnReasonBucket='" + mostCommonReturnReasonBucket + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,12 +4,14 @@ import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.utopiaindustries.qualitychecker.apiservice.ApiService;
|
import com.utopiaindustries.qualitychecker.apiservice.ApiService;
|
||||||
import com.utopiaindustries.qualitychecker.apiservice.ApiServiceFactory;
|
import com.utopiaindustries.qualitychecker.apiservice.ApiServiceFactory;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.InspectionDefect;
|
||||||
import com.utopiaindustries.qualitychecker.models.InspectionItemCheckPoint;
|
import com.utopiaindustries.qualitychecker.models.InspectionItemCheckPoint;
|
||||||
import com.utopiaindustries.qualitychecker.models.InspectionItemDefect;
|
import com.utopiaindustries.qualitychecker.models.InspectionItemDefect;
|
||||||
import com.utopiaindustries.qualitychecker.models.InspectionReport;
|
import com.utopiaindustries.qualitychecker.models.InspectionReport;
|
||||||
import com.utopiaindustries.qualitychecker.models.SaveReportCallback;
|
import com.utopiaindustries.qualitychecker.models.SaveReportCallback;
|
||||||
import com.utopiaindustries.qualitychecker.store.Store;
|
import com.utopiaindustries.qualitychecker.store.Store;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -90,10 +92,8 @@ public class InspectionReportService {
|
||||||
! inspectionReport.getItems().get(0).getCheckPoints().isEmpty() ){
|
! inspectionReport.getItems().get(0).getCheckPoints().isEmpty() ){
|
||||||
// populate defects in cp
|
// populate defects in cp
|
||||||
for( InspectionItemCheckPoint itemCp : inspectionReport.getItems().get(0).getCheckPoints() ){
|
for( InspectionItemCheckPoint itemCp : inspectionReport.getItems().get(0).getCheckPoints() ){
|
||||||
InspectionItemDefect defect = new InspectionItemDefect();
|
List<InspectionItemDefect> defectList = getInspectionItemDefects(itemCp);
|
||||||
defect.setDefectSeverity(itemCp.getDefectSeverity());
|
itemCp.setDefects( defectList );
|
||||||
defect.setTitle( itemCp.getDefectTitle() );
|
|
||||||
itemCp.setDefect( defect );
|
|
||||||
}
|
}
|
||||||
// post object
|
// post object
|
||||||
apiService.saveInspectionReport( inspectionReport ).enqueue(
|
apiService.saveInspectionReport( inspectionReport ).enqueue(
|
||||||
|
@ -124,4 +124,17 @@ public class InspectionReportService {
|
||||||
callback.onFailure( new Exception("Please Fill the required Fields..") );
|
callback.onFailure( new Exception("Please Fill the required Fields..") );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
private static List<InspectionItemDefect> getInspectionItemDefects(InspectionItemCheckPoint itemCp) {
|
||||||
|
List<InspectionItemDefect> defectList = new ArrayList<>();
|
||||||
|
for (int i = 0; i < itemCp.getDefectTitles().size() ; i++ ){
|
||||||
|
InspectionItemDefect defect = new InspectionItemDefect();
|
||||||
|
defect.setDefectSeverity(itemCp.getDefectSeverites().get( i ) );
|
||||||
|
defect.setTitle( itemCp.getDefectTitles().get( i ) );
|
||||||
|
defect.setQuantity( itemCp.getQuantities().get( i ) );
|
||||||
|
defectList.add( defect );
|
||||||
|
}
|
||||||
|
return defectList;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -102,9 +102,11 @@ public class Store {
|
||||||
for( InspectionCheckPoint cp : response.body() ){
|
for( InspectionCheckPoint cp : response.body() ){
|
||||||
InspectionItemCheckPoint icp = new InspectionItemCheckPoint();
|
InspectionItemCheckPoint icp = new InspectionItemCheckPoint();
|
||||||
icp.setTitle( cp.getTitle() );
|
icp.setTitle( cp.getTitle() );
|
||||||
icp.setDefectSeverity("MINOR");
|
|
||||||
icp.setChecked( false );
|
icp.setChecked( false );
|
||||||
icp.setRemarks("");
|
icp.setRemarks("");
|
||||||
|
icp.setDefectTitles( new ArrayList<>() );
|
||||||
|
icp.setDefectSeverites( new ArrayList<>() );
|
||||||
|
icp.setQuantities( new ArrayList<>() );
|
||||||
itemCp.add( icp );
|
itemCp.add( icp );
|
||||||
}
|
}
|
||||||
report.getItems().get( 0 ).setCheckPoints( itemCp );
|
report.getItems().get( 0 ).setCheckPoints( itemCp );
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class HomeActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
private Button createReportBtn,refreshReportsBtn,logoutBtn;
|
private Button createReportBtn,refreshReportsBtn,logoutBtn;
|
||||||
private RecyclerView recyclerView;
|
private RecyclerView recyclerView;
|
||||||
private ApiService apiService;
|
private ApiService apiService;
|
||||||
private TextView usernameTitle;
|
private TextView usernameTitle, emptyReportTextView;
|
||||||
private ImageView profileImage;
|
private ImageView profileImage;
|
||||||
private Store store;
|
private Store store;
|
||||||
|
|
||||||
|
@ -71,6 +71,7 @@ public class HomeActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
recyclerView = findViewById( R.id.reports_recyclerview );
|
recyclerView = findViewById( R.id.reports_recyclerview );
|
||||||
usernameTitle = findViewById( R.id.username_title );
|
usernameTitle = findViewById( R.id.username_title );
|
||||||
profileImage = findViewById( R.id.profile_image );
|
profileImage = findViewById( R.id.profile_image );
|
||||||
|
emptyReportTextView = findViewById( R.id.empty_report_text );
|
||||||
|
|
||||||
refreshReportsBtn.setOnClickListener( this );
|
refreshReportsBtn.setOnClickListener( this );
|
||||||
createReportBtn.setOnClickListener( this );
|
createReportBtn.setOnClickListener( this );
|
||||||
|
@ -93,13 +94,17 @@ public class HomeActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
System.out.println( response.body() );
|
System.out.println( response.body() );
|
||||||
ReportAdapter adapter = new ReportAdapter( response.body() );
|
ReportAdapter adapter = new ReportAdapter( response.body() );
|
||||||
recyclerView.setAdapter( adapter );
|
recyclerView.setAdapter( adapter );
|
||||||
|
if( response.body().isEmpty() )
|
||||||
|
emptyReportTextView.setVisibility( View.VISIBLE ) ;
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Error");
|
System.out.println("Error");
|
||||||
|
emptyReportTextView.setVisibility( View.VISIBLE ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Call<List<InspectionReport>> call, Throwable t) {
|
public void onFailure(Call<List<InspectionReport>> call, Throwable t) {
|
||||||
System.out.println( t.getMessage() );
|
System.out.println( t.getMessage() );
|
||||||
|
emptyReportTextView.setVisibility( View.VISIBLE ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -21,6 +21,7 @@ import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.utopiaindustries.qualitychecker.R;
|
import com.utopiaindustries.qualitychecker.R;
|
||||||
|
@ -29,7 +30,6 @@ import com.utopiaindustries.qualitychecker.models.InspectionDefect;
|
||||||
import com.utopiaindustries.qualitychecker.models.InspectionItemCheckPoint;
|
import com.utopiaindustries.qualitychecker.models.InspectionItemCheckPoint;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class CheckPointAdapter extends
|
public class CheckPointAdapter extends
|
||||||
|
@ -69,7 +69,7 @@ public class CheckPointAdapter extends
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||||
InspectionItemCheckPoint checkPoint = checkPointList.get( position );
|
InspectionItemCheckPoint checkPoint = checkPointList.get( position );
|
||||||
holder.bind(checkPoints, defects, defectTypes, checkPoint);
|
holder.bind(checkPoints, defects, defectTypes, checkPoint, context );
|
||||||
holder.setIsRecyclable(false);
|
holder.setIsRecyclable(false);
|
||||||
// spinner on change
|
// spinner on change
|
||||||
{
|
{
|
||||||
|
@ -87,28 +87,6 @@ public class CheckPointAdapter extends
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
holder.defectsSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
|
||||||
@Override
|
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
|
||||||
String selectedItem = parent.getItemAtPosition(position).toString();
|
|
||||||
checkPoint.setDefectTitle(selectedItem);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onNothingSelected(AdapterView<?> parent) {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
holder.defectTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
|
||||||
@Override
|
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
|
||||||
String selectedItem = parent.getItemAtPosition(position).toString();
|
|
||||||
checkPoint.setDefectSeverity(selectedItem);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onNothingSelected(AdapterView<?> parent) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
// checkboxes on change
|
// checkboxes on change
|
||||||
{
|
{
|
||||||
|
@ -146,6 +124,13 @@ public class CheckPointAdapter extends
|
||||||
holder.imagePreview.setImageDrawable( null );
|
holder.imagePreview.setImageDrawable( null );
|
||||||
notifyItemChanged( position );
|
notifyItemChanged( position );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
holder.addDefect.setOnClickListener( v -> {
|
||||||
|
checkPoint.getDefectTitles().add("");
|
||||||
|
checkPoint.getDefectSeverites().add("MINOR");
|
||||||
|
checkPoint.getQuantities().add(0f);
|
||||||
|
notifyItemChanged( position );
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -155,15 +140,17 @@ public class CheckPointAdapter extends
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
private final Spinner checkpointSpinner, defectsSpinner, defectTypeSpinner;
|
private final Spinner checkpointSpinner;
|
||||||
|
// private final Spinner defectsSpinner, defectTypeSpinner;
|
||||||
private final CheckBox okCheckBox, noCheckBox;
|
private final CheckBox okCheckBox, noCheckBox;
|
||||||
private final EditText remarks;
|
private final EditText remarks;
|
||||||
private final ImageButton imagePicker,deleteImage;
|
private final ImageButton imagePicker,deleteImage,addDefect;
|
||||||
private final LinearLayout linearLayout;
|
private final LinearLayout linearLayout;
|
||||||
private final TextView selectedImage;
|
private final TextView selectedImage;
|
||||||
private final ImageView imagePreview;
|
private final ImageView imagePreview;
|
||||||
|
private final RecyclerView defectRecyclerView;
|
||||||
|
|
||||||
public ViewHolder( @NonNull View itemView) {
|
public ViewHolder(@NonNull View itemView ) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
remarks = itemView.findViewById(R.id.check_point_remarks);
|
remarks = itemView.findViewById(R.id.check_point_remarks);
|
||||||
checkpointSpinner = itemView.findViewById(R.id.check_point_spinner);
|
checkpointSpinner = itemView.findViewById(R.id.check_point_spinner);
|
||||||
|
@ -171,16 +158,24 @@ public class CheckPointAdapter extends
|
||||||
noCheckBox = itemView.findViewById(R.id.check_point_no);
|
noCheckBox = itemView.findViewById(R.id.check_point_no);
|
||||||
imagePicker = itemView.findViewById(R.id.image_picker );
|
imagePicker = itemView.findViewById(R.id.image_picker );
|
||||||
selectedImage = itemView.findViewById( R.id.selected_image );
|
selectedImage = itemView.findViewById( R.id.selected_image );
|
||||||
defectsSpinner = itemView.findViewById(R.id.defect_spinner);
|
// defectsSpinner = itemView.findViewById(R.id.defect_spinner);
|
||||||
defectTypeSpinner = itemView.findViewById(R.id.defect_type_spinner);
|
// defectTypeSpinner = itemView.findViewById(R.id.defect_type_spinner);
|
||||||
linearLayout = itemView.findViewById(R.id.defect_layout);
|
linearLayout = itemView.findViewById(R.id.defect_layout);
|
||||||
deleteImage = itemView.findViewById( R.id.delete_image );
|
deleteImage = itemView.findViewById( R.id.delete_image );
|
||||||
imagePreview = itemView.findViewById( R.id.preview_image );
|
imagePreview = itemView.findViewById( R.id.preview_image );
|
||||||
|
defectRecyclerView = itemView.findViewById( R.id.defects_recyclerview );
|
||||||
|
addDefect = itemView.findViewById( R.id.add_defect );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void bind(List<InspectionCheckPoint> checkPoints,
|
public void bind(List<InspectionCheckPoint> checkPoints,
|
||||||
List<InspectionDefect> defects,
|
List<InspectionDefect> defects,
|
||||||
List<String> defectTypeOptions,
|
List<String> defectTypeOptions,
|
||||||
InspectionItemCheckPoint data ) {
|
InspectionItemCheckPoint data,
|
||||||
|
Context context ) {
|
||||||
|
// initialize recyclerview
|
||||||
|
|
||||||
|
|
||||||
List<String> checkPointsList = checkPoints.stream().map(InspectionCheckPoint::getTitle).collect(Collectors.toList());
|
List<String> checkPointsList = checkPoints.stream().map(InspectionCheckPoint::getTitle).collect(Collectors.toList());
|
||||||
|
|
||||||
// Populate checklist Spinner dropdown
|
// Populate checklist Spinner dropdown
|
||||||
|
@ -189,21 +184,12 @@ public class CheckPointAdapter extends
|
||||||
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
checkpointSpinner.setAdapter(spinnerAdapter);
|
checkpointSpinner.setAdapter(spinnerAdapter);
|
||||||
|
|
||||||
// Populate defect type Spinner dropdown
|
|
||||||
ArrayAdapter<String> defectTypeSpinnerAdapter = new ArrayAdapter<>(defectTypeSpinner.getContext(),
|
|
||||||
android.R.layout.simple_spinner_item, defectTypeOptions);
|
|
||||||
defectTypeSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
|
||||||
defectTypeSpinner.setAdapter(defectTypeSpinnerAdapter);
|
|
||||||
|
|
||||||
// Pre populate
|
// Pre populate
|
||||||
String defaultSelectedItem = data.getTitle();
|
String defaultSelectedItem = data.getTitle();
|
||||||
int defaultPosition = checkPointsList.indexOf(defaultSelectedItem);
|
int defaultPosition = checkPointsList.indexOf(defaultSelectedItem);
|
||||||
checkpointSpinner.setSelection(defaultPosition);
|
checkpointSpinner.setSelection(defaultPosition);
|
||||||
|
|
||||||
String defaultSelectedDefectType = data.getDefectSeverity();
|
|
||||||
int defaultSelectedDefectTypePosition = defectTypeOptions.indexOf(defaultSelectedDefectType);
|
|
||||||
defectTypeSpinner.setSelection(defaultSelectedDefectTypePosition);
|
|
||||||
|
|
||||||
remarks.setText( data.getRemarks() );
|
remarks.setText( data.getRemarks() );
|
||||||
okCheckBox.setChecked( data.getChecked() );
|
okCheckBox.setChecked( data.getChecked() );
|
||||||
noCheckBox.setChecked( ! data.getChecked());
|
noCheckBox.setChecked( ! data.getChecked());
|
||||||
|
@ -219,6 +205,13 @@ public class CheckPointAdapter extends
|
||||||
Bitmap bitmap = BitmapFactory.decodeByteArray( data.getFile(), 0 , data.getFile().length );
|
Bitmap bitmap = BitmapFactory.decodeByteArray( data.getFile(), 0 , data.getFile().length );
|
||||||
imagePreview.setImageBitmap( bitmap );
|
imagePreview.setImageBitmap( bitmap );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InspectionCheckPoint cp = checkPoints.stream().filter(c ->c.getTitle().equalsIgnoreCase(defaultSelectedItem)).findFirst().get();
|
||||||
|
|
||||||
|
defectRecyclerView.setLayoutManager( new LinearLayoutManager( context ) );
|
||||||
|
DefectsAdapter defectsAdapter = new DefectsAdapter(data, defectTypeOptions, defects, cp);
|
||||||
|
defectRecyclerView.setAdapter( defectsAdapter );
|
||||||
|
|
||||||
}
|
}
|
||||||
private void populateDefects(InspectionCheckPoint cp, List<InspectionDefect> defects, InspectionItemCheckPoint data) {
|
private void populateDefects(InspectionCheckPoint cp, List<InspectionDefect> defects, InspectionItemCheckPoint data) {
|
||||||
|
|
||||||
|
@ -226,15 +219,16 @@ public class CheckPointAdapter extends
|
||||||
.filter(d -> d.getCategory().equalsIgnoreCase(cp.getCategory()))
|
.filter(d -> d.getCategory().equalsIgnoreCase(cp.getCategory()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
List<String> defectList = filteredDefects.stream().map(InspectionDefect::getDefect).collect(Collectors.toList());
|
List<String> defectList = filteredDefects.stream().map(InspectionDefect::getDefect).collect(Collectors.toList());
|
||||||
// Populate defect Spinner dropdown
|
|
||||||
ArrayAdapter<String> defectSpinnerAdapter = new ArrayAdapter<>(defectsSpinner.getContext(),
|
|
||||||
android.R.layout.simple_spinner_item, defectList);
|
|
||||||
defectSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
|
||||||
defectsSpinner.setAdapter(defectSpinnerAdapter);
|
|
||||||
|
|
||||||
String defaultDefectSelectedItem = data.getDefectTitle();
|
// Populate defect Spinner dropdown
|
||||||
int defaultSelectedDefectPosition = defectList.indexOf(defaultDefectSelectedItem);
|
// ArrayAdapter<String> defectSpinnerAdapter = new ArrayAdapter<>(defectsSpinner.getContext(),
|
||||||
defectsSpinner.setSelection(defaultSelectedDefectPosition);
|
// android.R.layout.simple_spinner_item, defectList);
|
||||||
|
// defectSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
|
// defectsSpinner.setAdapter(defectSpinnerAdapter);
|
||||||
|
//
|
||||||
|
// String defaultDefectSelectedItem = data.getDefectTitle();
|
||||||
|
// int defaultSelectedDefectPosition = defectList.indexOf(defaultDefectSelectedItem);
|
||||||
|
// defectsSpinner.setSelection(defaultSelectedDefectPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setupRemarksListener(InspectionItemCheckPoint checkPoint) {
|
public void setupRemarksListener(InspectionItemCheckPoint checkPoint) {
|
||||||
|
|
|
@ -0,0 +1,182 @@
|
||||||
|
package com.utopiaindustries.qualitychecker.ui.adapter;
|
||||||
|
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.text.TextWatcher;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.ImageButton;
|
||||||
|
import android.widget.Spinner;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.utopiaindustries.qualitychecker.R;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.InspectionCheckPoint;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.InspectionDefect;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.InspectionItemCheckPoint;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class DefectsAdapter extends RecyclerView.Adapter<DefectsAdapter.DefectViewHolder> {
|
||||||
|
|
||||||
|
private InspectionItemCheckPoint checkPoint;
|
||||||
|
private List<String> defectTypes;
|
||||||
|
private List<InspectionDefect> defects;
|
||||||
|
|
||||||
|
private InspectionCheckPoint cp ;
|
||||||
|
|
||||||
|
public DefectsAdapter(InspectionItemCheckPoint checkPoint,
|
||||||
|
List<String> defectTypes,
|
||||||
|
List<InspectionDefect> defects, InspectionCheckPoint cp) {
|
||||||
|
this.checkPoint = checkPoint;
|
||||||
|
this.defectTypes = defectTypes;
|
||||||
|
this.defects = defects;
|
||||||
|
this.cp = cp;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public DefectViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
View view = LayoutInflater.from( parent.getContext() )
|
||||||
|
.inflate(R.layout.defect_item, parent, false);
|
||||||
|
return new DefectViewHolder(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void populateDefectSeveritySpinner( DefectViewHolder holder ){
|
||||||
|
String defectType = checkPoint.getDefectSeverites().get( holder.getAdapterPosition() );
|
||||||
|
ArrayAdapter<String> defectTypeSpinnerAdapter = new ArrayAdapter<>( holder.defectTypeSpinner.getContext(),
|
||||||
|
android.R.layout.simple_spinner_item, defectTypes );
|
||||||
|
defectTypeSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
|
holder.defectTypeSpinner.setAdapter(defectTypeSpinnerAdapter);
|
||||||
|
|
||||||
|
String defaultSelectedDefectType = defectType;
|
||||||
|
int defaultSelectedDefectTypePosition = defectTypes.indexOf(defaultSelectedDefectType);
|
||||||
|
holder.defectTypeSpinner.setSelection(defaultSelectedDefectTypePosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void populateDefectOptionsSpinner( DefectViewHolder holder ){
|
||||||
|
String defect = checkPoint.getDefectTitles().get( holder.getAdapterPosition() );
|
||||||
|
|
||||||
|
List<InspectionDefect> filteredDefects = defects.stream()
|
||||||
|
.filter(d -> d.getCategory().equalsIgnoreCase(cp.getCategory()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
List<String> defectList = filteredDefects.stream().map(InspectionDefect::getDefect).collect(Collectors.toList());
|
||||||
|
|
||||||
|
ArrayAdapter<String> defectSpinnerAdapter = new ArrayAdapter<>( holder.defectSpinner.getContext(),
|
||||||
|
android.R.layout.simple_spinner_item, defectList );
|
||||||
|
defectSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
|
holder.defectSpinner.setAdapter(defectSpinnerAdapter);
|
||||||
|
|
||||||
|
String defaultSelectedDefect = defect;
|
||||||
|
int defaultSelectedDefectPosition = defectList.indexOf(defaultSelectedDefect);
|
||||||
|
holder.defectSpinner.setSelection(defaultSelectedDefectPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void populateQuantity( DefectViewHolder holder ){
|
||||||
|
|
||||||
|
Float quantity = checkPoint.getQuantities().get( holder.getAdapterPosition() );
|
||||||
|
if( quantity != null ){
|
||||||
|
holder.quantity.setText( String.valueOf( quantity ) );
|
||||||
|
} else {
|
||||||
|
holder.quantity.setText( String.valueOf( 0f ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull DefectViewHolder holder, int position) {
|
||||||
|
|
||||||
|
populateDefectSeveritySpinner( holder );
|
||||||
|
populateDefectOptionsSpinner( holder );
|
||||||
|
populateQuantity( holder );
|
||||||
|
// Populate defect type Spinner dropdown
|
||||||
|
|
||||||
|
{
|
||||||
|
holder.defectTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
|
String selectedItem = parent.getItemAtPosition(position).toString();
|
||||||
|
checkPoint.getDefectSeverites().set( holder.getAdapterPosition(), selectedItem) ;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onNothingSelected(AdapterView<?> parent) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
holder.defectSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
|
String selectedItem = parent.getItemAtPosition(position).toString();
|
||||||
|
checkPoint.getDefectTitles().set( holder.getAdapterPosition(), selectedItem) ;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onNothingSelected(AdapterView<?> parent) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
holder.quantity.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) {
|
||||||
|
if( s == null || s.toString().isEmpty() ){
|
||||||
|
checkPoint.getQuantities().set( position , 0F );
|
||||||
|
|
||||||
|
} else {
|
||||||
|
checkPoint.getQuantities().set( position , Float.parseFloat( s.toString() ));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable s) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
holder.deleteBtn.setOnClickListener(v-> {
|
||||||
|
System.out.println( holder.getAdapterPosition() );
|
||||||
|
removeItem( holder.getAdapterPosition() );
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void removeItem(int position) {
|
||||||
|
if( position >= 0 && position < checkPoint.getDefectSeverites().size() ){
|
||||||
|
checkPoint.getDefectSeverites().remove( position ) ;
|
||||||
|
checkPoint.getDefectTitles().remove( position ) ;
|
||||||
|
checkPoint.getQuantities().remove( position );
|
||||||
|
notifyItemRemoved( position );
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return Math.max( checkPoint.getDefectTitles().size(), checkPoint.getDefectTitles().size() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class DefectViewHolder extends RecyclerView.ViewHolder{
|
||||||
|
|
||||||
|
private Spinner defectSpinner, defectTypeSpinner;
|
||||||
|
private ImageButton deleteBtn;
|
||||||
|
private EditText quantity;
|
||||||
|
|
||||||
|
public DefectViewHolder(@NonNull View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
defectSpinner = itemView.findViewById( R.id.defect_spinner );
|
||||||
|
defectTypeSpinner = itemView.findViewById( R.id.defect_type_spinner );
|
||||||
|
deleteBtn = itemView.findViewById( R.id.delete_defect );
|
||||||
|
quantity = itemView.findViewById( R.id.defect_quantity );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -68,7 +68,7 @@ public class VocAdapter extends
|
||||||
asin.setText( voc.getAsin() );
|
asin.setText( voc.getAsin() );
|
||||||
fnsku.setText( voc.getFnsku() );
|
fnsku.setText( voc.getFnsku() );
|
||||||
health.setText( voc.getPcxHealth() );
|
health.setText( voc.getPcxHealth() );
|
||||||
item .setText( voc.getItemName() );
|
item .setText( voc.getMostCommonReturnReasonBucket() );
|
||||||
markeplace.setText( voc.getMarketplace() );
|
markeplace.setText( voc.getMarketplace() );
|
||||||
Glide.with( context )
|
Glide.with( context )
|
||||||
.load( voc.getImageUrl() )
|
.load( voc.getImageUrl() )
|
||||||
|
|
|
@ -6,8 +6,11 @@ import android.Manifest;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Base64;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -93,7 +96,7 @@ public class SecondStepFragment extends Fragment
|
||||||
if (ContextCompat.checkSelfPermission( getContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
if (ContextCompat.checkSelfPermission( getContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||||
!= PackageManager.PERMISSION_GRANTED) {
|
!= PackageManager.PERMISSION_GRANTED) {
|
||||||
|
|
||||||
ActivityCompat.requestPermissions(getActivity(),
|
ActivityCompat.requestPermissions( getActivity(),
|
||||||
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
|
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
|
||||||
MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
|
MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
|
||||||
}
|
}
|
||||||
|
@ -134,7 +137,9 @@ public class SecondStepFragment extends Fragment
|
||||||
assert selectedImageUri != null;
|
assert selectedImageUri != null;
|
||||||
String imagePath = selectedImageUri.getPath();
|
String imagePath = selectedImageUri.getPath();
|
||||||
store.getReport().getItems().get( 0 ).getCheckPoints().get( requestCode ).setImagePath( imagePath );
|
store.getReport().getItems().get( 0 ).getCheckPoints().get( requestCode ).setImagePath( imagePath );
|
||||||
store.getReport().getItems().get( 0 ).getCheckPoints().get( requestCode ).setFile( getBytesFromUri( getContext(), selectedImageUri ) );
|
store.getReport().getItems().get( 0 ).getCheckPoints().get( requestCode ).setFile(
|
||||||
|
compressImageToMaxSize( getBytesFromUri( getContext(), selectedImageUri ), 200 )
|
||||||
|
);
|
||||||
adapter.notifyItemChanged( requestCode );
|
adapter.notifyItemChanged( requestCode );
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
@ -163,4 +168,28 @@ public class SecondStepFragment extends Fragment
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public byte[] compressImageToMaxSize(byte[] imageData,
|
||||||
|
int maxSizeKB) {
|
||||||
|
int quality = 100; // Start with highest quality
|
||||||
|
byte[] compressedBytes = compressImage(imageData, quality);
|
||||||
|
// Loop to reduce quality until the image is within the max size
|
||||||
|
while (compressedBytes.length > maxSizeKB * 1024 && quality > 0) {
|
||||||
|
quality -= 5;
|
||||||
|
compressedBytes = compressImage(imageData, quality);
|
||||||
|
}
|
||||||
|
|
||||||
|
return compressedBytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
private byte[] compressImage(byte[] imageData,
|
||||||
|
int quality) {
|
||||||
|
if( imageData != null && imageData.length > 0 ) {
|
||||||
|
Bitmap bitmap = BitmapFactory.decodeByteArray(imageData, 0, imageData.length);
|
||||||
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
|
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);
|
||||||
|
return outputStream.toByteArray();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.utopiaindustries.qualitychecker.ui.fragments;
|
package com.utopiaindustries.qualitychecker.ui.fragments;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
|
@ -30,7 +31,10 @@ import com.bumptech.glide.Glide;
|
||||||
import com.utopiaindustries.qualitychecker.R;
|
import com.utopiaindustries.qualitychecker.R;
|
||||||
import com.utopiaindustries.qualitychecker.apiservice.ApiService;
|
import com.utopiaindustries.qualitychecker.apiservice.ApiService;
|
||||||
import com.utopiaindustries.qualitychecker.apiservice.ApiServiceFactory;
|
import com.utopiaindustries.qualitychecker.apiservice.ApiServiceFactory;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.InspectionItemCheckPoint;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.InspectionItemDefect;
|
||||||
import com.utopiaindustries.qualitychecker.models.InspectionItemDimension;
|
import com.utopiaindustries.qualitychecker.models.InspectionItemDimension;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.InspectionReport;
|
||||||
import com.utopiaindustries.qualitychecker.models.SaveReportCallback;
|
import com.utopiaindustries.qualitychecker.models.SaveReportCallback;
|
||||||
import com.utopiaindustries.qualitychecker.models.VoiceOfCustomer;
|
import com.utopiaindustries.qualitychecker.models.VoiceOfCustomer;
|
||||||
import com.utopiaindustries.qualitychecker.service.InspectionReportService;
|
import com.utopiaindustries.qualitychecker.service.InspectionReportService;
|
||||||
|
@ -61,6 +65,8 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
|
||||||
private ApiService apiService;
|
private ApiService apiService;
|
||||||
private EditText generalRemarks;
|
private EditText generalRemarks;
|
||||||
|
|
||||||
|
private TextView minorCountTv,majorCountTv,criticalCountTv;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
|
@ -215,6 +221,7 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("DefaultLocale")
|
||||||
private void populateViews(){
|
private void populateViews(){
|
||||||
|
|
||||||
profileName.setText( store.getEmployeePhoto().getName() );
|
profileName.setText( store.getEmployeePhoto().getName() );
|
||||||
|
@ -245,6 +252,30 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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() ) {
|
||||||
|
int minor = 0;
|
||||||
|
int major = 0;
|
||||||
|
int crirical = 0;
|
||||||
|
for (InspectionItemCheckPoint itemCp : inspectionReport.getItems().get(0).getCheckPoints()) {
|
||||||
|
for( String status : itemCp.getDefectSeverites() ){
|
||||||
|
if( status.equalsIgnoreCase("minor") ) minor++;
|
||||||
|
if( status.equalsIgnoreCase("major") ) major++;
|
||||||
|
if( status.equalsIgnoreCase("critical") ) crirical++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
minorCountTv.setText( String.format("Minor : %d", minor ) );
|
||||||
|
majorCountTv.setText( String.format("Major : %d", major ) ) ;
|
||||||
|
criticalCountTv.setText( String.format("Critical : %d", crirical ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void calculateDimensions(){
|
private void calculateDimensions(){
|
||||||
|
@ -309,6 +340,9 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
|
||||||
resultSpinner = view.findViewById( R.id.result_spinner );
|
resultSpinner = view.findViewById( R.id.result_spinner );
|
||||||
generalRemarks = view.findViewById( R.id.general_remarks );
|
generalRemarks = view.findViewById( R.id.general_remarks );
|
||||||
itemDimensionsRecyclerView = view.findViewById( R.id.item_dimensions_recyclerview );
|
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 );
|
||||||
}
|
}
|
||||||
private void setOnClickListeners(){
|
private void setOnClickListeners(){
|
||||||
nextBtn.setOnClickListener( this );
|
nextBtn.setOnClickListener( this );
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#FFFFFF" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||||
|
|
||||||
<path android:fillColor="@android:color/white" android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
|
<path android:fillColor="@android:color/black" android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
|
||||||
|
|
||||||
</vector>
|
</vector>
|
||||||
|
|
|
@ -92,6 +92,14 @@
|
||||||
android:padding="16dp">
|
android:padding="16dp">
|
||||||
|
|
||||||
</androidx.recyclerview.widget.RecyclerView>
|
</androidx.recyclerview.widget.RecyclerView>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/empty_report_text"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="No Report Found"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:visibility="invisible">
|
||||||
|
</TextView>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:padding="4dp"
|
android:padding="4dp"
|
||||||
|
android:layout_margin="8dp"
|
||||||
android:elevation="10dp"
|
android:elevation="10dp"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
|
app:cardBackgroundColor="@color/cp_bg_color"
|
||||||
android:layout_marginVertical="4dp">
|
android:layout_marginVertical="4dp">
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -65,29 +68,6 @@
|
||||||
</EditText>
|
</EditText>
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:layout_marginTop="3dp"
|
|
||||||
android:id="@+id/defect_layout">
|
|
||||||
|
|
||||||
<Spinner
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="50dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:padding="5dp"
|
|
||||||
android:id="@+id/defect_spinner">
|
|
||||||
</Spinner>
|
|
||||||
|
|
||||||
<Spinner
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="50dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:padding="5dp"
|
|
||||||
android:id="@+id/defect_type_spinner">
|
|
||||||
</Spinner>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -121,6 +101,42 @@
|
||||||
android:src="@drawable/ic_delete"
|
android:src="@drawable/ic_delete"
|
||||||
android:background="@null"
|
android:background="@null"
|
||||||
android:padding="8dp"/>
|
android:padding="8dp"/>
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/add_defect"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:src="@drawable/ic_add"
|
||||||
|
android:background="@null"
|
||||||
|
android:padding="8dp"/>
|
||||||
|
</LinearLayout>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_marginTop="3dp"
|
||||||
|
android:id="@+id/defect_layout">
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/defects_recyclerview">
|
||||||
|
</androidx.recyclerview.widget.RecyclerView>
|
||||||
|
|
||||||
|
<!-- <Spinner-->
|
||||||
|
<!-- android:layout_width="wrap_content"-->
|
||||||
|
<!-- android:layout_height="50dp"-->
|
||||||
|
<!-- android:layout_weight="1"-->
|
||||||
|
<!-- android:padding="5dp"-->
|
||||||
|
<!-- android:id="@+id/defect_spinner">-->
|
||||||
|
<!-- </Spinner>-->
|
||||||
|
|
||||||
|
<!-- <Spinner-->
|
||||||
|
<!-- android:layout_width="wrap_content"-->
|
||||||
|
<!-- android:layout_height="50dp"-->
|
||||||
|
<!-- android:layout_weight="1"-->
|
||||||
|
<!-- android:padding="5dp"-->
|
||||||
|
<!-- android:id="@+id/defect_type_spinner">-->
|
||||||
|
<!-- </Spinner>-->
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</androidx.cardview.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="50dp">
|
||||||
|
<Spinner
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:padding="5dp"
|
||||||
|
android:id="@+id/defect_spinner">
|
||||||
|
</Spinner>
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:padding="5dp"
|
||||||
|
android:id="@+id/defect_type_spinner">
|
||||||
|
</Spinner>
|
||||||
|
<EditText
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:id="@+id/defect_quantity"
|
||||||
|
android:hint="quantity"
|
||||||
|
android:inputType="numberDecimal">
|
||||||
|
</EditText>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/delete_defect"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:src="@drawable/ic_delete"
|
||||||
|
android:background="@null"
|
||||||
|
android:padding="8dp"/>
|
||||||
|
</LinearLayout>
|
|
@ -323,15 +323,44 @@
|
||||||
android:text="Status"
|
android:text="Status"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:layout_marginBottom="5dp"
|
android:layout_marginBottom="5dp" />
|
||||||
/>
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
<Spinner
|
android:padding="10dp"
|
||||||
android:id="@+id/result_spinner"
|
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content">
|
||||||
android:prompt="@string/spinner_title"
|
<Spinner
|
||||||
/>
|
android:id="@+id/result_spinner"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:prompt="@string/spinner_title"
|
||||||
|
/>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/minor_count"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Minor"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:textSize="16sp"/>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/major_count"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Major"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:textSize="16sp"/>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/critical_count"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Citical"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:textSize="16sp"/>
|
||||||
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
|
|
|
@ -9,4 +9,5 @@
|
||||||
<color name="success">#20830E</color>
|
<color name="success">#20830E</color>
|
||||||
<color name="red">#FF0000</color>
|
<color name="red">#FF0000</color>
|
||||||
<color name="light_blue">#29DAF1</color>
|
<color name="light_blue">#29DAF1</color>
|
||||||
|
<color name="cp_bg_color">#FFFFFF</color>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue