- add standards in checkpoint sku wise
parent
a733658789
commit
e7e736c468
|
@ -2,6 +2,7 @@ package com.utopiaindustries.qualitychecker.apiservice;
|
||||||
|
|
||||||
import com.utopiaindustries.qualitychecker.models.EmployeePhoto;
|
import com.utopiaindustries.qualitychecker.models.EmployeePhoto;
|
||||||
import com.utopiaindustries.qualitychecker.models.InspectionCheckPoint;
|
import com.utopiaindustries.qualitychecker.models.InspectionCheckPoint;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.InspectionCheckpointSku;
|
||||||
import com.utopiaindustries.qualitychecker.models.InspectionDefect;
|
import com.utopiaindustries.qualitychecker.models.InspectionDefect;
|
||||||
import com.utopiaindustries.qualitychecker.models.InspectionDimension;
|
import com.utopiaindustries.qualitychecker.models.InspectionDimension;
|
||||||
import com.utopiaindustries.qualitychecker.models.InspectionReport;
|
import com.utopiaindustries.qualitychecker.models.InspectionReport;
|
||||||
|
@ -88,4 +89,7 @@ public interface ApiService {
|
||||||
|
|
||||||
@GET( "rest/uic/cosmos-products/" )
|
@GET( "rest/uic/cosmos-products/" )
|
||||||
Call<List<Product>> fetchAllProducts();
|
Call<List<Product>> fetchAllProducts();
|
||||||
|
|
||||||
|
@GET( "rest/uic/inspection-report/inspection-sku-checkpoints" )
|
||||||
|
Call<List<InspectionCheckpointSku>> fetchSkuCheckpoints( );
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@ 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;
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,14 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
||||||
public static final String REPORT_COLUMN_CONTENT = "content";
|
public static final String REPORT_COLUMN_CONTENT = "content";
|
||||||
public static final String REPORT_COLUMN_SYNCED = "synced";
|
public static final String REPORT_COLUMN_SYNCED = "synced";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* sku checkpoints standard
|
||||||
|
* */
|
||||||
|
public static final String CHECKPOINT_SKU_TABLE_NAME = "checkpoint_sku";
|
||||||
|
public static final String CHECKPOINT_SKU_SKU = "sku";
|
||||||
|
public static final String CHECKPOINT_SKU_CHECKPOINT_ID = "checkpoint_id";
|
||||||
|
public static final String CHECKPOINT_SKU_STANDARD = "standard";
|
||||||
|
|
||||||
public DatabaseHelper(Context context) {
|
public DatabaseHelper(Context context) {
|
||||||
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
||||||
}
|
}
|
||||||
|
@ -117,12 +125,19 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
||||||
REPORT_COLUMN_SYNCED + " INTEGER DEFAULT 0 CHECK(synced IN (0, 1))"
|
REPORT_COLUMN_SYNCED + " INTEGER DEFAULT 0 CHECK(synced IN (0, 1))"
|
||||||
+ ")";
|
+ ")";
|
||||||
|
|
||||||
|
String CREATE_SKU_CHECKPOINT_TABLE = "CREATE TABLE " + CHECKPOINT_SKU_TABLE_NAME + " (" +
|
||||||
|
CHECKPOINT_SKU_SKU + " TEXT NOT NULL," +
|
||||||
|
CHECKPOINT_SKU_CHECKPOINT_ID + " INTEGER NOT NULL," +
|
||||||
|
CHECKPOINT_SKU_STANDARD + " TEXT," +
|
||||||
|
"PRIMARY KEY (" + CHECKPOINT_SKU_SKU + ", " + CHECKPOINT_SKU_CHECKPOINT_ID + "))";
|
||||||
|
|
||||||
db.execSQL( CREATE_PRODUCT_TABLE );
|
db.execSQL( CREATE_PRODUCT_TABLE );
|
||||||
db.execSQL( CREATE_INSPECTION_DIMENSION_TABLE );
|
db.execSQL( CREATE_INSPECTION_DIMENSION_TABLE );
|
||||||
db.execSQL( CREATE_CHECKPOINT_TABLE );
|
db.execSQL( CREATE_CHECKPOINT_TABLE );
|
||||||
db.execSQL( CREATE_DEFECT_TABLE );
|
db.execSQL( CREATE_DEFECT_TABLE );
|
||||||
db.execSQL( CREATE_UNIT_TABLE );
|
db.execSQL( CREATE_UNIT_TABLE );
|
||||||
db.execSQL( CREATE_REPORT_TABLE );
|
db.execSQL( CREATE_REPORT_TABLE );
|
||||||
|
db.execSQL( CREATE_SKU_CHECKPOINT_TABLE );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -133,6 +148,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
||||||
db.execSQL( "DROP TABLE IF EXISTS " + DEFECT_TABLE_NAME );
|
db.execSQL( "DROP TABLE IF EXISTS " + DEFECT_TABLE_NAME );
|
||||||
db.execSQL( "DROP TABLE IF EXISTS " + UNIT_TABLE_NAME );
|
db.execSQL( "DROP TABLE IF EXISTS " + UNIT_TABLE_NAME );
|
||||||
db.execSQL( "DROP TABLE IF EXISTS " + REPORT_TABLE_NAME );
|
db.execSQL( "DROP TABLE IF EXISTS " + REPORT_TABLE_NAME );
|
||||||
|
db.execSQL( "DROP TABLE IF EXISTS " + CHECKPOINT_SKU_TABLE_NAME );
|
||||||
onCreate(db);
|
onCreate(db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,6 @@ public class DimensionRepository {
|
||||||
null);
|
null);
|
||||||
|
|
||||||
List<InspectionDimension> dimensions = new ArrayList<>();
|
List<InspectionDimension> dimensions = new ArrayList<>();
|
||||||
|
|
||||||
if ( cursor != null && cursor.moveToFirst() ) {
|
if ( cursor != null && cursor.moveToFirst() ) {
|
||||||
do {
|
do {
|
||||||
InspectionDimension dimension = new InspectionDimension();
|
InspectionDimension dimension = new InspectionDimension();
|
||||||
|
|
|
@ -0,0 +1,110 @@
|
||||||
|
package com.utopiaindustries.qualitychecker.db;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.ContentValues;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
|
||||||
|
import com.utopiaindustries.qualitychecker.models.InspectionCheckPoint;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.InspectionCheckpointSku;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.InspectionDimension;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
|
public class InspectionCheckpointSkuRepository {
|
||||||
|
|
||||||
|
private final DatabaseHelper dbHelper;
|
||||||
|
private final SQLiteDatabase database;
|
||||||
|
private final ExecutorService executorService;
|
||||||
|
|
||||||
|
public InspectionCheckpointSkuRepository( Context context ) {
|
||||||
|
dbHelper = new DatabaseHelper ( context );
|
||||||
|
database = dbHelper.getWritableDatabase();
|
||||||
|
executorService = Executors.newSingleThreadExecutor();
|
||||||
|
}
|
||||||
|
public void insert( List<InspectionCheckpointSku> checkPoints ) {
|
||||||
|
executorService.execute(() -> {
|
||||||
|
database.beginTransaction();
|
||||||
|
try {
|
||||||
|
for ( InspectionCheckpointSku checkPoint : checkPoints ) {
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put(DatabaseHelper.CHECKPOINT_SKU_SKU, checkPoint.getSku() );
|
||||||
|
values.put(DatabaseHelper.CHECKPOINT_SKU_CHECKPOINT_ID, checkPoint.getCheckpointId() );
|
||||||
|
values.put(DatabaseHelper.CHECKPOINT_SKU_STANDARD, checkPoint.getStandard() );
|
||||||
|
database.insertWithOnConflict(DatabaseHelper.CHECKPOINT_SKU_TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE);
|
||||||
|
}
|
||||||
|
database.setTransactionSuccessful();
|
||||||
|
} finally {
|
||||||
|
database.endTransaction();
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("Range")
|
||||||
|
public List<InspectionCheckpointSku> findBySku(String sku ){
|
||||||
|
|
||||||
|
String selection = DatabaseHelper.CHECKPOINT_SKU_SKU + "=?";
|
||||||
|
String[] selectionArgs = {sku};
|
||||||
|
|
||||||
|
Cursor cursor = database.query( DatabaseHelper.CHECKPOINT_SKU_TABLE_NAME,
|
||||||
|
null,
|
||||||
|
selection,
|
||||||
|
selectionArgs,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null);
|
||||||
|
|
||||||
|
List<InspectionCheckpointSku> checkpointSkus = new ArrayList<>();
|
||||||
|
if ( cursor != null && cursor.moveToFirst() ) {
|
||||||
|
do {
|
||||||
|
InspectionCheckpointSku checkpointSku = new InspectionCheckpointSku();
|
||||||
|
checkpointSku.setSku( cursor.getString( cursor.getColumnIndex( DatabaseHelper.CHECKPOINT_SKU_SKU )));
|
||||||
|
checkpointSku.setCheckpointId( cursor.getLong(cursor.getColumnIndex( DatabaseHelper.CHECKPOINT_SKU_CHECKPOINT_ID )));
|
||||||
|
checkpointSku.setStandard( cursor.getString(cursor.getColumnIndex(DatabaseHelper.CHECKPOINT_SKU_STANDARD )));
|
||||||
|
checkpointSkus.add( checkpointSku );
|
||||||
|
} while ( cursor.moveToNext() );
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
close();
|
||||||
|
return checkpointSkus;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressLint("Range")
|
||||||
|
public List<InspectionCheckpointSku> findAll( ) {
|
||||||
|
Cursor cursor = database.query( DatabaseHelper.CHECKPOINT_TABLE_NAME,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null);
|
||||||
|
|
||||||
|
List<InspectionCheckpointSku> checkPoints = new ArrayList<>();
|
||||||
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
|
do {
|
||||||
|
InspectionCheckpointSku checkPoint = new InspectionCheckpointSku();
|
||||||
|
checkPoint.setSku(cursor.getString( cursor.getColumnIndex(DatabaseHelper.CHECKPOINT_SKU_SKU )));
|
||||||
|
checkPoint.setCheckpointId(cursor.getLong(cursor.getColumnIndex(DatabaseHelper.CHECKPOINT_SKU_CHECKPOINT_ID) ));
|
||||||
|
checkPoint.setStandard(cursor.getString(cursor.getColumnIndex(DatabaseHelper.CHECKPOINT_SKU_STANDARD )));
|
||||||
|
checkPoints.add( checkPoint );
|
||||||
|
} while ( cursor.moveToNext() );
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
close();
|
||||||
|
return checkPoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Close the database
|
||||||
|
*/
|
||||||
|
public void close() {
|
||||||
|
dbHelper.close();
|
||||||
|
executorService.shutdown();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,8 @@
|
||||||
package com.utopiaindustries.qualitychecker.db;
|
package com.utopiaindustries.qualitychecker.db;
|
||||||
|
|
||||||
|
import static com.utopiaindustries.qualitychecker.db.DatabaseHelper.PRODUCT_COLUMN_ASIN;
|
||||||
|
import static com.utopiaindustries.qualitychecker.db.DatabaseHelper.PRODUCT_COLUMN_MARKETPLACE;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
@ -35,7 +38,7 @@ public class ProductRepository {
|
||||||
try {
|
try {
|
||||||
for (Product product : products) {
|
for (Product product : products) {
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
values.put(DatabaseHelper.PRODUCT_COLUMN_ASIN, product.getAsin());
|
values.put(PRODUCT_COLUMN_ASIN, product.getAsin());
|
||||||
values.put(DatabaseHelper.PRODUCT_COLUMN_PARENT_ASIN, product.getParentAsin());
|
values.put(DatabaseHelper.PRODUCT_COLUMN_PARENT_ASIN, product.getParentAsin());
|
||||||
values.put(DatabaseHelper.PRODUCT_COLUMN_MARKETPLACE, product.getMarketplace());
|
values.put(DatabaseHelper.PRODUCT_COLUMN_MARKETPLACE, product.getMarketplace());
|
||||||
values.put(DatabaseHelper.PRODUCT_COLUMN_SKU, product.getSku());
|
values.put(DatabaseHelper.PRODUCT_COLUMN_SKU, product.getSku());
|
||||||
|
@ -65,7 +68,7 @@ public class ProductRepository {
|
||||||
public void insert(Product product) {
|
public void insert(Product product) {
|
||||||
executorService.execute(() -> {
|
executorService.execute(() -> {
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
values.put(DatabaseHelper.PRODUCT_COLUMN_ASIN, product.getAsin());
|
values.put(PRODUCT_COLUMN_ASIN, product.getAsin());
|
||||||
values.put(DatabaseHelper.PRODUCT_COLUMN_PARENT_ASIN, product.getParentAsin());
|
values.put(DatabaseHelper.PRODUCT_COLUMN_PARENT_ASIN, product.getParentAsin());
|
||||||
values.put(DatabaseHelper.PRODUCT_COLUMN_MARKETPLACE, product.getMarketplace());
|
values.put(DatabaseHelper.PRODUCT_COLUMN_MARKETPLACE, product.getMarketplace());
|
||||||
values.put(DatabaseHelper.PRODUCT_COLUMN_SKU, product.getSku());
|
values.put(DatabaseHelper.PRODUCT_COLUMN_SKU, product.getSku());
|
||||||
|
@ -89,9 +92,13 @@ public class ProductRepository {
|
||||||
* Retrieve product by sku
|
* Retrieve product by sku
|
||||||
* */
|
* */
|
||||||
@SuppressLint("Range")
|
@SuppressLint("Range")
|
||||||
public List<Product> getProductBySku(String sku) {
|
public List<Product> getProductBySkuOrAsin(String sku, String marketplace) {
|
||||||
String selection = DatabaseHelper.PRODUCT_COLUMN_SKU + "=?";
|
String selection = "(" + DatabaseHelper.PRODUCT_COLUMN_SKU + "=? OR " + PRODUCT_COLUMN_ASIN + "=? )";
|
||||||
String[] selectionArgs = {sku};
|
String[] selectionArgs = {sku,sku};
|
||||||
|
if( marketplace != null && ! marketplace.isEmpty() ){
|
||||||
|
selection += "AND " + PRODUCT_COLUMN_MARKETPLACE + "=?";
|
||||||
|
selectionArgs = new String[]{ sku, sku, marketplace };
|
||||||
|
}
|
||||||
|
|
||||||
Cursor cursor = database.query(DatabaseHelper.PRODUCT_TABLE_NAME,
|
Cursor cursor = database.query(DatabaseHelper.PRODUCT_TABLE_NAME,
|
||||||
null,
|
null,
|
||||||
|
@ -104,7 +111,7 @@ public class ProductRepository {
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
do {
|
do {
|
||||||
Product product = new Product();
|
Product product = new Product();
|
||||||
product.setAsin(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_ASIN)));
|
product.setAsin(cursor.getString(cursor.getColumnIndex(PRODUCT_COLUMN_ASIN)));
|
||||||
product.setParentAsin(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_PARENT_ASIN)));
|
product.setParentAsin(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_PARENT_ASIN)));
|
||||||
product.setMarketplace(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_MARKETPLACE)));
|
product.setMarketplace(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_MARKETPLACE)));
|
||||||
product.setSku(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_SKU)));
|
product.setSku(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_SKU)));
|
||||||
|
@ -132,7 +139,7 @@ public class ProductRepository {
|
||||||
* */
|
* */
|
||||||
@SuppressLint("Range")
|
@SuppressLint("Range")
|
||||||
public Product getProduct(String asin, String marketplace, String sku) {
|
public Product getProduct(String asin, String marketplace, String sku) {
|
||||||
String selection = DatabaseHelper.PRODUCT_COLUMN_ASIN + "=? AND " +
|
String selection = PRODUCT_COLUMN_ASIN + "=? AND " +
|
||||||
DatabaseHelper.PRODUCT_COLUMN_MARKETPLACE + "=? AND " +
|
DatabaseHelper.PRODUCT_COLUMN_MARKETPLACE + "=? AND " +
|
||||||
DatabaseHelper.PRODUCT_COLUMN_SKU + "=?";
|
DatabaseHelper.PRODUCT_COLUMN_SKU + "=?";
|
||||||
String[] selectionArgs = {asin, marketplace, sku};
|
String[] selectionArgs = {asin, marketplace, sku};
|
||||||
|
@ -145,7 +152,7 @@ public class ProductRepository {
|
||||||
|
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
Product product = new Product();
|
Product product = new Product();
|
||||||
product.setAsin( cursor.getString( cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_ASIN ) ));
|
product.setAsin( cursor.getString( cursor.getColumnIndex(PRODUCT_COLUMN_ASIN ) ));
|
||||||
product.setParentAsin( cursor.getString( cursor.getColumnIndex( DatabaseHelper.PRODUCT_COLUMN_PARENT_ASIN ) ));
|
product.setParentAsin( cursor.getString( cursor.getColumnIndex( DatabaseHelper.PRODUCT_COLUMN_PARENT_ASIN ) ));
|
||||||
product.setMarketplace( cursor.getString( cursor.getColumnIndex( DatabaseHelper.PRODUCT_COLUMN_MARKETPLACE )));
|
product.setMarketplace( cursor.getString( cursor.getColumnIndex( DatabaseHelper.PRODUCT_COLUMN_MARKETPLACE )));
|
||||||
product.setSku(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_SKU)));
|
product.setSku(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_SKU)));
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
package com.utopiaindustries.qualitychecker.models;
|
||||||
|
|
||||||
|
public class InspectionCheckpointSku {
|
||||||
|
|
||||||
|
private String sku;
|
||||||
|
private long checkpointId;
|
||||||
|
private String standard;
|
||||||
|
|
||||||
|
public InspectionCheckpointSku() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public InspectionCheckpointSku(String sku, long checkpointId, String standard) {
|
||||||
|
this.sku = sku;
|
||||||
|
this.checkpointId = checkpointId;
|
||||||
|
this.standard = standard;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSku() {
|
||||||
|
return sku;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSku(String sku) {
|
||||||
|
this.sku = sku;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getCheckpointId() {
|
||||||
|
return checkpointId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCheckpointId(long checkpointId) {
|
||||||
|
this.checkpointId = checkpointId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStandard() {
|
||||||
|
return standard;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStandard(String standard) {
|
||||||
|
this.standard = standard;
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,10 +9,12 @@ import com.utopiaindustries.qualitychecker.apiservice.ApiServiceFactory;
|
||||||
import com.utopiaindustries.qualitychecker.db.CheckpointRepository;
|
import com.utopiaindustries.qualitychecker.db.CheckpointRepository;
|
||||||
import com.utopiaindustries.qualitychecker.db.DefectRepository;
|
import com.utopiaindustries.qualitychecker.db.DefectRepository;
|
||||||
import com.utopiaindustries.qualitychecker.db.DimensionRepository;
|
import com.utopiaindustries.qualitychecker.db.DimensionRepository;
|
||||||
|
import com.utopiaindustries.qualitychecker.db.InspectionCheckpointSkuRepository;
|
||||||
import com.utopiaindustries.qualitychecker.db.ItemRepository;
|
import com.utopiaindustries.qualitychecker.db.ItemRepository;
|
||||||
import com.utopiaindustries.qualitychecker.db.ProductRepository;
|
import com.utopiaindustries.qualitychecker.db.ProductRepository;
|
||||||
import com.utopiaindustries.qualitychecker.db.ReportRepository;
|
import com.utopiaindustries.qualitychecker.db.ReportRepository;
|
||||||
import com.utopiaindustries.qualitychecker.models.InspectionCheckPoint;
|
import com.utopiaindustries.qualitychecker.models.InspectionCheckPoint;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.InspectionCheckpointSku;
|
||||||
import com.utopiaindustries.qualitychecker.models.InspectionDefect;
|
import com.utopiaindustries.qualitychecker.models.InspectionDefect;
|
||||||
import com.utopiaindustries.qualitychecker.models.InspectionDimension;
|
import com.utopiaindustries.qualitychecker.models.InspectionDimension;
|
||||||
import com.utopiaindustries.qualitychecker.models.InspectionItemCheckPoint;
|
import com.utopiaindustries.qualitychecker.models.InspectionItemCheckPoint;
|
||||||
|
@ -253,6 +255,13 @@ public class InspectionReportService {
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void fetchAndPopulateSkuCheckpoints( SaveItemCallback callback,
|
||||||
|
InspectionCheckpointSkuRepository repository ){
|
||||||
|
new Thread(() -> {
|
||||||
|
populateSkuCheckpoints( callback, repository );
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void populateProducts( SaveProductCallBack callback,
|
private void populateProducts( SaveProductCallBack callback,
|
||||||
ProductRepository repository ){
|
ProductRepository repository ){
|
||||||
|
@ -393,4 +402,36 @@ public class InspectionReportService {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* populate sku checkpoints tagging
|
||||||
|
* */
|
||||||
|
private void populateSkuCheckpoints( SaveItemCallback callback ,
|
||||||
|
InspectionCheckpointSkuRepository repository){
|
||||||
|
apiService.fetchSkuCheckpoints().enqueue(
|
||||||
|
new Callback<List<InspectionCheckpointSku>>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse( Call<List<InspectionCheckpointSku>> call,
|
||||||
|
Response<List<InspectionCheckpointSku>> response) {
|
||||||
|
if (response.isSuccessful()) {
|
||||||
|
try {
|
||||||
|
System.out.println( response.body() );
|
||||||
|
callback.onSuccess();
|
||||||
|
repository.insert( response.body() );
|
||||||
|
} catch ( Exception ex ){
|
||||||
|
callback.onFailure(new Exception( ex.getMessage() ) );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
callback.onFailure(new Exception("API call failed with status code: " + response.code()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onFailure( Call<List<InspectionCheckpointSku>> call,
|
||||||
|
Throwable t) {
|
||||||
|
System.out.println( t );
|
||||||
|
callback.onFailure( t );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -9,6 +9,7 @@ import com.utopiaindustries.qualitychecker.db.DefectRepository;
|
||||||
import com.utopiaindustries.qualitychecker.db.ItemRepository;
|
import com.utopiaindustries.qualitychecker.db.ItemRepository;
|
||||||
import com.utopiaindustries.qualitychecker.models.EmployeePhoto;
|
import com.utopiaindustries.qualitychecker.models.EmployeePhoto;
|
||||||
import com.utopiaindustries.qualitychecker.models.InspectionCheckPoint;
|
import com.utopiaindustries.qualitychecker.models.InspectionCheckPoint;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.InspectionCheckpointSku;
|
||||||
import com.utopiaindustries.qualitychecker.models.InspectionDefect;
|
import com.utopiaindustries.qualitychecker.models.InspectionDefect;
|
||||||
import com.utopiaindustries.qualitychecker.models.InspectionDimension;
|
import com.utopiaindustries.qualitychecker.models.InspectionDimension;
|
||||||
import com.utopiaindustries.qualitychecker.models.InspectionItemCheckPoint;
|
import com.utopiaindustries.qualitychecker.models.InspectionItemCheckPoint;
|
||||||
|
@ -35,6 +36,7 @@ public class Store {
|
||||||
private List<Product> products;
|
private List<Product> products;
|
||||||
private EmployeePhoto employeePhoto;
|
private EmployeePhoto employeePhoto;
|
||||||
private List<ItemUnit> itemUnits;
|
private List<ItemUnit> itemUnits;
|
||||||
|
private List<InspectionCheckpointSku> checkpointSkus;
|
||||||
|
|
||||||
private Store(){
|
private Store(){
|
||||||
}
|
}
|
||||||
|
@ -224,6 +226,14 @@ public class Store {
|
||||||
this.dimensionList = dimensionList;
|
this.dimensionList = dimensionList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<InspectionCheckpointSku> getCheckpointSkus() {
|
||||||
|
return checkpointSkus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCheckpointSkus(List<InspectionCheckpointSku> checkpointSkus) {
|
||||||
|
this.checkpointSkus = checkpointSkus;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Store{" +
|
return "Store{" +
|
||||||
|
|
|
@ -30,6 +30,7 @@ import com.utopiaindustries.qualitychecker.apiservice.ApiServiceFactory;
|
||||||
import com.utopiaindustries.qualitychecker.db.CheckpointRepository;
|
import com.utopiaindustries.qualitychecker.db.CheckpointRepository;
|
||||||
import com.utopiaindustries.qualitychecker.db.DefectRepository;
|
import com.utopiaindustries.qualitychecker.db.DefectRepository;
|
||||||
import com.utopiaindustries.qualitychecker.db.DimensionRepository;
|
import com.utopiaindustries.qualitychecker.db.DimensionRepository;
|
||||||
|
import com.utopiaindustries.qualitychecker.db.InspectionCheckpointSkuRepository;
|
||||||
import com.utopiaindustries.qualitychecker.db.ItemRepository;
|
import com.utopiaindustries.qualitychecker.db.ItemRepository;
|
||||||
import com.utopiaindustries.qualitychecker.db.ProductRepository;
|
import com.utopiaindustries.qualitychecker.db.ProductRepository;
|
||||||
import com.utopiaindustries.qualitychecker.models.EmployeePhoto;
|
import com.utopiaindustries.qualitychecker.models.EmployeePhoto;
|
||||||
|
@ -159,6 +160,7 @@ public class HomeActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
fetchAndPopulateCheckpointData();
|
fetchAndPopulateCheckpointData();
|
||||||
fetchAndPopulateDefectsData();
|
fetchAndPopulateDefectsData();
|
||||||
fetchAndPopulateUnitsData();
|
fetchAndPopulateUnitsData();
|
||||||
|
fetchAndPopulateSkuCheckpointsData();
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText( this, "network not available", Toast.LENGTH_LONG ).show();
|
Toast.makeText( this, "network not available", Toast.LENGTH_LONG ).show();
|
||||||
}
|
}
|
||||||
|
@ -336,6 +338,33 @@ public class HomeActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
}, new ItemRepository( this ) );
|
}, new ItemRepository( this ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void fetchAndPopulateSkuCheckpointsData(){
|
||||||
|
|
||||||
|
NotificationHelper.showProductNotification(
|
||||||
|
this,
|
||||||
|
"Utopia QA App",
|
||||||
|
"Fetching sku checkpoints Details.");
|
||||||
|
inspectionReportService.fetchAndPopulateSkuCheckpoints( new SaveItemCallback() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess() {
|
||||||
|
Toast.makeText( HomeActivity.this, "Sku Cps successfully synced", Toast.LENGTH_LONG ).show();
|
||||||
|
NotificationHelper.showProductNotification(
|
||||||
|
HomeActivity.this,
|
||||||
|
"Utopia QA App",
|
||||||
|
"Sku Cps successfully synced");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable throwable) {
|
||||||
|
Toast.makeText( HomeActivity.this, "Error in Sku Cps syncing " + throwable.getMessage(), Toast.LENGTH_LONG ).show();
|
||||||
|
NotificationHelper.showProductNotification(
|
||||||
|
HomeActivity.this,
|
||||||
|
"Utopia QA App",
|
||||||
|
"Error in Sku Cps " );
|
||||||
|
}
|
||||||
|
}, new InspectionCheckpointSkuRepository( this ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private boolean isNetworkConnected() {
|
private boolean isNetworkConnected() {
|
||||||
|
|
|
@ -26,6 +26,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.utopiaindustries.qualitychecker.R;
|
import com.utopiaindustries.qualitychecker.R;
|
||||||
import com.utopiaindustries.qualitychecker.models.InspectionCheckPoint;
|
import com.utopiaindustries.qualitychecker.models.InspectionCheckPoint;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.InspectionCheckpointSku;
|
||||||
import com.utopiaindustries.qualitychecker.models.InspectionDefect;
|
import com.utopiaindustries.qualitychecker.models.InspectionDefect;
|
||||||
import com.utopiaindustries.qualitychecker.models.InspectionItemCheckPoint;
|
import com.utopiaindustries.qualitychecker.models.InspectionItemCheckPoint;
|
||||||
|
|
||||||
|
@ -39,17 +40,20 @@ public class CheckPointAdapter extends
|
||||||
private final List<InspectionCheckPoint> checkPoints;
|
private final List<InspectionCheckPoint> checkPoints;
|
||||||
private final List<InspectionDefect> defects;
|
private final List<InspectionDefect> defects;
|
||||||
private final List<String> defectTypes;
|
private final List<String> defectTypes;
|
||||||
|
private final List<InspectionCheckpointSku> checkpointSkus;
|
||||||
private final Context context;
|
private final Context context;
|
||||||
public CheckPointAdapter( List<InspectionItemCheckPoint> checkPointList,
|
public CheckPointAdapter( List<InspectionItemCheckPoint> checkPointList,
|
||||||
List<InspectionCheckPoint> checkPoints,
|
List<InspectionCheckPoint> checkPoints,
|
||||||
List<InspectionDefect> defects,
|
List<InspectionDefect> defects,
|
||||||
List<String> defectTypes,
|
List<String> defectTypes,
|
||||||
|
List<InspectionCheckpointSku> checkpointSkus,
|
||||||
Context context ) {
|
Context context ) {
|
||||||
|
|
||||||
this.checkPointList = checkPointList;
|
this.checkPointList = checkPointList;
|
||||||
this.checkPoints = checkPoints;
|
this.checkPoints = checkPoints;
|
||||||
this.defects = defects;
|
this.defects = defects;
|
||||||
this.defectTypes = defectTypes;
|
this.defectTypes = defectTypes;
|
||||||
|
this.checkpointSkus = checkpointSkus;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +73,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, context );
|
holder.bind(checkPoints, defects, defectTypes, checkPoint, checkpointSkus, context );
|
||||||
holder.setIsRecyclable(false);
|
holder.setIsRecyclable(false);
|
||||||
// spinner on change
|
// spinner on change
|
||||||
{
|
{
|
||||||
|
@ -143,12 +147,11 @@ public class CheckPointAdapter extends
|
||||||
|
|
||||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
private final Spinner checkpointSpinner;
|
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,addDefect;
|
private final ImageButton imagePicker,deleteImage,addDefect;
|
||||||
private final LinearLayout linearLayout;
|
private final LinearLayout linearLayout;
|
||||||
private final TextView selectedImage;
|
private final TextView selectedImage,standard;
|
||||||
private final ImageView imagePreview;
|
private final ImageView imagePreview;
|
||||||
private final RecyclerView defectRecyclerView;
|
private final RecyclerView defectRecyclerView;
|
||||||
|
|
||||||
|
@ -160,13 +163,12 @@ 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);
|
|
||||||
// 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 );
|
defectRecyclerView = itemView.findViewById( R.id.defects_recyclerview );
|
||||||
addDefect = itemView.findViewById( R.id.add_defect );
|
addDefect = itemView.findViewById( R.id.add_defect );
|
||||||
|
standard = itemView.findViewById( R.id.standard );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -174,10 +176,10 @@ public class CheckPointAdapter extends
|
||||||
List<InspectionDefect> defects,
|
List<InspectionDefect> defects,
|
||||||
List<String> defectTypeOptions,
|
List<String> defectTypeOptions,
|
||||||
InspectionItemCheckPoint data,
|
InspectionItemCheckPoint data,
|
||||||
|
List<InspectionCheckpointSku> checkpointSkus,
|
||||||
Context context ) {
|
Context context ) {
|
||||||
// initialize recyclerview
|
// 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
|
||||||
|
@ -209,6 +211,14 @@ public class CheckPointAdapter extends
|
||||||
}
|
}
|
||||||
|
|
||||||
InspectionCheckPoint cp = checkPoints.stream().filter(c ->c.getTitle().equalsIgnoreCase(defaultSelectedItem)).findFirst().get();
|
InspectionCheckPoint cp = checkPoints.stream().filter(c ->c.getTitle().equalsIgnoreCase(defaultSelectedItem)).findFirst().get();
|
||||||
|
// set standard
|
||||||
|
InspectionCheckpointSku cpSku = checkpointSkus.stream()
|
||||||
|
.filter( inspectionCheckpointSku -> inspectionCheckpointSku.getCheckpointId() == cp.getId() )
|
||||||
|
.findFirst()
|
||||||
|
.orElse( new InspectionCheckpointSku() );
|
||||||
|
if( cpSku.getStandard() != null && ! cpSku.getStandard().isEmpty() ){
|
||||||
|
standard.setText( cpSku.getStandard() );
|
||||||
|
}
|
||||||
|
|
||||||
defectRecyclerView.setLayoutManager( new LinearLayoutManager( context ) );
|
defectRecyclerView.setLayoutManager( new LinearLayoutManager( context ) );
|
||||||
DefectsAdapter defectsAdapter = new DefectsAdapter(data, defectTypeOptions, defects, cp);
|
DefectsAdapter defectsAdapter = new DefectsAdapter(data, defectTypeOptions, defects, cp);
|
||||||
|
|
|
@ -33,7 +33,9 @@ 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.db.DimensionRepository;
|
import com.utopiaindustries.qualitychecker.db.DimensionRepository;
|
||||||
|
import com.utopiaindustries.qualitychecker.db.InspectionCheckpointSkuRepository;
|
||||||
import com.utopiaindustries.qualitychecker.db.ProductRepository;
|
import com.utopiaindustries.qualitychecker.db.ProductRepository;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.InspectionCheckpointSku;
|
||||||
import com.utopiaindustries.qualitychecker.models.InspectionDimension;
|
import com.utopiaindustries.qualitychecker.models.InspectionDimension;
|
||||||
import com.utopiaindustries.qualitychecker.models.InspectionReportItem;
|
import com.utopiaindustries.qualitychecker.models.InspectionReportItem;
|
||||||
import com.utopiaindustries.qualitychecker.models.Product;
|
import com.utopiaindustries.qualitychecker.models.Product;
|
||||||
|
@ -79,7 +81,7 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
|
||||||
searchSku.setOnClickListener( this );
|
searchSku.setOnClickListener( this );
|
||||||
scanBtn.setOnClickListener( this );
|
scanBtn.setOnClickListener( this );
|
||||||
showHistoryBtn.setOnClickListener( this );
|
showHistoryBtn.setOnClickListener( this );
|
||||||
populateItem( store.getProducts() );
|
populateItem( store.getProducts(), true );
|
||||||
prePopulateData( store.getProducts() );
|
prePopulateData( store.getProducts() );
|
||||||
updateProfileViews();
|
updateProfileViews();
|
||||||
|
|
||||||
|
@ -102,13 +104,22 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
|
||||||
fri.setChecked( true );
|
fri.setChecked( true );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// marketplace
|
// marketplace
|
||||||
markerplace.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
markerplace.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
if( parent.getItemAtPosition( position ) != null ){
|
if( parent.getItemAtPosition( position ) != null ){
|
||||||
String marketplaceOption = parent.getItemAtPosition( position ).toString();
|
String marketplaceOption = parent.getItemAtPosition( position ).toString();
|
||||||
store.getReport().getItems().get(0).setMarketplace( marketplaceOption );
|
store.getReport().getItems().get(0).setMarketplace( marketplaceOption );
|
||||||
|
System.out.println( marketplaceOption );
|
||||||
|
populateProductDataOnSelection(
|
||||||
|
store.getReport().getItems().get(0).getSku(),
|
||||||
|
marketplaceOption,
|
||||||
|
false
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,58 +293,8 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
|
||||||
}
|
}
|
||||||
if( v.getId() == R.id.search_sku_btn ){
|
if( v.getId() == R.id.search_sku_btn ){
|
||||||
if( sku.getText() != null ){
|
if( sku.getText() != null ){
|
||||||
// setting the product details
|
populateProductDataOnSelection( sku.getText().toString(), "", true );
|
||||||
String skuStr = sku.getText().toString().trim();
|
populateSkuCheckpointsParams( sku.getText().toString() );
|
||||||
List<Product> products = new ProductRepository( getContext() ).getProductBySku( skuStr );
|
|
||||||
Product product = products.stream().findFirst().orElse( new Product() );
|
|
||||||
store.getReport().getItems().get(0).setSku( skuStr );
|
|
||||||
store.getReport().getItems().get(0).setAsin( product.getAsin() );
|
|
||||||
populateItem( products );
|
|
||||||
store.setProducts( products );
|
|
||||||
|
|
||||||
|
|
||||||
// apiService.fetchProductBySku( skuStr ).enqueue(
|
|
||||||
// new Callback<List<Product>>() {
|
|
||||||
// @Override
|
|
||||||
// public void onResponse(Call<List<Product>> call, Response<List<Product>> response) {
|
|
||||||
// if( response.isSuccessful() && response.body() != null ){
|
|
||||||
// Product product = response.body().stream().findFirst().orElse(new Product());
|
|
||||||
// store.getReport().getItems().get(0).setSku( skuStr );
|
|
||||||
// store.getReport().getItems().get(0).setAsin( product.getAsin() );
|
|
||||||
// populateItem( response.body() );
|
|
||||||
// store.setProducts( response.body() );
|
|
||||||
// } else {
|
|
||||||
// Snackbar.make(v, "Error in response", Snackbar.LENGTH_LONG ).show();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onFailure(Call<List<Product>> call, Throwable t) {
|
|
||||||
// System.out.println( t.getMessage() );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
// apiService.fetchDimensions( ).enqueue(
|
|
||||||
// new Callback<List<InspectionDimension>>() {
|
|
||||||
// @Override
|
|
||||||
// public void onResponse(Call<List<InspectionDimension>> call, Response<List<InspectionDimension>> response) {
|
|
||||||
// if( response.isSuccessful() && response.body() != null ){
|
|
||||||
// store.setDimensionList( response.body() );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onFailure(Call<List<InspectionDimension>> call, Throwable t) {
|
|
||||||
// System.out.println( t.getMessage() );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
if( product.getCategory() != null ){
|
|
||||||
List<InspectionDimension> dimensions = new DimensionRepository( getContext() ).findByCategory(
|
|
||||||
product.getCategory()
|
|
||||||
);
|
|
||||||
store.setDimensionList( dimensions );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( v.getId() == R.id.scan_sku_btn ){
|
if( v.getId() == R.id.scan_sku_btn ){
|
||||||
|
@ -348,6 +309,34 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void populateSkuCheckpointsParams( String sku ){
|
||||||
|
if( sku != null && ! sku.isEmpty() ){
|
||||||
|
List<InspectionCheckpointSku> checkpointSkus = new InspectionCheckpointSkuRepository( getContext() )
|
||||||
|
.findBySku( sku );
|
||||||
|
System.out.println( checkpointSkus );
|
||||||
|
store.setCheckpointSkus( checkpointSkus );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void populateProductDataOnSelection( String sku, String marketplace , boolean populateMarketplace){
|
||||||
|
// setting the product details
|
||||||
|
if( sku != null ){
|
||||||
|
String skuStr = sku.trim();
|
||||||
|
List<Product> products = new ProductRepository( getContext() ).getProductBySkuOrAsin( skuStr, marketplace );
|
||||||
|
System.out.println( products );
|
||||||
|
Product product = products.stream().findFirst().orElse( new Product() );
|
||||||
|
store.getReport().getItems().get(0).setSku( product.getSku() );
|
||||||
|
store.getReport().getItems().get(0).setAsin( product.getAsin() );
|
||||||
|
populateItem( products, populateMarketplace );
|
||||||
|
store.setProducts( products );
|
||||||
|
if( product.getCategory() != null ){
|
||||||
|
List<InspectionDimension> dimensions = new DimensionRepository( getContext() ).findByCategory(
|
||||||
|
product.getCategory()
|
||||||
|
);
|
||||||
|
store.setDimensionList( dimensions );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
private void prePopulateData( List<Product> products ){
|
private void prePopulateData( List<Product> products ){
|
||||||
fri.setChecked( store.getReport().getFri() );
|
fri.setChecked( store.getReport().getFri() );
|
||||||
refri.setChecked( ! store.getReport().getFri() );
|
refri.setChecked( ! store.getReport().getFri() );
|
||||||
|
@ -373,8 +362,10 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateItem( List<Product> products ){
|
private void populateItem( List<Product> products , boolean populateMarketplace){
|
||||||
populateMarketplaces( products );
|
if( populateMarketplace ){
|
||||||
|
populateMarketplaces( products );
|
||||||
|
}
|
||||||
populateMmodelNumber(products );
|
populateMmodelNumber(products );
|
||||||
populateTitle( products );
|
populateTitle( products );
|
||||||
populateColor( products );
|
populateColor( products );
|
||||||
|
|
|
@ -88,6 +88,7 @@ public class SecondStepFragment extends Fragment
|
||||||
store.getCheckPoints(),
|
store.getCheckPoints(),
|
||||||
store.getDefects(),
|
store.getDefects(),
|
||||||
inspectionReportService.getDefectTypes(),
|
inspectionReportService.getDefectTypes(),
|
||||||
|
store.getCheckpointSkus(),
|
||||||
getContext());
|
getContext());
|
||||||
recyclerView.setAdapter( adapter );
|
recyclerView.setAdapter( adapter );
|
||||||
// set on click listener
|
// set on click listener
|
||||||
|
|
|
@ -138,5 +138,14 @@
|
||||||
<!-- android:id="@+id/defect_type_spinner">-->
|
<!-- android:id="@+id/defect_type_spinner">-->
|
||||||
<!-- </Spinner>-->
|
<!-- </Spinner>-->
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/standard"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text=""
|
||||||
|
android:background="@color/light_blue_2"
|
||||||
|
android:padding="16dp"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:textColor="#000000" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</androidx.cardview.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
|
@ -9,5 +9,6 @@
|
||||||
<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="light_blue_2">#6DE2F1</color>
|
||||||
<color name="cp_bg_color">#FFFFFF</color>
|
<color name="cp_bg_color">#FFFFFF</color>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue