- feedback 1 implemented
parent
30526b3dab
commit
1b53281f73
|
@ -2,5 +2,6 @@
|
||||||
<profile version="1.0">
|
<profile version="1.0">
|
||||||
<option name="myName" value="Project Default" />
|
<option name="myName" value="Project Default" />
|
||||||
<inspection_tool class="Deprecation" enabled="false" level="WARNING" enabled_by_default="false" />
|
<inspection_tool class="Deprecation" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="ThrowablePrintStackTrace" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
</profile>
|
</profile>
|
||||||
</component>
|
</component>
|
|
@ -2,7 +2,6 @@ plugins {
|
||||||
alias(libs.plugins.androidApplication)
|
alias(libs.plugins.androidApplication)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace 'com.utopiaindustries.qualitychecker'
|
namespace 'com.utopiaindustries.qualitychecker'
|
||||||
compileSdk 34
|
compileSdk 34
|
||||||
|
@ -45,10 +44,9 @@ dependencies {
|
||||||
implementation "androidx.navigation:navigation-fragment:2.4.0"
|
implementation "androidx.navigation:navigation-fragment:2.4.0"
|
||||||
implementation "androidx.navigation:navigation-ui:2.4.0"
|
implementation "androidx.navigation:navigation-ui:2.4.0"
|
||||||
implementation 'androidx.lifecycle:lifecycle-viewmodel:2.4.0'
|
implementation 'androidx.lifecycle:lifecycle-viewmodel:2.4.0'
|
||||||
implementation 'androidx.lifecycle:lifecycle-livedata:2.4.0'
|
|
||||||
implementation 'com.github.bumptech.glide:glide:4.12.0'
|
implementation 'com.github.bumptech.glide:glide:4.12.0'
|
||||||
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
|
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
|
||||||
implementation 'com.journeyapps:zxing-android-embedded:4.1.0'
|
implementation 'com.journeyapps:zxing-android-embedded:4.1.0'
|
||||||
|
implementation 'com.squareup.okhttp3:okhttp:4.9.3'
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -10,7 +10,7 @@
|
||||||
<uses-permission android:name="android.permission.CAMERA"/>
|
<uses-permission android:name="android.permission.CAMERA"/>
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="false"
|
||||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||||
android:fullBackupContent="@xml/backup_rules"
|
android:fullBackupContent="@xml/backup_rules"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
@ -19,9 +19,8 @@
|
||||||
android:roundIcon="@mipmap/ic_launcher"
|
android:roundIcon="@mipmap/ic_launcher"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme"
|
android:theme="@style/AppTheme"
|
||||||
tools:targetApi="31"
|
tools:targetApi="26"
|
||||||
android:usesCleartextTraffic="true">
|
android:usesCleartextTraffic="true">
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.google.zxing.client.android.CaptureActivity"
|
android:name="com.google.zxing.client.android.CaptureActivity"
|
||||||
android:configChanges="orientation|keyboardHidden"
|
android:configChanges="orientation|keyboardHidden"
|
||||||
|
@ -39,7 +38,6 @@
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:windowSoftInputMode="stateAlwaysVisible|adjustResize">
|
android:windowSoftInputMode="stateAlwaysVisible|adjustResize">
|
||||||
|
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.activities.HomeActivity"
|
android:name=".ui.activities.HomeActivity"
|
||||||
|
@ -59,6 +57,15 @@
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
<service android:name=".service.NetworkService"
|
||||||
|
android:exported="false"/>
|
||||||
|
<receiver
|
||||||
|
android:name=".receiver.NetworkReceiver"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
|
@ -55,10 +55,13 @@ public interface ApiService {
|
||||||
@GET( "rest/uic/inspection-report/defects" )
|
@GET( "rest/uic/inspection-report/defects" )
|
||||||
Call<List<InspectionDefect>> fetchDefects();
|
Call<List<InspectionDefect>> fetchDefects();
|
||||||
|
|
||||||
|
// @GET( "rest/uic/inspection-report/dimensions" )
|
||||||
|
// Call<List<InspectionDimension>> fetchDimensions(
|
||||||
|
// @Query("sku") String sku
|
||||||
|
// );
|
||||||
|
|
||||||
@GET( "rest/uic/inspection-report/dimensions" )
|
@GET( "rest/uic/inspection-report/dimensions" )
|
||||||
Call<List<InspectionDimension>> fetchDimensions(
|
Call<List<InspectionDimension>> fetchDimensions();
|
||||||
@Query("sku") String sku
|
|
||||||
);
|
|
||||||
|
|
||||||
@GET( "rest/hrms/employees/attendance")
|
@GET( "rest/hrms/employees/attendance")
|
||||||
Call<EmployeePhoto> fetchEmployeePhoto(
|
Call<EmployeePhoto> fetchEmployeePhoto(
|
||||||
|
@ -82,4 +85,7 @@ public interface ApiService {
|
||||||
|
|
||||||
@GET( "rest/uic/items/units" )
|
@GET( "rest/uic/items/units" )
|
||||||
Call<List<ItemUnit>> fetchItemUnits();
|
Call<List<ItemUnit>> fetchItemUnits();
|
||||||
|
|
||||||
|
@GET( "rest/uic/cosmos-products/" )
|
||||||
|
Call<List<Product>> fetchAllProducts();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,17 @@ 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 java.security.KeyManagementException;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.cert.CertificateException;
|
||||||
|
import java.security.cert.X509Certificate;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.net.ssl.SSLContext;
|
||||||
|
import javax.net.ssl.SSLSocketFactory;
|
||||||
|
import javax.net.ssl.TrustManager;
|
||||||
|
import javax.net.ssl.X509TrustManager;
|
||||||
|
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
import retrofit2.converter.gson.GsonConverterFactory;
|
import retrofit2.converter.gson.GsonConverterFactory;
|
||||||
|
@ -22,17 +31,15 @@ public class RetrofitClient {
|
||||||
.create();
|
.create();
|
||||||
|
|
||||||
if (retrofit == null) {
|
if (retrofit == null) {
|
||||||
OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
try {
|
||||||
.connectTimeout(60, TimeUnit.SECONDS)
|
|
||||||
.readTimeout(60, TimeUnit.SECONDS)
|
|
||||||
.writeTimeout(60, TimeUnit.SECONDS)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
retrofit = new Retrofit.Builder()
|
retrofit = new Retrofit.Builder()
|
||||||
.baseUrl(BASE_URL)
|
.baseUrl(BASE_URL)
|
||||||
.client( okHttpClient )
|
.client( SSLCheckHttpClient.getOkHttpClient() )
|
||||||
.addConverterFactory(GsonConverterFactory.create(gson))
|
.addConverterFactory(GsonConverterFactory.create(gson))
|
||||||
.build();
|
.build();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return retrofit;
|
return retrofit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
package com.utopiaindustries.qualitychecker.apiservice;
|
||||||
|
|
||||||
|
import java.security.KeyManagementException;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.cert.CertificateException;
|
||||||
|
import java.security.cert.X509Certificate;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.net.ssl.SSLContext;
|
||||||
|
import javax.net.ssl.SSLSocketFactory;
|
||||||
|
import javax.net.ssl.TrustManager;
|
||||||
|
import javax.net.ssl.X509TrustManager;
|
||||||
|
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
|
public class SSLCheckHttpClient {
|
||||||
|
public static OkHttpClient getOkHttpClient() throws NoSuchAlgorithmException, KeyManagementException {
|
||||||
|
// Create a trust manager that does not validate certificate chains
|
||||||
|
final TrustManager[] trustAllCerts = new TrustManager[]{
|
||||||
|
new X509TrustManager() {
|
||||||
|
@Override
|
||||||
|
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public X509Certificate[] getAcceptedIssuers() {
|
||||||
|
return new X509Certificate[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Install the all-trusting trust manager
|
||||||
|
final SSLContext sslContext = SSLContext.getInstance("SSL");
|
||||||
|
sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
|
||||||
|
|
||||||
|
// Create an ssl socket factory with our all-trusting manager
|
||||||
|
final SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
|
||||||
|
|
||||||
|
|
||||||
|
return new OkHttpClient.Builder()
|
||||||
|
.sslSocketFactory(sslSocketFactory, (X509TrustManager) trustAllCerts[0])
|
||||||
|
.hostnameVerifier((hostname, session) -> true)
|
||||||
|
.connectTimeout(60, TimeUnit.SECONDS)
|
||||||
|
.readTimeout(60, TimeUnit.SECONDS)
|
||||||
|
.writeTimeout(60, TimeUnit.SECONDS)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -28,9 +28,7 @@ public class ImageProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void compressImageFromUriAsync(final Context context, final Uri uri, final int maxSizeKB, final OnImageCompressedListener listener) {
|
public void compressImageFromUriAsync(final Context context, final Uri uri, final int maxSizeKB, final OnImageCompressedListener listener) {
|
||||||
backgroundHandler.post(new Runnable() {
|
backgroundHandler.post(() -> {
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
byte[] imageData = getBytesFromUri(context, uri);
|
byte[] imageData = getBytesFromUri(context, uri);
|
||||||
if (imageData != null) {
|
if (imageData != null) {
|
||||||
final byte[] compressedData = compressImageToMaxSize(imageData, maxSizeKB);
|
final byte[] compressedData = compressImageToMaxSize(imageData, maxSizeKB);
|
||||||
|
@ -43,7 +41,6 @@ public class ImageProcessor {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
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.InspectionDimension;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
|
public class CheckpointRepository {
|
||||||
|
|
||||||
|
private final DatabaseHelper dbHelper;
|
||||||
|
private final SQLiteDatabase database;
|
||||||
|
private final ExecutorService executorService;
|
||||||
|
|
||||||
|
public CheckpointRepository( Context context ) {
|
||||||
|
dbHelper = new DatabaseHelper ( context );
|
||||||
|
database = dbHelper.getWritableDatabase();
|
||||||
|
executorService = Executors.newSingleThreadExecutor();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Insert list of checkpoints in batch
|
||||||
|
* */
|
||||||
|
public void insert( List<InspectionCheckPoint> checkPoints ) {
|
||||||
|
executorService.execute(() -> {
|
||||||
|
database.beginTransaction();
|
||||||
|
try {
|
||||||
|
for ( InspectionCheckPoint checkPoint : checkPoints ) {
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put(DatabaseHelper.CHECKPOINT_COLUMN_ID, checkPoint.getId() );
|
||||||
|
values.put(DatabaseHelper.CHECKPOINT_COLUMN_TITLE, checkPoint.getTitle() );
|
||||||
|
values.put(DatabaseHelper.CHECKPOINT_COLUMN_CATEGORY, checkPoint.getCategory() );
|
||||||
|
database.insertWithOnConflict(DatabaseHelper.CHECKPOINT_TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE);
|
||||||
|
}
|
||||||
|
database.setTransactionSuccessful();
|
||||||
|
} finally {
|
||||||
|
database.endTransaction();
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressLint("Range")
|
||||||
|
public List<InspectionCheckPoint> findAll( ) {
|
||||||
|
Cursor cursor = database.query( DatabaseHelper.CHECKPOINT_TABLE_NAME,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null);
|
||||||
|
|
||||||
|
List<InspectionCheckPoint> checkPoints = new ArrayList<>();
|
||||||
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
|
do {
|
||||||
|
InspectionCheckPoint checkPoint = new InspectionCheckPoint();
|
||||||
|
checkPoint.setId(cursor.getLong( cursor.getColumnIndex(DatabaseHelper.CHECKPOINT_COLUMN_ID )));
|
||||||
|
checkPoint.setTitle(cursor.getString(cursor.getColumnIndex(DatabaseHelper.CHECKPOINT_COLUMN_TITLE) ));
|
||||||
|
checkPoint.setCategory(cursor.getString(cursor.getColumnIndex(DatabaseHelper.CHECKPOINT_COLUMN_CATEGORY )));
|
||||||
|
checkPoints.add( checkPoint );
|
||||||
|
} while ( cursor.moveToNext() );
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
close();
|
||||||
|
return checkPoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Close the database
|
||||||
|
*/
|
||||||
|
public void close() {
|
||||||
|
dbHelper.close();
|
||||||
|
executorService.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,138 @@
|
||||||
|
package com.utopiaindustries.qualitychecker.db;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
|
|
||||||
|
public class DatabaseHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
|
private static final int DATABASE_VERSION = 1;
|
||||||
|
|
||||||
|
private static final String DATABASE_NAME = "inventory";
|
||||||
|
// Table and columns
|
||||||
|
public static final String PRODUCT_TABLE_NAME = "product";
|
||||||
|
public static final String PRODUCT_COLUMN_ASIN = "asin";
|
||||||
|
public static final String PRODUCT_COLUMN_PARENT_ASIN = "parentAsin";
|
||||||
|
public static final String PRODUCT_COLUMN_MARKETPLACE = "marketplace";
|
||||||
|
public static final String PRODUCT_COLUMN_SKU = "sku";
|
||||||
|
public static final String PRODUCT_COLUMN_TITLE = "title";
|
||||||
|
public static final String PRODUCT_COLUMN_HS_CODE = "hsCode";
|
||||||
|
public static final String PRODUCT_COLUMN_MODEL_NUMBER = "modelNumber";
|
||||||
|
public static final String PRODUCT_COLUMN_ITEM_PER_BOX = "itemPerBox";
|
||||||
|
public static final String PRODUCT_COLUMN_SM_COLOR = "smColor";
|
||||||
|
public static final String PRODUCT_COLUMN_SM_SIZE = "smSize";
|
||||||
|
public static final String PRODUCT_COLUMN_SM_ITEM_NAME = "smItemName";
|
||||||
|
public static final String PRODUCT_COLUMN_ITEM_PER_PACK = "itemPerPack";
|
||||||
|
public static final String PRODUCT_COLUMN_INVENTORY = "inventory";
|
||||||
|
public static final String PRODUCT_COLUMN_CATEGORY = "category";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* dimension table
|
||||||
|
*/
|
||||||
|
public static final String INSPECTION_DIMENSION_TABLE_NAME = "dimension";
|
||||||
|
public static final String DIMENSION_COLUMN_ID = "id";
|
||||||
|
public static final String DIMENSION_COLUMN_TITLE = "title";
|
||||||
|
public static final String DIMENSION_COLUMN_CATEGORY = "category";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* checkpoints table
|
||||||
|
* */
|
||||||
|
public static final String CHECKPOINT_TABLE_NAME = "checkpoint";
|
||||||
|
public static final String CHECKPOINT_COLUMN_ID = "id";
|
||||||
|
public static final String CHECKPOINT_COLUMN_TITLE = "title";
|
||||||
|
public static final String CHECKPOINT_COLUMN_CATEGORY = "category";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* defect table
|
||||||
|
* */
|
||||||
|
public static final String DEFECT_TABLE_NAME = "defect";
|
||||||
|
public static final String DEFECT_COLUMN_DEFECT = "defect";
|
||||||
|
public static final String DEFECT_COLUMN_CATEGORY = "category";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* unit table
|
||||||
|
* */
|
||||||
|
public static final String UNIT_TABLE_NAME = "unit";
|
||||||
|
public static final String UNIT_COLUMN_ID = "id";
|
||||||
|
public static final String UNIT_COLUMN_TITLE = "title";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* report table
|
||||||
|
* */
|
||||||
|
public static final String REPORT_TABLE_NAME = "report";
|
||||||
|
public static final String REPORT_COLUMN_ID = "id";
|
||||||
|
public static final String REPORT_COLUMN_CONTENT = "content";
|
||||||
|
public static final String REPORT_COLUMN_SYNCED = "synced";
|
||||||
|
|
||||||
|
public DatabaseHelper(Context context) {
|
||||||
|
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(SQLiteDatabase db) {
|
||||||
|
// creating product table
|
||||||
|
String CREATE_PRODUCT_TABLE = "CREATE TABLE " + PRODUCT_TABLE_NAME + "("
|
||||||
|
+ PRODUCT_COLUMN_ASIN + " TEXT,"
|
||||||
|
+ PRODUCT_COLUMN_PARENT_ASIN + " TEXT,"
|
||||||
|
+ PRODUCT_COLUMN_MARKETPLACE + " TEXT,"
|
||||||
|
+ PRODUCT_COLUMN_SKU + " TEXT,"
|
||||||
|
+ PRODUCT_COLUMN_TITLE + " TEXT,"
|
||||||
|
+ PRODUCT_COLUMN_HS_CODE + " TEXT,"
|
||||||
|
+ PRODUCT_COLUMN_MODEL_NUMBER + " TEXT,"
|
||||||
|
+ PRODUCT_COLUMN_ITEM_PER_BOX + " INTEGER,"
|
||||||
|
+ PRODUCT_COLUMN_SM_COLOR + " TEXT,"
|
||||||
|
+ PRODUCT_COLUMN_SM_SIZE + " TEXT,"
|
||||||
|
+ PRODUCT_COLUMN_SM_ITEM_NAME + " TEXT,"
|
||||||
|
+ PRODUCT_COLUMN_ITEM_PER_PACK + " INTEGER,"
|
||||||
|
+ PRODUCT_COLUMN_INVENTORY + " INTEGER,"
|
||||||
|
+ PRODUCT_COLUMN_CATEGORY + " TEXT,"
|
||||||
|
+ "PRIMARY KEY (" + PRODUCT_COLUMN_ASIN + ", " + PRODUCT_COLUMN_MARKETPLACE + ", " + PRODUCT_COLUMN_SKU + ")"
|
||||||
|
+ ")";
|
||||||
|
|
||||||
|
|
||||||
|
String CREATE_INSPECTION_DIMENSION_TABLE = "CREATE TABLE " + INSPECTION_DIMENSION_TABLE_NAME + " (" +
|
||||||
|
DIMENSION_COLUMN_ID + " INTEGER PRIMARY KEY," +
|
||||||
|
DIMENSION_COLUMN_TITLE + " TEXT NOT NULL," +
|
||||||
|
DIMENSION_COLUMN_CATEGORY + " TEXT NOT NULL);";
|
||||||
|
|
||||||
|
String CREATE_CHECKPOINT_TABLE = "CREATE TABLE " + CHECKPOINT_TABLE_NAME + " (" +
|
||||||
|
CHECKPOINT_COLUMN_ID + " INTEGER PRIMARY KEY," +
|
||||||
|
CHECKPOINT_COLUMN_TITLE + " TEXT NOT NULL," +
|
||||||
|
CHECKPOINT_COLUMN_CATEGORY + " TEXT NOT NULL);";
|
||||||
|
|
||||||
|
String CREATE_DEFECT_TABLE = "CREATE TABLE " + DEFECT_TABLE_NAME + " (" +
|
||||||
|
DEFECT_COLUMN_DEFECT + " TEXT NOT NULL," +
|
||||||
|
DEFECT_COLUMN_CATEGORY + " TEXT NOT NULL," +
|
||||||
|
"PRIMARY KEY (" + DEFECT_COLUMN_DEFECT + ", " + DEFECT_COLUMN_CATEGORY + ")"
|
||||||
|
+ ")";
|
||||||
|
|
||||||
|
|
||||||
|
String CREATE_UNIT_TABLE = "CREATE TABLE " + UNIT_TABLE_NAME + " (" +
|
||||||
|
UNIT_COLUMN_ID + " INTEGER PRIMARY KEY," +
|
||||||
|
UNIT_COLUMN_TITLE + " TEXT NOT NULL )";
|
||||||
|
|
||||||
|
String CREATE_REPORT_TABLE = "CREATE TABLE " + REPORT_TABLE_NAME + " (" +
|
||||||
|
REPORT_COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
|
||||||
|
REPORT_COLUMN_CONTENT + " TEXT NOT NULL," +
|
||||||
|
REPORT_COLUMN_SYNCED + " INTEGER DEFAULT 0 CHECK(synced IN (0, 1))"
|
||||||
|
+ ")";
|
||||||
|
|
||||||
|
db.execSQL( CREATE_PRODUCT_TABLE );
|
||||||
|
db.execSQL( CREATE_INSPECTION_DIMENSION_TABLE );
|
||||||
|
db.execSQL( CREATE_CHECKPOINT_TABLE );
|
||||||
|
db.execSQL( CREATE_DEFECT_TABLE );
|
||||||
|
db.execSQL( CREATE_UNIT_TABLE );
|
||||||
|
db.execSQL( CREATE_REPORT_TABLE );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
|
db.execSQL( "DROP TABLE IF EXISTS " + PRODUCT_TABLE_NAME);
|
||||||
|
db.execSQL( "DROP TABLE IF EXISTS " + INSPECTION_DIMENSION_TABLE_NAME );
|
||||||
|
db.execSQL( "DROP TABLE IF EXISTS " + CHECKPOINT_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 " + REPORT_TABLE_NAME );
|
||||||
|
onCreate(db);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,82 @@
|
||||||
|
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.InspectionDefect;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
|
public class DefectRepository {
|
||||||
|
|
||||||
|
private final DatabaseHelper dbHelper;
|
||||||
|
private final SQLiteDatabase database;
|
||||||
|
private final ExecutorService executorService;
|
||||||
|
|
||||||
|
public DefectRepository( Context context ) {
|
||||||
|
dbHelper = new DatabaseHelper ( context );
|
||||||
|
database = dbHelper.getWritableDatabase();
|
||||||
|
executorService = Executors.newSingleThreadExecutor();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Insert list of defects in batch
|
||||||
|
* */
|
||||||
|
public void insert( List<InspectionDefect> defects ) {
|
||||||
|
executorService.execute(() -> {
|
||||||
|
database.beginTransaction();
|
||||||
|
try {
|
||||||
|
for ( InspectionDefect defect : defects ) {
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put(DatabaseHelper.DEFECT_COLUMN_DEFECT, defect.getDefect() );
|
||||||
|
values.put(DatabaseHelper.DEFECT_COLUMN_CATEGORY, defect.getCategory() );
|
||||||
|
database.insertWithOnConflict(DatabaseHelper.DEFECT_TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE);
|
||||||
|
}
|
||||||
|
database.setTransactionSuccessful();
|
||||||
|
} finally {
|
||||||
|
database.endTransaction();
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("Range")
|
||||||
|
public List<InspectionDefect> findAll( ) {
|
||||||
|
Cursor cursor = database.query( DatabaseHelper.DEFECT_TABLE_NAME,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null);
|
||||||
|
|
||||||
|
List<InspectionDefect> defects = new ArrayList<>();
|
||||||
|
if ( cursor != null && cursor.moveToFirst() ) {
|
||||||
|
do {
|
||||||
|
InspectionDefect defect = new InspectionDefect();
|
||||||
|
defect.setCategory( cursor.getString( cursor.getColumnIndex(DatabaseHelper.DEFECT_COLUMN_CATEGORY )));
|
||||||
|
defect.setDefect( cursor.getString( cursor.getColumnIndex(DatabaseHelper.DEFECT_COLUMN_DEFECT) ));
|
||||||
|
defects.add( defect );
|
||||||
|
} while ( cursor.moveToNext() );
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
close();
|
||||||
|
return defects;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Close the database
|
||||||
|
*/
|
||||||
|
public void close() {
|
||||||
|
dbHelper.close();
|
||||||
|
executorService.shutdown();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,97 @@
|
||||||
|
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.InspectionDimension;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
|
public class DimensionRepository {
|
||||||
|
|
||||||
|
private final DatabaseHelper dbHelper;
|
||||||
|
private final SQLiteDatabase database;
|
||||||
|
private final ExecutorService executorService;
|
||||||
|
|
||||||
|
public DimensionRepository( Context context ) {
|
||||||
|
dbHelper = new DatabaseHelper ( context );
|
||||||
|
database = dbHelper.getWritableDatabase();
|
||||||
|
executorService = Executors.newSingleThreadExecutor();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Insert list of dimension in batch
|
||||||
|
* */
|
||||||
|
public void insert( List<InspectionDimension> dimensions) {
|
||||||
|
executorService.execute(() -> {
|
||||||
|
database.beginTransaction();
|
||||||
|
try {
|
||||||
|
for ( InspectionDimension dimension : dimensions ) {
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put(DatabaseHelper.DIMENSION_COLUMN_ID, dimension.getId() );
|
||||||
|
values.put(DatabaseHelper.DIMENSION_COLUMN_TITLE, dimension.getTitle() );
|
||||||
|
values.put(DatabaseHelper.DIMENSION_COLUMN_CATEGORY, dimension.getCategory() );
|
||||||
|
database.insertWithOnConflict(DatabaseHelper.INSPECTION_DIMENSION_TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE);
|
||||||
|
}
|
||||||
|
database.setTransactionSuccessful();
|
||||||
|
} finally {
|
||||||
|
database.endTransaction();
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressLint("Range")
|
||||||
|
public List<InspectionDimension> findByCategory(String category) {
|
||||||
|
|
||||||
|
if( category == null ){
|
||||||
|
category = "OTHER";
|
||||||
|
}
|
||||||
|
|
||||||
|
String selection = DatabaseHelper.DIMENSION_COLUMN_CATEGORY + "=?";
|
||||||
|
String[] selectionArgs = {category};
|
||||||
|
|
||||||
|
Cursor cursor = database.query(DatabaseHelper.INSPECTION_DIMENSION_TABLE_NAME,
|
||||||
|
null,
|
||||||
|
selection,
|
||||||
|
selectionArgs,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null);
|
||||||
|
|
||||||
|
List<InspectionDimension> dimensions = new ArrayList<>();
|
||||||
|
|
||||||
|
if ( cursor != null && cursor.moveToFirst() ) {
|
||||||
|
do {
|
||||||
|
InspectionDimension dimension = new InspectionDimension();
|
||||||
|
dimension.setId(cursor.getLong( cursor.getColumnIndex(DatabaseHelper.DIMENSION_COLUMN_ID )));
|
||||||
|
dimension.setTitle(cursor.getString(cursor.getColumnIndex(DatabaseHelper.DIMENSION_COLUMN_TITLE)));
|
||||||
|
dimension.setCategory(cursor.getString(cursor.getColumnIndex(DatabaseHelper.DIMENSION_COLUMN_CATEGORY)));
|
||||||
|
dimensions.add( dimension );
|
||||||
|
} while ( cursor.moveToNext() );
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if ( dimensions.isEmpty() && !"OTHER".equalsIgnoreCase( category ) ) {
|
||||||
|
return findByCategory( "OTHER" );
|
||||||
|
}
|
||||||
|
close();
|
||||||
|
return dimensions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Close the database
|
||||||
|
*/
|
||||||
|
public void close() {
|
||||||
|
dbHelper.close();
|
||||||
|
executorService.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,82 @@
|
||||||
|
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.ItemUnit;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
|
public class ItemRepository {
|
||||||
|
|
||||||
|
private final DatabaseHelper dbHelper;
|
||||||
|
private final SQLiteDatabase database;
|
||||||
|
private final ExecutorService executorService;
|
||||||
|
|
||||||
|
public ItemRepository( Context context ) {
|
||||||
|
dbHelper = new DatabaseHelper ( context );
|
||||||
|
database = dbHelper.getWritableDatabase();
|
||||||
|
executorService = Executors.newSingleThreadExecutor();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Insert list of unit in batch
|
||||||
|
* */
|
||||||
|
public void insert( List<ItemUnit> units ) {
|
||||||
|
executorService.execute(() -> {
|
||||||
|
database.beginTransaction();
|
||||||
|
try {
|
||||||
|
for ( ItemUnit unit : units ) {
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put(DatabaseHelper.UNIT_COLUMN_ID, unit.getId() );
|
||||||
|
values.put(DatabaseHelper.UNIT_COLUMN_TITLE, unit.getTitle() );
|
||||||
|
database.insertWithOnConflict(DatabaseHelper.UNIT_TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE );
|
||||||
|
}
|
||||||
|
database.setTransactionSuccessful();
|
||||||
|
} finally {
|
||||||
|
database.endTransaction();
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("Range")
|
||||||
|
public List<ItemUnit> findAll( ) {
|
||||||
|
Cursor cursor = database.query( DatabaseHelper.UNIT_TABLE_NAME,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null);
|
||||||
|
|
||||||
|
List<ItemUnit> units = new ArrayList<>();
|
||||||
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
|
do {
|
||||||
|
ItemUnit unit = new ItemUnit();
|
||||||
|
unit.setId(cursor.getLong( cursor.getColumnIndex(DatabaseHelper.UNIT_COLUMN_ID )));
|
||||||
|
unit.setTitle(cursor.getString(cursor.getColumnIndex(DatabaseHelper.UNIT_COLUMN_TITLE) ));
|
||||||
|
units.add( unit );
|
||||||
|
} while ( cursor.moveToNext() );
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
close();
|
||||||
|
return units;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Close the database
|
||||||
|
*/
|
||||||
|
public void close() {
|
||||||
|
dbHelper.close();
|
||||||
|
executorService.shutdown();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,181 @@
|
||||||
|
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 java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
|
import com.utopiaindustries.qualitychecker.models.Product;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ProductRepository {
|
||||||
|
|
||||||
|
private final DatabaseHelper dbHelper;
|
||||||
|
private final SQLiteDatabase database;
|
||||||
|
private final ExecutorService executorService;
|
||||||
|
|
||||||
|
|
||||||
|
public ProductRepository( Context context ) {
|
||||||
|
dbHelper = new DatabaseHelper ( context );
|
||||||
|
database = dbHelper.getWritableDatabase();
|
||||||
|
executorService = Executors.newSingleThreadExecutor();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Insert list of products in batch
|
||||||
|
* */
|
||||||
|
public void insert( List<Product> products) {
|
||||||
|
executorService.execute(() -> {
|
||||||
|
database.beginTransaction();
|
||||||
|
try {
|
||||||
|
for (Product product : products) {
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put(DatabaseHelper.PRODUCT_COLUMN_ASIN, product.getAsin());
|
||||||
|
values.put(DatabaseHelper.PRODUCT_COLUMN_PARENT_ASIN, product.getParentAsin());
|
||||||
|
values.put(DatabaseHelper.PRODUCT_COLUMN_MARKETPLACE, product.getMarketplace());
|
||||||
|
values.put(DatabaseHelper.PRODUCT_COLUMN_SKU, product.getSku());
|
||||||
|
values.put(DatabaseHelper.PRODUCT_COLUMN_TITLE, product.getTitle());
|
||||||
|
values.put(DatabaseHelper.PRODUCT_COLUMN_HS_CODE, product.getHsCode());
|
||||||
|
values.put(DatabaseHelper.PRODUCT_COLUMN_MODEL_NUMBER, product.getModelNumber());
|
||||||
|
values.put(DatabaseHelper.PRODUCT_COLUMN_ITEM_PER_BOX, product.getItemPerBox());
|
||||||
|
values.put(DatabaseHelper.PRODUCT_COLUMN_SM_COLOR, product.getSmColor());
|
||||||
|
values.put(DatabaseHelper.PRODUCT_COLUMN_SM_SIZE, product.getSmSize());
|
||||||
|
values.put(DatabaseHelper.PRODUCT_COLUMN_SM_ITEM_NAME, product.getSmItemName());
|
||||||
|
values.put(DatabaseHelper.PRODUCT_COLUMN_ITEM_PER_PACK, product.getItemPerPack());
|
||||||
|
values.put(DatabaseHelper.PRODUCT_COLUMN_INVENTORY, product.getInventory());
|
||||||
|
values.put(DatabaseHelper.PRODUCT_COLUMN_CATEGORY, product.getCategory());
|
||||||
|
database.insertWithOnConflict(DatabaseHelper.PRODUCT_TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE);
|
||||||
|
}
|
||||||
|
database.setTransactionSuccessful();
|
||||||
|
} finally {
|
||||||
|
database.endTransaction();
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* insert single product
|
||||||
|
* */
|
||||||
|
public void insert(Product product) {
|
||||||
|
executorService.execute(() -> {
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put(DatabaseHelper.PRODUCT_COLUMN_ASIN, product.getAsin());
|
||||||
|
values.put(DatabaseHelper.PRODUCT_COLUMN_PARENT_ASIN, product.getParentAsin());
|
||||||
|
values.put(DatabaseHelper.PRODUCT_COLUMN_MARKETPLACE, product.getMarketplace());
|
||||||
|
values.put(DatabaseHelper.PRODUCT_COLUMN_SKU, product.getSku());
|
||||||
|
values.put(DatabaseHelper.PRODUCT_COLUMN_TITLE, product.getTitle());
|
||||||
|
values.put(DatabaseHelper.PRODUCT_COLUMN_HS_CODE, product.getHsCode());
|
||||||
|
values.put(DatabaseHelper.PRODUCT_COLUMN_MODEL_NUMBER, product.getModelNumber());
|
||||||
|
values.put(DatabaseHelper.PRODUCT_COLUMN_ITEM_PER_BOX, product.getItemPerBox());
|
||||||
|
values.put(DatabaseHelper.PRODUCT_COLUMN_SM_COLOR, product.getSmColor());
|
||||||
|
values.put(DatabaseHelper.PRODUCT_COLUMN_SM_SIZE, product.getSmSize());
|
||||||
|
values.put(DatabaseHelper.PRODUCT_COLUMN_SM_ITEM_NAME, product.getSmItemName());
|
||||||
|
values.put(DatabaseHelper.PRODUCT_COLUMN_ITEM_PER_PACK, product.getItemPerPack());
|
||||||
|
values.put(DatabaseHelper.PRODUCT_COLUMN_INVENTORY, product.getInventory());
|
||||||
|
values.put(DatabaseHelper.PRODUCT_COLUMN_CATEGORY, product.getCategory());
|
||||||
|
|
||||||
|
database.insertWithOnConflict(DatabaseHelper.PRODUCT_TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE);
|
||||||
|
close();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieve product by sku
|
||||||
|
* */
|
||||||
|
@SuppressLint("Range")
|
||||||
|
public List<Product> getProductBySku(String sku) {
|
||||||
|
String selection = DatabaseHelper.PRODUCT_COLUMN_SKU + "=?";
|
||||||
|
String[] selectionArgs = {sku};
|
||||||
|
|
||||||
|
Cursor cursor = database.query(DatabaseHelper.PRODUCT_TABLE_NAME,
|
||||||
|
null,
|
||||||
|
selection,
|
||||||
|
selectionArgs,
|
||||||
|
null, null, null);
|
||||||
|
|
||||||
|
List<Product> products = new ArrayList<>();
|
||||||
|
|
||||||
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
|
do {
|
||||||
|
Product product = new Product();
|
||||||
|
product.setAsin(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_ASIN)));
|
||||||
|
product.setParentAsin(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_PARENT_ASIN)));
|
||||||
|
product.setMarketplace(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_MARKETPLACE)));
|
||||||
|
product.setSku(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_SKU)));
|
||||||
|
product.setTitle(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_TITLE)));
|
||||||
|
product.setHsCode(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_HS_CODE)));
|
||||||
|
product.setModelNumber(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_MODEL_NUMBER)));
|
||||||
|
product.setItemPerBox(cursor.getLong(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_ITEM_PER_BOX)));
|
||||||
|
product.setSmColor(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_SM_COLOR)));
|
||||||
|
product.setSmSize(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_SM_SIZE)));
|
||||||
|
product.setSmItemName(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_SM_ITEM_NAME)));
|
||||||
|
product.setItemPerPack(cursor.getLong(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_ITEM_PER_PACK)));
|
||||||
|
product.setInventory(cursor.getLong(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_INVENTORY)));
|
||||||
|
product.setCategory(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_CATEGORY)));
|
||||||
|
|
||||||
|
products.add( product );
|
||||||
|
} while ( cursor.moveToNext() );
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
close();
|
||||||
|
return products;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieve products
|
||||||
|
* */
|
||||||
|
@SuppressLint("Range")
|
||||||
|
public Product getProduct(String asin, String marketplace, String sku) {
|
||||||
|
String selection = DatabaseHelper.PRODUCT_COLUMN_ASIN + "=? AND " +
|
||||||
|
DatabaseHelper.PRODUCT_COLUMN_MARKETPLACE + "=? AND " +
|
||||||
|
DatabaseHelper.PRODUCT_COLUMN_SKU + "=?";
|
||||||
|
String[] selectionArgs = {asin, marketplace, sku};
|
||||||
|
|
||||||
|
Cursor cursor = database.query(DatabaseHelper.PRODUCT_TABLE_NAME,
|
||||||
|
null,
|
||||||
|
selection,
|
||||||
|
selectionArgs,
|
||||||
|
null, null, null);
|
||||||
|
|
||||||
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
|
Product product = new Product();
|
||||||
|
product.setAsin( cursor.getString( cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_ASIN ) ));
|
||||||
|
product.setParentAsin( cursor.getString( cursor.getColumnIndex( DatabaseHelper.PRODUCT_COLUMN_PARENT_ASIN ) ));
|
||||||
|
product.setMarketplace( cursor.getString( cursor.getColumnIndex( DatabaseHelper.PRODUCT_COLUMN_MARKETPLACE )));
|
||||||
|
product.setSku(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_SKU)));
|
||||||
|
product.setTitle(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_TITLE)));
|
||||||
|
product.setHsCode(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_HS_CODE)));
|
||||||
|
product.setModelNumber(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_MODEL_NUMBER)));
|
||||||
|
product.setItemPerBox(cursor.getLong(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_ITEM_PER_BOX)));
|
||||||
|
product.setSmColor(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_SM_COLOR)));
|
||||||
|
product.setSmSize(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_SM_SIZE)));
|
||||||
|
product.setSmItemName(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_SM_ITEM_NAME)));
|
||||||
|
product.setItemPerPack(cursor.getLong(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_ITEM_PER_PACK)));
|
||||||
|
product.setInventory(cursor.getLong(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_INVENTORY)));
|
||||||
|
product.setCategory(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_CATEGORY)));
|
||||||
|
|
||||||
|
cursor.close();
|
||||||
|
close();
|
||||||
|
return product;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cursor != null) {
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Close the database
|
||||||
|
*/
|
||||||
|
public void close() {
|
||||||
|
dbHelper.close();
|
||||||
|
executorService.shutdown();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,129 @@
|
||||||
|
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.InspectionReportWrapper;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.RejectedExecutionException;
|
||||||
|
|
||||||
|
public class ReportRepository {
|
||||||
|
|
||||||
|
private final DatabaseHelper dbHelper;
|
||||||
|
private SQLiteDatabase database;
|
||||||
|
private final ExecutorService executorService;
|
||||||
|
|
||||||
|
public ReportRepository(Context context) {
|
||||||
|
dbHelper = new DatabaseHelper(context);
|
||||||
|
executorService = Executors.newSingleThreadExecutor();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openDatabase() {
|
||||||
|
if (database == null || !database.isOpen()) {
|
||||||
|
database = dbHelper.getWritableDatabase();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void insert(InspectionReportWrapper wrapper) {
|
||||||
|
executeSafely(() -> {
|
||||||
|
openDatabase();
|
||||||
|
database.beginTransaction();
|
||||||
|
try {
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put(DatabaseHelper.REPORT_COLUMN_CONTENT, wrapper.getContent());
|
||||||
|
values.put(DatabaseHelper.REPORT_COLUMN_SYNCED, wrapper.isSynced());
|
||||||
|
database.insertWithOnConflict(DatabaseHelper.REPORT_TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE);
|
||||||
|
database.setTransactionSuccessful();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
database.endTransaction();
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateSyncStatus(long id) {
|
||||||
|
executeSafely(() -> {
|
||||||
|
openDatabase();
|
||||||
|
database.beginTransaction();
|
||||||
|
try {
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put(DatabaseHelper.REPORT_COLUMN_SYNCED, true ); // Set the synced value to true
|
||||||
|
String whereClause = DatabaseHelper.REPORT_COLUMN_ID + " = ?";
|
||||||
|
String[] whereArgs = {String.valueOf(id)};
|
||||||
|
database.update(DatabaseHelper.REPORT_TABLE_NAME, values, whereClause, whereArgs);
|
||||||
|
database.setTransactionSuccessful();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
database.endTransaction();
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("Range")
|
||||||
|
public List<InspectionReportWrapper> findAllUnsynced() {
|
||||||
|
List<InspectionReportWrapper> reports = new ArrayList<>();
|
||||||
|
openDatabase();
|
||||||
|
String selection = DatabaseHelper.REPORT_COLUMN_SYNCED + " = ?";
|
||||||
|
String[] selectionArgs = {"0"};
|
||||||
|
|
||||||
|
try (Cursor cursor = database.query(DatabaseHelper.REPORT_TABLE_NAME,
|
||||||
|
null,
|
||||||
|
selection,
|
||||||
|
selectionArgs,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null)) {
|
||||||
|
|
||||||
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
|
do {
|
||||||
|
InspectionReportWrapper wrapper = new InspectionReportWrapper();
|
||||||
|
wrapper.setId(cursor.getLong(cursor.getColumnIndex(DatabaseHelper.REPORT_COLUMN_ID)));
|
||||||
|
wrapper.setContent(cursor.getString(cursor.getColumnIndex(DatabaseHelper.REPORT_COLUMN_CONTENT)));
|
||||||
|
wrapper.setSynced(cursor.getInt(cursor.getColumnIndex(DatabaseHelper.REPORT_COLUMN_SYNCED)) == 1);
|
||||||
|
reports.add(wrapper);
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
return reports;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Close the database when all operations are complete
|
||||||
|
*/
|
||||||
|
public void close() {
|
||||||
|
if (database != null && database.isOpen()) {
|
||||||
|
database.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Executes a task safely, ensuring the ExecutorService is still active
|
||||||
|
*/
|
||||||
|
private void executeSafely(Runnable task) {
|
||||||
|
try {
|
||||||
|
if (!executorService.isShutdown()) {
|
||||||
|
executorService.submit(task);
|
||||||
|
} else {
|
||||||
|
// Handle the situation when the executor is already shut down
|
||||||
|
System.err.println("Task execution rejected because ExecutorService is shut down");
|
||||||
|
}
|
||||||
|
} catch (RejectedExecutionException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,10 @@
|
||||||
package com.utopiaindustries.qualitychecker.models;
|
package com.utopiaindustries.qualitychecker.models;
|
||||||
|
|
||||||
public class Dimension {
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class Dimension implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private String type;
|
private String type;
|
||||||
private float actual;
|
private float actual;
|
||||||
private float required;
|
private float required;
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
package com.utopiaindustries.qualitychecker.models;
|
package com.utopiaindustries.qualitychecker.models;
|
||||||
|
|
||||||
|
|
||||||
public class InspectionCheckPoint {
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class InspectionCheckPoint implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private long id;
|
private long id;
|
||||||
private String title;
|
private String title;
|
||||||
private String category;
|
private String category;
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
package com.utopiaindustries.qualitychecker.models;
|
package com.utopiaindustries.qualitychecker.models;
|
||||||
|
|
||||||
public class InspectionDefect {
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class InspectionDefect implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private String category;
|
private String category;
|
||||||
private String defect;
|
private String defect;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package com.utopiaindustries.qualitychecker.models;
|
package com.utopiaindustries.qualitychecker.models;
|
||||||
|
|
||||||
public class InspectionDimension {
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class InspectionDimension implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private long id;
|
private long id;
|
||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
package com.utopiaindustries.qualitychecker.models;
|
package com.utopiaindustries.qualitychecker.models;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class InspectionItemCheckPoint {
|
public class InspectionItemCheckPoint implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private long id;
|
private long id;
|
||||||
private long inspectionItemId;
|
private long inspectionItemId;
|
||||||
private String title;
|
private String title;
|
||||||
|
@ -118,6 +122,7 @@ public class InspectionItemCheckPoint {
|
||||||
this.quantities = quantities;
|
this.quantities = quantities;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "InspectionItemCheckPoint{" +
|
return "InspectionItemCheckPoint{" +
|
||||||
|
@ -126,9 +131,13 @@ public class InspectionItemCheckPoint {
|
||||||
", title='" + title + '\'' +
|
", title='" + title + '\'' +
|
||||||
", checked=" + checked +
|
", checked=" + checked +
|
||||||
", remarks='" + remarks + '\'' +
|
", remarks='" + remarks + '\'' +
|
||||||
|
", defectSeverites=" + defectSeverites +
|
||||||
|
", defectTitles=" + defectTitles +
|
||||||
|
", quantities=" + quantities +
|
||||||
", defects=" + defects +
|
", defects=" + defects +
|
||||||
", file=" + Arrays.toString(file) +
|
", file=" + Arrays.toString(file) +
|
||||||
", imagePath='" + imagePath + '\'' +
|
", imagePath='" + imagePath + '\'' +
|
||||||
|
", uuid=" + uuid +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package com.utopiaindustries.qualitychecker.models;
|
package com.utopiaindustries.qualitychecker.models;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class InspectionItemDefect {
|
public class InspectionItemDefect implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private long id;
|
private long id;
|
||||||
private long cpId;
|
private long cpId;
|
||||||
private String title;
|
private String title;
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
package com.utopiaindustries.qualitychecker.models;
|
package com.utopiaindustries.qualitychecker.models;
|
||||||
|
|
||||||
|
|
||||||
public class InspectionItemDimension {
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class InspectionItemDimension implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private long id;
|
private long id;
|
||||||
private long inspectionItemId;
|
private long inspectionItemId;
|
||||||
private String type;
|
private String type;
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
package com.utopiaindustries.qualitychecker.models;
|
package com.utopiaindustries.qualitychecker.models;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class InspectionReport {
|
public class InspectionReport implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private long id;
|
private long id;
|
||||||
private boolean fri;
|
private boolean fri;
|
||||||
|
@ -20,6 +23,9 @@ public class InspectionReport {
|
||||||
// wrapper
|
// wrapper
|
||||||
List<InspectionReportItem> items;
|
List<InspectionReportItem> items;
|
||||||
|
|
||||||
|
private String filePath;
|
||||||
|
private long wrapperId;
|
||||||
|
|
||||||
public InspectionReport(){
|
public InspectionReport(){
|
||||||
this.fri = true;
|
this.fri = true;
|
||||||
}
|
}
|
||||||
|
@ -120,14 +126,30 @@ public class InspectionReport {
|
||||||
this.fri = fri;
|
this.fri = fri;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
public long getWrapperId() {
|
||||||
|
return wrapperId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWrapperId(long wrapperId) {
|
||||||
|
this.wrapperId = wrapperId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFilePath() {
|
||||||
|
return filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFilePath(String filePath) {
|
||||||
|
this.filePath = filePath;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "InspectionReport{" +
|
return "InspectionReport{" +
|
||||||
"id=" + id +
|
"id=" + id +
|
||||||
|
", fri=" + fri +
|
||||||
", code='" + code + '\'' +
|
", code='" + code + '\'' +
|
||||||
", generatedBy='" + generatedBy + '\'' +
|
", generatedBy='" + generatedBy + '\'' +
|
||||||
", generatedAt=" + generatedAt +
|
", generatedAt='" + generatedAt + '\'' +
|
||||||
", siteId=" + siteId +
|
", siteId=" + siteId +
|
||||||
", floorId=" + floorId +
|
", floorId=" + floorId +
|
||||||
", departmentId=" + departmentId +
|
", departmentId=" + departmentId +
|
||||||
|
@ -135,6 +157,7 @@ public class InspectionReport {
|
||||||
", generalRemarks='" + generalRemarks + '\'' +
|
", generalRemarks='" + generalRemarks + '\'' +
|
||||||
", reportResult='" + reportResult + '\'' +
|
", reportResult='" + reportResult + '\'' +
|
||||||
", items=" + items +
|
", items=" + items +
|
||||||
|
", wrapperId=" + wrapperId +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,10 +2,12 @@ package com.utopiaindustries.qualitychecker.models;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class InspectionReportItem {
|
public class InspectionReportItem implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private long id;
|
private long id;
|
||||||
private long reportId;
|
private long reportId;
|
||||||
private String asin;
|
private String asin;
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
package com.utopiaindustries.qualitychecker.models;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class InspectionReportWrapper {
|
||||||
|
|
||||||
|
public InspectionReportWrapper() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public InspectionReportWrapper(long id, String content, boolean synced) {
|
||||||
|
this.id = id;
|
||||||
|
this.content = content;
|
||||||
|
this.synced = synced;
|
||||||
|
}
|
||||||
|
|
||||||
|
private long id;
|
||||||
|
private String content;
|
||||||
|
private boolean synced;
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContent() {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContent(String content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSynced() {
|
||||||
|
return synced;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSynced(boolean synced) {
|
||||||
|
this.synced = synced;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
InspectionReportWrapper that = (InspectionReportWrapper) o;
|
||||||
|
return id == that.id && synced == that.synced && Objects.equals(content, that.content);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id, content, synced);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "InspectionReportWrapper{" +
|
||||||
|
"id=" + id +
|
||||||
|
", content='" + content + '\'' +
|
||||||
|
", synced=" + synced +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,10 @@
|
||||||
package com.utopiaindustries.qualitychecker.models;
|
package com.utopiaindustries.qualitychecker.models;
|
||||||
|
|
||||||
public class ItemUnit {
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class ItemUnit implements Serializable {
|
||||||
private long id;
|
private long id;
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
public ItemUnit() {
|
public ItemUnit() {
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package com.utopiaindustries.qualitychecker.models;
|
package com.utopiaindustries.qualitychecker.models;
|
||||||
|
|
||||||
public class Product {
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class Product implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private String asin;
|
private String asin;
|
||||||
private String parentAsin;
|
private String parentAsin;
|
||||||
private String marketplace;
|
private String marketplace;
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
package com.utopiaindustries.qualitychecker.models;
|
|
||||||
|
|
||||||
public interface SaveReportCallback {
|
|
||||||
void onSuccess();
|
|
||||||
void onFailure(Throwable throwable);
|
|
||||||
}
|
|
|
@ -1,6 +1,9 @@
|
||||||
package com.utopiaindustries.qualitychecker.models;
|
package com.utopiaindustries.qualitychecker.models;
|
||||||
|
|
||||||
public class VoiceOfCustomer {
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class VoiceOfCustomer implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private String mskus;
|
private String mskus;
|
||||||
private String marketplace;
|
private String marketplace;
|
||||||
private String itemName;
|
private String itemName;
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
package com.utopiaindustries.qualitychecker.models.callback;
|
||||||
|
|
||||||
|
public interface SaveCallback {
|
||||||
|
void onSuccess();
|
||||||
|
void onFailure(Throwable throwable);
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
package com.utopiaindustries.qualitychecker.models.callback;
|
||||||
|
|
||||||
|
public interface SaveCheckpointCallback extends SaveCallback {
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
package com.utopiaindustries.qualitychecker.models.callback;
|
||||||
|
|
||||||
|
public interface SaveDefectCallback extends SaveCallback{
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
package com.utopiaindustries.qualitychecker.models.callback;
|
||||||
|
|
||||||
|
public interface SaveDimensionCallback extends SaveCallback {
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
package com.utopiaindustries.qualitychecker.models.callback;
|
||||||
|
|
||||||
|
public interface SaveItemCallback extends SaveCallback{
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package com.utopiaindustries.qualitychecker.models.callback;
|
||||||
|
|
||||||
|
public interface SaveProductCallBack extends SaveCallback {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
package com.utopiaindustries.qualitychecker.models.callback;
|
||||||
|
|
||||||
|
public interface SaveReportCallback extends SaveCallback{
|
||||||
|
}
|
|
@ -13,6 +13,10 @@ public class NotificationHelper {
|
||||||
private static final String CHANNEL_ID = "001122";
|
private static final String CHANNEL_ID = "001122";
|
||||||
private static final String CHANNEL_NAME = "QA_App_Channel";
|
private static final String CHANNEL_NAME = "QA_App_Channel";
|
||||||
private static final String CHANNEL_DESCRIPTION = "Channel_for_qa_app";
|
private static final String CHANNEL_DESCRIPTION = "Channel_for_qa_app";
|
||||||
|
private static final String PRODUCT_CHANNEL_ID = "6754631";
|
||||||
|
private static final String PRODUCT_CHANNEL_NAME= "PRODUCT_NOTIFICATION_CHANNEL";
|
||||||
|
public static final String PRODUCT_CHANNEL_DESCRIPTION = "CHANNEL_FOR_PRODUCT";
|
||||||
|
|
||||||
|
|
||||||
public static void showNotification(Context context, String title, String message) {
|
public static void showNotification(Context context, String title, String message) {
|
||||||
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
@ -34,4 +38,25 @@ public class NotificationHelper {
|
||||||
// Show the notification
|
// Show the notification
|
||||||
notificationManager.notify(0, builder.build());
|
notificationManager.notify(0, builder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void showProductNotification(Context context, String title, String message) {
|
||||||
|
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
|
||||||
|
// Create a notification channel for devices running Android Oreo (API 26) and higher
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
NotificationChannel channel = new NotificationChannel(PRODUCT_CHANNEL_ID, PRODUCT_CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT);
|
||||||
|
channel.setDescription(PRODUCT_CHANNEL_DESCRIPTION);
|
||||||
|
notificationManager.createNotificationChannel(channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build the notification
|
||||||
|
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, PRODUCT_CHANNEL_ID)
|
||||||
|
.setSmallIcon(R.drawable.utopia_svg_logo) // Set your notification icon here
|
||||||
|
.setContentTitle(title)
|
||||||
|
.setContentText(message)
|
||||||
|
.setPriority(NotificationCompat.PRIORITY_HIGH );
|
||||||
|
|
||||||
|
// Show the notification
|
||||||
|
notificationManager.notify(0, builder.build());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.utopiaindustries.qualitychecker.receiver;
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.ConnectivityManager;
|
||||||
|
import android.net.NetworkInfo;
|
||||||
|
|
||||||
|
import com.utopiaindustries.qualitychecker.db.ReportRepository;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.InspectionReport;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.InspectionReportWrapper;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.callback.SaveReportCallback;
|
||||||
|
import com.utopiaindustries.qualitychecker.service.InspectionReportService;
|
||||||
|
import com.utopiaindustries.qualitychecker.service.NetworkService;
|
||||||
|
import com.utopiaindustries.qualitychecker.utils.FileUtils;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class NetworkReceiver extends BroadcastReceiver {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
|
||||||
|
boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting();
|
||||||
|
Intent serviceIntent = new Intent( context, NetworkService.class );
|
||||||
|
context.startService(serviceIntent);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,22 +1,46 @@
|
||||||
package com.utopiaindustries.qualitychecker.service;
|
package com.utopiaindustries.qualitychecker.service;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
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.db.CheckpointRepository;
|
||||||
|
import com.utopiaindustries.qualitychecker.db.DefectRepository;
|
||||||
|
import com.utopiaindustries.qualitychecker.db.DimensionRepository;
|
||||||
|
import com.utopiaindustries.qualitychecker.db.ItemRepository;
|
||||||
|
import com.utopiaindustries.qualitychecker.db.ProductRepository;
|
||||||
|
import com.utopiaindustries.qualitychecker.db.ReportRepository;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.InspectionCheckPoint;
|
||||||
import com.utopiaindustries.qualitychecker.models.InspectionDefect;
|
import com.utopiaindustries.qualitychecker.models.InspectionDefect;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.InspectionDimension;
|
||||||
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.InspectionReportWrapper;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.ItemUnit;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.Product;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.callback.SaveCheckpointCallback;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.callback.SaveDefectCallback;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.callback.SaveDimensionCallback;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.callback.SaveItemCallback;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.callback.SaveProductCallBack;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.callback.SaveReportCallback;
|
||||||
import com.utopiaindustries.qualitychecker.store.Store;
|
import com.utopiaindustries.qualitychecker.store.Store;
|
||||||
|
import com.utopiaindustries.qualitychecker.utils.FileUtils;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
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;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.logging.Handler;
|
|
||||||
|
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
@ -44,7 +68,7 @@ public class InspectionReportService {
|
||||||
apiService = ApiServiceFactory.getApiService();
|
apiService = ApiServiceFactory.getApiService();
|
||||||
defectTypes = Arrays.asList( "CRITICAL","MINOR","MAJOR" );
|
defectTypes = Arrays.asList( "CRITICAL","MINOR","MAJOR" );
|
||||||
dimensionTypes = Arrays.asList( "LENGTH", "WIDTH", "DROP" );
|
dimensionTypes = Arrays.asList( "LENGTH", "WIDTH", "DROP" );
|
||||||
reportResult = Arrays.asList("PASSED","FAILED");
|
reportResult = Arrays.asList("PASSED","FAILED","ON_HOLD");
|
||||||
store = Store.getInstance();
|
store = Store.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +110,7 @@ public class InspectionReportService {
|
||||||
this.reportResult = reportResult;
|
this.reportResult = reportResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateDefectsInBackground(InspectionReport inspectionReport) {
|
private synchronized void populateDefectsInBackground(InspectionReport inspectionReport) {
|
||||||
for (InspectionItemCheckPoint itemCp : inspectionReport.getItems().get(0).getCheckPoints()) {
|
for (InspectionItemCheckPoint itemCp : inspectionReport.getItems().get(0).getCheckPoints()) {
|
||||||
List<InspectionItemDefect> defectList = getInspectionItemDefects(itemCp);
|
List<InspectionItemDefect> defectList = getInspectionItemDefects(itemCp);
|
||||||
itemCp.setDefects(defectList);
|
itemCp.setDefects(defectList);
|
||||||
|
@ -122,49 +146,62 @@ public class InspectionReportService {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private synchronized void saveReportInDb( final Context context,
|
||||||
|
final InspectionReport inspectionReport,
|
||||||
|
final SaveReportCallback callback) throws IOException {
|
||||||
|
try {
|
||||||
|
// convert into byte array
|
||||||
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||||
|
ObjectOutputStream objectOutputStream = new ObjectOutputStream( byteArrayOutputStream );
|
||||||
|
objectOutputStream.writeObject( inspectionReport );
|
||||||
|
objectOutputStream.flush();
|
||||||
|
byte[] bytes = byteArrayOutputStream.toByteArray();
|
||||||
|
// write bytes in file
|
||||||
|
long epochSeconds = System.currentTimeMillis() / 1000;
|
||||||
|
String fileName = "Report-" + epochSeconds + ".bin";
|
||||||
|
String savedPath = FileUtils.writeFile( context, bytes, fileName );
|
||||||
|
System.out.println( savedPath );
|
||||||
|
new ReportRepository( context ).insert(
|
||||||
|
new InspectionReportWrapper( 0, savedPath, false )
|
||||||
|
);
|
||||||
|
callback.onSuccess();
|
||||||
|
} catch ( Exception e ){
|
||||||
|
callback.onFailure( new Exception( "Failed to Save in DB" ) );
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void saveReport(InspectionReport inspectionReport , SaveReportCallback callback){
|
|
||||||
|
|
||||||
|
|
||||||
|
public void saveInLocalDb( Context context,
|
||||||
|
InspectionReport inspectionReport ,
|
||||||
|
SaveReportCallback callback ){
|
||||||
if( Objects.nonNull( inspectionReport ) && inspectionReport.getItems().get(0).getSku() != null && inspectionReport.getItems() != null &&
|
if( Objects.nonNull( inspectionReport ) && inspectionReport.getItems().get(0).getSku() != null && inspectionReport.getItems() != null &&
|
||||||
! inspectionReport.getItems().isEmpty() &&
|
! inspectionReport.getItems().isEmpty() &&
|
||||||
! inspectionReport.getItems().get(0).getCheckPoints().isEmpty() ){
|
! inspectionReport.getItems().get(0).getCheckPoints().isEmpty() ){
|
||||||
|
new Thread(() -> {
|
||||||
|
populateDefectsInBackground( inspectionReport );
|
||||||
|
//post report
|
||||||
|
try {
|
||||||
|
saveReportInDb( context, inspectionReport , callback );
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveReport(InspectionReport inspectionReport , SaveReportCallback callback){
|
||||||
|
|
||||||
|
if( Objects.nonNull( inspectionReport ) && inspectionReport.getItems().get(0).getSku() != null && inspectionReport.getItems() != null &&
|
||||||
|
! inspectionReport.getItems().isEmpty() &&
|
||||||
|
! inspectionReport.getItems().get(0).getCheckPoints().isEmpty() ){
|
||||||
|
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
populateDefectsInBackground( inspectionReport );
|
populateDefectsInBackground( inspectionReport );
|
||||||
//post report
|
//post report
|
||||||
saveReportInBackground( inspectionReport , callback );
|
saveReportInBackground( inspectionReport , callback );
|
||||||
}).start();
|
}).start();
|
||||||
|
|
||||||
|
|
||||||
// populate defects in cp
|
|
||||||
// for( InspectionItemCheckPoint itemCp : inspectionReport.getItems().get(0).getCheckPoints() ){
|
|
||||||
// List<InspectionItemDefect> defectList = getInspectionItemDefects(itemCp);
|
|
||||||
// itemCp.setDefects( defectList );
|
|
||||||
// }
|
|
||||||
// post object
|
|
||||||
// apiService.saveInspectionReport( inspectionReport ).enqueue(
|
|
||||||
// new Callback<Map<String,String>>() {
|
|
||||||
// @Override
|
|
||||||
// public void onResponse(Call<Map<String,String>> call,
|
|
||||||
// Response<Map<String,String>> response) {
|
|
||||||
// if ( response.isSuccessful() ) {
|
|
||||||
// System.out.println( response.body() );
|
|
||||||
// if( response.body().get("result").equalsIgnoreCase("success")){
|
|
||||||
// callback.onSuccess();
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// callback.onFailure(new Exception( "Error on submitting report" ));
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// callback.onFailure(new Exception("API call failed with status code: " + response.code()));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// @Override
|
|
||||||
// public void onFailure(Call<Map<String,String>> call, Throwable t) {
|
|
||||||
// System.out.println( t );
|
|
||||||
// callback.onFailure( t );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
} else {
|
} else {
|
||||||
callback.onFailure( new Exception("Please Fill the required Fields..") );
|
callback.onFailure( new Exception("Please Fill the required Fields..") );
|
||||||
}
|
}
|
||||||
|
@ -182,4 +219,181 @@ public class InspectionReportService {
|
||||||
}
|
}
|
||||||
return defectList;
|
return defectList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void fetchAndPopulateProducts( SaveProductCallBack callback,
|
||||||
|
ProductRepository repository){
|
||||||
|
new Thread(() -> {
|
||||||
|
populateProducts( callback, repository );
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fetchAndPopulateDimensions( SaveDimensionCallback callback,
|
||||||
|
DimensionRepository repository ){
|
||||||
|
new Thread(() -> {
|
||||||
|
populateDimensions( callback, repository );
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fetchAndPopulateCheckpoints( SaveCheckpointCallback callback ,
|
||||||
|
CheckpointRepository repository ){
|
||||||
|
new Thread(() -> {
|
||||||
|
populateCheckpoints( callback, repository );
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fetchAndPopulateDefects( SaveDefectCallback callback,
|
||||||
|
DefectRepository repository ){
|
||||||
|
new Thread( () -> {
|
||||||
|
populateDefects( callback, repository );
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fetchAndPopulateUnits( SaveItemCallback callback,
|
||||||
|
ItemRepository repository ){
|
||||||
|
new Thread(() -> {
|
||||||
|
populateUnits( callback, repository );
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void populateProducts( SaveProductCallBack callback,
|
||||||
|
ProductRepository repository ){
|
||||||
|
apiService.fetchAllProducts().enqueue(
|
||||||
|
new Callback<List<Product>>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(Call<List<Product>> call,
|
||||||
|
Response<List<Product>> 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<Product>> call, Throwable t) {
|
||||||
|
System.out.println(t);
|
||||||
|
callback.onFailure(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
private void populateDimensions( SaveDimensionCallback callback,
|
||||||
|
DimensionRepository repository ){
|
||||||
|
|
||||||
|
apiService.fetchDimensions( ).enqueue(new Callback<List<InspectionDimension>>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(Call<List<InspectionDimension>> call,
|
||||||
|
Response<List<InspectionDimension>> 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<InspectionDimension>> call, Throwable t) {
|
||||||
|
System.out.println( t );
|
||||||
|
callback.onFailure( t );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void populateCheckpoints( SaveCheckpointCallback callback,
|
||||||
|
CheckpointRepository repository ){
|
||||||
|
|
||||||
|
apiService.fetchCheckPoints().enqueue(
|
||||||
|
new Callback<List<InspectionCheckPoint>>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse( Call<List<InspectionCheckPoint>> call,
|
||||||
|
Response<List<InspectionCheckPoint>> 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<InspectionCheckPoint>> call,
|
||||||
|
Throwable t) {
|
||||||
|
System.out.println( t );
|
||||||
|
callback.onFailure( t );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void populateDefects( SaveDefectCallback callback,
|
||||||
|
DefectRepository repository ){
|
||||||
|
apiService.fetchDefects().enqueue(new Callback<List<InspectionDefect>>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(Call<List<InspectionDefect>> call, Response<List<InspectionDefect>> 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<InspectionDefect>> call, Throwable t) {
|
||||||
|
System.out.println( t );
|
||||||
|
callback.onFailure( t );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void populateUnits( SaveItemCallback callback ,
|
||||||
|
ItemRepository repository ){
|
||||||
|
apiService.fetchItemUnits().enqueue(
|
||||||
|
new Callback<List<ItemUnit>>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse( Call<List<ItemUnit>> call,
|
||||||
|
Response<List<ItemUnit>> 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<ItemUnit>> call,
|
||||||
|
Throwable t) {
|
||||||
|
System.out.println( t );
|
||||||
|
callback.onFailure( t );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,123 @@
|
||||||
|
package com.utopiaindustries.qualitychecker.service;
|
||||||
|
|
||||||
|
import android.app.Service;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.ConnectivityManager;
|
||||||
|
import android.net.NetworkInfo;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.IBinder;
|
||||||
|
import android.util.Log;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.utopiaindustries.qualitychecker.db.ReportRepository;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.InspectionReport;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.InspectionReportWrapper;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.callback.SaveReportCallback;
|
||||||
|
import com.utopiaindustries.qualitychecker.utils.FileUtils;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class NetworkService extends Service {
|
||||||
|
|
||||||
|
private static final String TAG = "NetworkService";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate() {
|
||||||
|
super.onCreate();
|
||||||
|
// Start the connectivity check
|
||||||
|
startCheckingNetwork();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
|
// Handle service start logic if needed
|
||||||
|
return START_STICKY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public IBinder onBind(Intent intent) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startCheckingNetwork() {
|
||||||
|
Handler handler = new Handler();
|
||||||
|
Runnable runnable = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
checkNetworkAndPushData();
|
||||||
|
handler.postDelayed(this, 1 * 60 * 1000); // Check 5 every minute
|
||||||
|
}
|
||||||
|
};
|
||||||
|
handler.post(runnable);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkNetworkAndPushData() {
|
||||||
|
ConnectivityManager cm = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
|
||||||
|
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
|
||||||
|
boolean isConnected = activeNetwork != null && activeNetwork.isConnected();
|
||||||
|
|
||||||
|
if (isConnected) {
|
||||||
|
Log.i(TAG, "Network is available. Pushing data...");
|
||||||
|
// Call your method to push data here
|
||||||
|
pushDataToInternet();
|
||||||
|
} else {
|
||||||
|
Log.i(TAG, "No network available.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void pushDataToInternet() {
|
||||||
|
ReportRepository repository = new ReportRepository( this );
|
||||||
|
List<InspectionReportWrapper> reportWrappers = repository.findAllUnsynced();
|
||||||
|
InspectionReportService service = InspectionReportService.getInstance();
|
||||||
|
try {
|
||||||
|
List<InspectionReport> reports = getReports( reportWrappers );
|
||||||
|
for ( InspectionReport report : reports ){
|
||||||
|
service.saveReport(report, new SaveReportCallback() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess() {
|
||||||
|
// update status
|
||||||
|
repository.updateSyncStatus( report.getWrapperId() );
|
||||||
|
// remove file
|
||||||
|
FileUtils.deleteFile( report.getFilePath() );
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable throwable) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch ( Exception e ) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* map wrapper to reports
|
||||||
|
* */
|
||||||
|
private List<InspectionReport> getReports(List<InspectionReportWrapper> wrappers ) {
|
||||||
|
List<InspectionReport> reports = new ArrayList<>();
|
||||||
|
if( ! wrappers.isEmpty() ){
|
||||||
|
for( InspectionReportWrapper wrapper : wrappers ){
|
||||||
|
try {
|
||||||
|
// get file from path
|
||||||
|
byte[] result = FileUtils.readFile( wrapper.getContent() );
|
||||||
|
ByteArrayInputStream byteIn = new ByteArrayInputStream( result );
|
||||||
|
ObjectInputStream in = new ObjectInputStream(byteIn);
|
||||||
|
InspectionReport report = ( InspectionReport ) in.readObject();
|
||||||
|
report.setWrapperId( wrapper.getId() );
|
||||||
|
report.setFilePath( wrapper.getContent() );
|
||||||
|
reports.add( report );
|
||||||
|
} catch ( Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return reports;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,14 @@
|
||||||
package com.utopiaindustries.qualitychecker.store;
|
package com.utopiaindustries.qualitychecker.store;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
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.CheckpointRepository;
|
||||||
|
import com.utopiaindustries.qualitychecker.db.DefectRepository;
|
||||||
|
import com.utopiaindustries.qualitychecker.db.ItemRepository;
|
||||||
|
import com.utopiaindustries.qualitychecker.db.ProductRepository;
|
||||||
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.InspectionDefect;
|
import com.utopiaindustries.qualitychecker.models.InspectionDefect;
|
||||||
|
@ -12,6 +19,9 @@ import com.utopiaindustries.qualitychecker.models.InspectionReport;
|
||||||
import com.utopiaindustries.qualitychecker.models.InspectionReportItem;
|
import com.utopiaindustries.qualitychecker.models.InspectionReportItem;
|
||||||
import com.utopiaindustries.qualitychecker.models.ItemUnit;
|
import com.utopiaindustries.qualitychecker.models.ItemUnit;
|
||||||
import com.utopiaindustries.qualitychecker.models.Product;
|
import com.utopiaindustries.qualitychecker.models.Product;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.callback.SaveProductCallBack;
|
||||||
|
import com.utopiaindustries.qualitychecker.notification.NotificationHelper;
|
||||||
|
import com.utopiaindustries.qualitychecker.ui.activities.HomeActivity;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -45,7 +55,7 @@ public class Store {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void initializeNewReport() {
|
public synchronized void initializeNewReport( Context context ) {
|
||||||
checkPoints = new ArrayList<>();
|
checkPoints = new ArrayList<>();
|
||||||
defects = new ArrayList<>();
|
defects = new ArrayList<>();
|
||||||
dimensions = new ArrayList<>();
|
dimensions = new ArrayList<>();
|
||||||
|
@ -58,48 +68,45 @@ public class Store {
|
||||||
item.setDimensions( new ArrayList<>() );
|
item.setDimensions( new ArrayList<>() );
|
||||||
report.setItems(Collections.singletonList( item ));
|
report.setItems(Collections.singletonList( item ));
|
||||||
|
|
||||||
apiService.fetchCheckPoints().enqueue(
|
// apiService.fetchCheckPoints().enqueue(
|
||||||
new Callback<List<InspectionCheckPoint>>() {
|
// new Callback<List<InspectionCheckPoint>>() {
|
||||||
@Override
|
// @Override
|
||||||
public void onResponse( Call<List<InspectionCheckPoint>> call,
|
// public void onResponse( Call<List<InspectionCheckPoint>> call,
|
||||||
Response<List<InspectionCheckPoint>> response) {
|
// Response<List<InspectionCheckPoint>> response) {
|
||||||
if( response.isSuccessful() && response.body() != null ){
|
// if( response.isSuccessful() && response.body() != null ){
|
||||||
checkPoints = response.body() ;
|
// checkPoints = response.body() ;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
@Override
|
// @Override
|
||||||
public void onFailure(Call<List<InspectionCheckPoint>> call, Throwable t) {
|
// public void onFailure(Call<List<InspectionCheckPoint>> call, Throwable t) {
|
||||||
System.out.println( t.getMessage() );
|
// System.out.println( t.getMessage() );
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
);
|
// );
|
||||||
|
|
||||||
apiService.fetchDefects().enqueue(
|
CheckpointRepository checkpointRepository = new CheckpointRepository( context );
|
||||||
new Callback<List<InspectionDefect>>() {
|
checkPoints = checkpointRepository.findAll();
|
||||||
@Override
|
|
||||||
public void onResponse( Call<List<InspectionDefect>> call,
|
|
||||||
Response<List<InspectionDefect>> response) {
|
|
||||||
if( response.isSuccessful() && response.body() != null ){
|
|
||||||
defects = response.body();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onFailure( Call<List<InspectionDefect>> call, Throwable t) {
|
|
||||||
System.out.println( t.getMessage() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
|
// apiService.fetchDefects().enqueue(
|
||||||
|
// new Callback<List<InspectionDefect>>() {
|
||||||
|
// @Override
|
||||||
|
// public void onResponse( Call<List<InspectionDefect>> call,
|
||||||
|
// Response<List<InspectionDefect>> response) {
|
||||||
|
// if( response.isSuccessful() && response.body() != null ){
|
||||||
|
// defects = response.body();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// @Override
|
||||||
|
// public void onFailure( Call<List<InspectionDefect>> call, Throwable t) {
|
||||||
|
// System.out.println( t.getMessage() );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
DefectRepository defectRepository = new DefectRepository( context );
|
||||||
|
defects = defectRepository.findAll();
|
||||||
|
|
||||||
apiService.fetchCheckPoints().enqueue(
|
|
||||||
new Callback<List<InspectionCheckPoint>>() {
|
|
||||||
@Override
|
|
||||||
public void onResponse(Call<List<InspectionCheckPoint>> call,
|
|
||||||
Response<List<InspectionCheckPoint>> response) {
|
|
||||||
|
|
||||||
if( response.isSuccessful() && response.body() != null ){
|
|
||||||
List<InspectionItemCheckPoint> itemCp = new ArrayList<>();
|
List<InspectionItemCheckPoint> itemCp = new ArrayList<>();
|
||||||
for( InspectionCheckPoint cp : response.body() ){
|
for( InspectionCheckPoint cp : checkPoints ){
|
||||||
InspectionItemCheckPoint icp = new InspectionItemCheckPoint();
|
InspectionItemCheckPoint icp = new InspectionItemCheckPoint();
|
||||||
icp.setTitle( cp.getTitle() );
|
icp.setTitle( cp.getTitle() );
|
||||||
icp.setChecked( false );
|
icp.setChecked( false );
|
||||||
|
@ -110,33 +117,57 @@ public class Store {
|
||||||
itemCp.add( icp );
|
itemCp.add( icp );
|
||||||
}
|
}
|
||||||
report.getItems().get( 0 ).setCheckPoints( itemCp );
|
report.getItems().get( 0 ).setCheckPoints( itemCp );
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onFailure(Call<List<InspectionCheckPoint>> call, Throwable t) {
|
|
||||||
System.out.println( t.getMessage() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
apiService.fetchItemUnits().enqueue(
|
|
||||||
new Callback<List<ItemUnit>>() {
|
|
||||||
@Override
|
|
||||||
public void onResponse(Call<List<ItemUnit>> call,
|
|
||||||
Response<List<ItemUnit>> response) {
|
|
||||||
if( response.isSuccessful() && response.body() != null ){
|
|
||||||
System.out.println( response.body() );
|
|
||||||
itemUnits = response.body();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Call<List<ItemUnit>> call,
|
// apiService.fetchCheckPoints().enqueue(
|
||||||
Throwable t) {
|
// new Callback<List<InspectionCheckPoint>>() {
|
||||||
System.out.println( t.getMessage() );
|
// @Override
|
||||||
}
|
// public void onResponse(Call<List<InspectionCheckPoint>> call,
|
||||||
}
|
// Response<List<InspectionCheckPoint>> response) {
|
||||||
);
|
//
|
||||||
|
// if( response.isSuccessful() && response.body() != null ){
|
||||||
|
// List<InspectionItemCheckPoint> itemCp = new ArrayList<>();
|
||||||
|
// for( InspectionCheckPoint cp : response.body() ){
|
||||||
|
// InspectionItemCheckPoint icp = new InspectionItemCheckPoint();
|
||||||
|
// icp.setTitle( cp.getTitle() );
|
||||||
|
// icp.setChecked( false );
|
||||||
|
// icp.setRemarks("");
|
||||||
|
// icp.setDefectTitles( new ArrayList<>() );
|
||||||
|
// icp.setDefectSeverites( new ArrayList<>() );
|
||||||
|
// icp.setQuantities( new ArrayList<>() );
|
||||||
|
// itemCp.add( icp );
|
||||||
|
// }
|
||||||
|
// report.getItems().get( 0 ).setCheckPoints( itemCp );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// @Override
|
||||||
|
// public void onFailure(Call<List<InspectionCheckPoint>> call, Throwable t) {
|
||||||
|
// System.out.println( t.getMessage() );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
|
||||||
|
// apiService.fetchItemUnits().enqueue(
|
||||||
|
// new Callback<List<ItemUnit>>() {
|
||||||
|
// @Override
|
||||||
|
// public void onResponse(Call<List<ItemUnit>> call,
|
||||||
|
// Response<List<ItemUnit>> response) {
|
||||||
|
// if( response.isSuccessful() && response.body() != null ){
|
||||||
|
// System.out.println( response.body() );
|
||||||
|
// itemUnits = response.body();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void onFailure(Call<List<ItemUnit>> call,
|
||||||
|
// Throwable t) {
|
||||||
|
// System.out.println( t.getMessage() );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
ItemRepository itemRepository = new ItemRepository( context );
|
||||||
|
itemUnits = itemRepository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public InspectionReport getReport() {
|
public InspectionReport getReport() {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.utopiaindustries.qualitychecker.ui.activities;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
|
@ -26,12 +27,26 @@ 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.db.CheckpointRepository;
|
||||||
|
import com.utopiaindustries.qualitychecker.db.DefectRepository;
|
||||||
|
import com.utopiaindustries.qualitychecker.db.DimensionRepository;
|
||||||
|
import com.utopiaindustries.qualitychecker.db.ItemRepository;
|
||||||
|
import com.utopiaindustries.qualitychecker.db.ProductRepository;
|
||||||
import com.utopiaindustries.qualitychecker.models.EmployeePhoto;
|
import com.utopiaindustries.qualitychecker.models.EmployeePhoto;
|
||||||
import com.utopiaindustries.qualitychecker.models.InspectionReport;
|
import com.utopiaindustries.qualitychecker.models.InspectionReport;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.callback.SaveCheckpointCallback;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.callback.SaveDefectCallback;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.callback.SaveDimensionCallback;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.callback.SaveItemCallback;
|
||||||
|
import com.utopiaindustries.qualitychecker.models.callback.SaveProductCallBack;
|
||||||
|
import com.utopiaindustries.qualitychecker.notification.NotificationHelper;
|
||||||
|
import com.utopiaindustries.qualitychecker.receiver.NetworkReceiver;
|
||||||
|
import com.utopiaindustries.qualitychecker.service.InspectionReportService;
|
||||||
import com.utopiaindustries.qualitychecker.store.Store;
|
import com.utopiaindustries.qualitychecker.store.Store;
|
||||||
import com.utopiaindustries.qualitychecker.ui.adapter.ReportAdapter;
|
import com.utopiaindustries.qualitychecker.ui.adapter.ReportAdapter;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
@ -39,12 +54,15 @@ import retrofit2.Response;
|
||||||
|
|
||||||
public class HomeActivity extends AppCompatActivity implements View.OnClickListener {
|
public class HomeActivity extends AppCompatActivity implements View.OnClickListener {
|
||||||
|
|
||||||
private Button createReportBtn,refreshReportsBtn,logoutBtn;
|
private Button createReportBtn,refreshReportsBtn,logoutBtn,fetchProductBtn;
|
||||||
private RecyclerView recyclerView;
|
private RecyclerView recyclerView;
|
||||||
private ApiService apiService;
|
private ApiService apiService;
|
||||||
private TextView usernameTitle, emptyReportTextView;
|
private TextView usernameTitle, emptyReportTextView;
|
||||||
private ImageView profileImage;
|
private ImageView profileImage;
|
||||||
private Store store;
|
private Store store;
|
||||||
|
private InspectionReportService inspectionReportService;
|
||||||
|
private NetworkReceiver networkReceiver;
|
||||||
|
private boolean isReceiverRegistered = false;
|
||||||
|
|
||||||
@SuppressLint("SourceLockedOrientationActivity")
|
@SuppressLint("SourceLockedOrientationActivity")
|
||||||
@Override
|
@Override
|
||||||
|
@ -65,9 +83,11 @@ public class HomeActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
// initialize views
|
// initialize views
|
||||||
store = Store.getInstance();
|
store = Store.getInstance();
|
||||||
apiService = ApiServiceFactory.getApiService();
|
apiService = ApiServiceFactory.getApiService();
|
||||||
|
inspectionReportService = InspectionReportService.getInstance();
|
||||||
createReportBtn = findViewById( R.id.create_report_btn );
|
createReportBtn = findViewById( R.id.create_report_btn );
|
||||||
refreshReportsBtn = findViewById( R.id.refresh_btn );
|
refreshReportsBtn = findViewById( R.id.refresh_btn );
|
||||||
logoutBtn = findViewById( R.id.logout_btn );
|
logoutBtn = findViewById( R.id.logout_btn );
|
||||||
|
fetchProductBtn = findViewById( R.id.fetch_product_btn );
|
||||||
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 );
|
||||||
|
@ -76,6 +96,7 @@ public class HomeActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
refreshReportsBtn.setOnClickListener( this );
|
refreshReportsBtn.setOnClickListener( this );
|
||||||
createReportBtn.setOnClickListener( this );
|
createReportBtn.setOnClickListener( this );
|
||||||
logoutBtn.setOnClickListener( this );
|
logoutBtn.setOnClickListener( this );
|
||||||
|
fetchProductBtn.setOnClickListener( this );
|
||||||
|
|
||||||
recyclerView.setLayoutManager( new LinearLayoutManager( this ) );
|
recyclerView.setLayoutManager( new LinearLayoutManager( this ) );
|
||||||
|
|
||||||
|
@ -131,12 +152,23 @@ public class HomeActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
refreshReportData();
|
refreshReportData();
|
||||||
updateProfileImage();
|
updateProfileImage();
|
||||||
}
|
}
|
||||||
|
if( id == R.id.fetch_product_btn ){
|
||||||
|
if( isNetworkConnected() ) {
|
||||||
|
fetchAndPopulateProductData();
|
||||||
|
fetchAndPopulateDimensionsData();
|
||||||
|
fetchAndPopulateCheckpointData();
|
||||||
|
fetchAndPopulateDefectsData();
|
||||||
|
fetchAndPopulateUnitsData();
|
||||||
|
} else {
|
||||||
|
Toast.makeText( this, "network not available", Toast.LENGTH_LONG ).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateProfileImage(){
|
private void updateProfileImage(){
|
||||||
SharedPreferences sharedPreferences = getSharedPreferences("login_prefs", Context.MODE_PRIVATE);
|
SharedPreferences sharedPreferences = getSharedPreferences("login_prefs", Context.MODE_PRIVATE);
|
||||||
|
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||||
String username = sharedPreferences.getString("username", null );
|
String username = sharedPreferences.getString("username", null );
|
||||||
System.out.println( );
|
|
||||||
if( username != null ){
|
if( username != null ){
|
||||||
apiService.fetchEmployeePhoto( username ).enqueue(
|
apiService.fetchEmployeePhoto( username ).enqueue(
|
||||||
new Callback<EmployeePhoto>() {
|
new Callback<EmployeePhoto>() {
|
||||||
|
@ -145,6 +177,8 @@ public class HomeActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
System.out.println( response.body() );
|
System.out.println( response.body() );
|
||||||
if( response.isSuccessful() && response.body() != null ){
|
if( response.isSuccessful() && response.body() != null ){
|
||||||
System.out.println( response.body() );
|
System.out.println( response.body() );
|
||||||
|
editor.putString("name" , response.body().getName() );
|
||||||
|
editor.apply();
|
||||||
usernameTitle.setText( response.body().getName() );
|
usernameTitle.setText( response.body().getName() );
|
||||||
store.setEmployeePhoto( response.body() );
|
store.setEmployeePhoto( response.body() );
|
||||||
Glide.with( getBaseContext() )
|
Glide.with( getBaseContext() )
|
||||||
|
@ -156,12 +190,154 @@ public class HomeActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Call<EmployeePhoto> call, Throwable t) {
|
public void onFailure(Call<EmployeePhoto> call, Throwable t) {
|
||||||
System.out.println( t.getMessage() );
|
System.out.println( t.getMessage() );
|
||||||
|
String name = sharedPreferences.getString("name", null);
|
||||||
|
usernameTitle.setText( name );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* fetch and update product map
|
||||||
|
* */
|
||||||
|
private void fetchAndPopulateProductData(){
|
||||||
|
|
||||||
|
NotificationHelper.showProductNotification(
|
||||||
|
this,
|
||||||
|
"Utopia QA App",
|
||||||
|
"Fetching Product Details.");
|
||||||
|
inspectionReportService.fetchAndPopulateProducts( new SaveProductCallBack() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess() {
|
||||||
|
Toast.makeText( HomeActivity.this, "Products successfully synced", Toast.LENGTH_LONG ).show();
|
||||||
|
NotificationHelper.showProductNotification(
|
||||||
|
HomeActivity.this,
|
||||||
|
"Utopia QA App",
|
||||||
|
"Products successfully synced");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable throwable) {
|
||||||
|
Toast.makeText( HomeActivity.this, "Error in Products syncing " + throwable.getMessage(), Toast.LENGTH_LONG ).show();
|
||||||
|
NotificationHelper.showProductNotification(
|
||||||
|
HomeActivity.this,
|
||||||
|
"Utopia QA App",
|
||||||
|
"Error in Products syncing" );
|
||||||
|
}
|
||||||
|
}, new ProductRepository( this ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fetchAndPopulateDimensionsData(){
|
||||||
|
|
||||||
|
NotificationHelper.showProductNotification( this,
|
||||||
|
"Utopia QA App",
|
||||||
|
"Fetching Dimensions Details.");
|
||||||
|
inspectionReportService.fetchAndPopulateDimensions( new SaveDimensionCallback() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess() {
|
||||||
|
Toast.makeText( HomeActivity.this, "Dimensions successfully synced", Toast.LENGTH_LONG ).show();
|
||||||
|
NotificationHelper.showProductNotification(
|
||||||
|
HomeActivity.this,
|
||||||
|
"Utopia QA App",
|
||||||
|
"Dimensions successfully synced");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable throwable) {
|
||||||
|
Toast.makeText( HomeActivity.this, "Error in Dimensions syncing " + throwable.getMessage(), Toast.LENGTH_LONG ).show();
|
||||||
|
NotificationHelper.showProductNotification(
|
||||||
|
HomeActivity.this,
|
||||||
|
"Utopia QA App",
|
||||||
|
"Error in Dimensions syncing" );
|
||||||
|
}
|
||||||
|
}, new DimensionRepository( this ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fetchAndPopulateCheckpointData(){
|
||||||
|
|
||||||
|
NotificationHelper.showProductNotification(
|
||||||
|
this,
|
||||||
|
"Utopia QA App",
|
||||||
|
"Fetching Checkpoints Details.");
|
||||||
|
inspectionReportService.fetchAndPopulateCheckpoints( new SaveCheckpointCallback() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess() {
|
||||||
|
Toast.makeText( HomeActivity.this, "Checkpoints successfully synced", Toast.LENGTH_LONG ).show();
|
||||||
|
NotificationHelper.showProductNotification( HomeActivity.this,
|
||||||
|
"Utopia QA App",
|
||||||
|
"Checkpoints successfully synced");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable throwable) {
|
||||||
|
Toast.makeText( HomeActivity.this, "Error in Checkpoints syncing " + throwable.getMessage(), Toast.LENGTH_LONG ).show();
|
||||||
|
NotificationHelper.showProductNotification(
|
||||||
|
HomeActivity.this,
|
||||||
|
"Utopia QA App",
|
||||||
|
"Error in Checkpoints syncing" );
|
||||||
|
}
|
||||||
|
}, new CheckpointRepository( this ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fetchAndPopulateDefectsData(){
|
||||||
|
|
||||||
|
NotificationHelper.showProductNotification(
|
||||||
|
this,
|
||||||
|
"Utopia QA App",
|
||||||
|
"Fetching Defects Details.");
|
||||||
|
inspectionReportService.fetchAndPopulateDefects( new SaveDefectCallback() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess() {
|
||||||
|
Toast.makeText( HomeActivity.this, "Defects successfully synced", Toast.LENGTH_LONG ).show();
|
||||||
|
NotificationHelper.showProductNotification(
|
||||||
|
HomeActivity.this,
|
||||||
|
"Utopia QA App",
|
||||||
|
"Defects successfully synced");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable throwable) {
|
||||||
|
Toast.makeText( HomeActivity.this, "Error in Defects syncing " + throwable.getMessage(), Toast.LENGTH_LONG ).show();
|
||||||
|
NotificationHelper.showProductNotification(
|
||||||
|
HomeActivity.this,
|
||||||
|
"Utopia QA App",
|
||||||
|
"Error in Defects syncing" );
|
||||||
|
}
|
||||||
|
}, new DefectRepository( this ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fetchAndPopulateUnitsData(){
|
||||||
|
|
||||||
|
NotificationHelper.showProductNotification(
|
||||||
|
this,
|
||||||
|
"Utopia QA App",
|
||||||
|
"Fetching Units Details.");
|
||||||
|
inspectionReportService.fetchAndPopulateUnits( new SaveItemCallback() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess() {
|
||||||
|
Toast.makeText( HomeActivity.this, "Units successfully synced", Toast.LENGTH_LONG ).show();
|
||||||
|
NotificationHelper.showProductNotification(
|
||||||
|
HomeActivity.this,
|
||||||
|
"Utopia QA App",
|
||||||
|
"Units successfully synced");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable throwable) {
|
||||||
|
Toast.makeText( HomeActivity.this, "Error in Units syncing " + throwable.getMessage(), Toast.LENGTH_LONG ).show();
|
||||||
|
NotificationHelper.showProductNotification(
|
||||||
|
HomeActivity.this,
|
||||||
|
"Utopia QA App",
|
||||||
|
"Error in Units syncing" );
|
||||||
|
}
|
||||||
|
}, new ItemRepository( this ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private boolean isNetworkConnected() {
|
private boolean isNetworkConnected() {
|
||||||
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo();
|
NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo();
|
||||||
|
@ -173,4 +349,24 @@ public class HomeActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
super.onResume();
|
super.onResume();
|
||||||
refreshReportData();
|
refreshReportData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
if (networkReceiver == null) {
|
||||||
|
networkReceiver = new NetworkReceiver();
|
||||||
|
}
|
||||||
|
IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
|
||||||
|
registerReceiver(networkReceiver, filter);
|
||||||
|
isReceiverRegistered = true; // Mark the receiver as registered
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop() {
|
||||||
|
super.onStop();
|
||||||
|
if (isReceiverRegistered) {
|
||||||
|
unregisterReceiver(networkReceiver);
|
||||||
|
isReceiverRegistered = false; // Mark the receiver as unregistered
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -111,28 +111,33 @@ public class LoginActivity extends AppCompatActivity {
|
||||||
|
|
||||||
String username = sharedPreferences.getString("username", null);
|
String username = sharedPreferences.getString("username", null);
|
||||||
String password = sharedPreferences.getString("password", null);
|
String password = sharedPreferences.getString("password", null);
|
||||||
|
if( username != null && ! username.trim().isEmpty() && password != null && !password.trim().isEmpty() ){
|
||||||
reportService.isUserAuthenticated(username,
|
|
||||||
password,
|
|
||||||
new String[]{"ROLE_UIM_QA_APP_ACCESS_YES"},
|
|
||||||
new Callback<Boolean>() {
|
|
||||||
@Override
|
|
||||||
public void onResponse(Call<Boolean> call, Response<Boolean> response) {
|
|
||||||
if (response.isSuccessful()) {
|
|
||||||
boolean isAuthenticated = response.body();
|
|
||||||
if (isAuthenticated) {
|
|
||||||
Intent intent = new Intent(LoginActivity.this, HomeActivity.class);
|
Intent intent = new Intent(LoginActivity.this, HomeActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
// close login screen
|
// close login screen
|
||||||
LoginActivity.this.finish();
|
LoginActivity.this.finish();
|
||||||
}
|
}
|
||||||
}
|
// reportService.isUserAuthenticated(username,
|
||||||
}
|
// password,
|
||||||
@Override
|
// new String[]{"ROLE_UIM_QA_APP_ACCESS_YES"},
|
||||||
public void onFailure(Call<Boolean> call, Throwable t) {
|
// new Callback<Boolean>() {
|
||||||
Log.d(t.getMessage(), "onFailure: ");
|
// @Override
|
||||||
}
|
// public void onResponse(Call<Boolean> call, Response<Boolean> response) {
|
||||||
});
|
// if (response.isSuccessful()) {
|
||||||
|
// boolean isAuthenticated = response.body();
|
||||||
|
// if (isAuthenticated) {
|
||||||
|
// Intent intent = new Intent(LoginActivity.this, HomeActivity.class);
|
||||||
|
// startActivity(intent);
|
||||||
|
// // close login screen
|
||||||
|
// LoginActivity.this.finish();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// @Override
|
||||||
|
// public void onFailure(Call<Boolean> call, Throwable t) {
|
||||||
|
// Log.d(t.getMessage(), "onFailure: ");
|
||||||
|
// }
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isNetworkConnected() {
|
private boolean isNetworkConnected() {
|
||||||
|
|
|
@ -32,16 +32,13 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
private NavController navController;
|
private NavController navController;
|
||||||
private Store store;
|
private Store store;
|
||||||
|
|
||||||
{
|
|
||||||
store = Store.getInstance();
|
|
||||||
store.initializeNewReport();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("SourceLockedOrientationActivity")
|
@SuppressLint("SourceLockedOrientationActivity")
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
EdgeToEdge.enable(this);
|
EdgeToEdge.enable(this);
|
||||||
|
store = Store.getInstance();
|
||||||
|
store.initializeNewReport( getApplicationContext() );
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
|
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
|
||||||
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||||
|
@ -49,9 +46,8 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
return insets;
|
return insets;
|
||||||
});
|
});
|
||||||
setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_PORTRAIT );
|
setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_PORTRAIT );
|
||||||
|
|
||||||
// initializing fields
|
|
||||||
navController = Navigation.findNavController( this, R.id.nav_host_fragment );
|
navController = Navigation.findNavController( this, R.id.nav_host_fragment );
|
||||||
|
// initializing fields
|
||||||
updateUsername();
|
updateUsername();
|
||||||
}
|
}
|
||||||
private void updateUsername() {
|
private void updateUsername() {
|
||||||
|
|
|
@ -76,12 +76,14 @@ public class CheckPointAdapter extends
|
||||||
holder.checkpointSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
holder.checkpointSpinner.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 ){
|
||||||
String selectedItem = parent.getItemAtPosition(position).toString();
|
String selectedItem = parent.getItemAtPosition(position).toString();
|
||||||
InspectionCheckPoint cp = checkPoints.stream().filter(check -> check.getTitle().equalsIgnoreCase(selectedItem))
|
InspectionCheckPoint cp = checkPoints.stream().filter(check -> check.getTitle().equalsIgnoreCase(selectedItem))
|
||||||
.findFirst().orElse(new InspectionCheckPoint());
|
.findFirst().orElse(new InspectionCheckPoint());
|
||||||
holder.populateDefects(cp, defects, checkPoint);
|
holder.populateDefects(cp, defects, checkPoint);
|
||||||
checkPoint.setTitle(selectedItem);
|
checkPoint.setTitle(selectedItem);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onNothingSelected(AdapterView<?> parent) {
|
public void onNothingSelected(AdapterView<?> parent) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,11 +7,13 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.AutoCompleteTextView;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.widget.SearchView;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.utopiaindustries.qualitychecker.R;
|
import com.utopiaindustries.qualitychecker.R;
|
||||||
|
@ -37,6 +39,7 @@ public class DefectsAdapter extends RecyclerView.Adapter<DefectsAdapter.DefectVi
|
||||||
this.defectTypes = defectTypes;
|
this.defectTypes = defectTypes;
|
||||||
this.defects = defects;
|
this.defects = defects;
|
||||||
this.cp = cp;
|
this.cp = cp;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -68,14 +71,17 @@ public class DefectsAdapter extends RecyclerView.Adapter<DefectsAdapter.DefectVi
|
||||||
.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());
|
||||||
|
|
||||||
|
|
||||||
ArrayAdapter<String> defectSpinnerAdapter = new ArrayAdapter<>( holder.defectSpinner.getContext(),
|
ArrayAdapter<String> defectSpinnerAdapter = new ArrayAdapter<>( holder.defectSpinner.getContext(),
|
||||||
android.R.layout.simple_spinner_item, defectList );
|
android.R.layout.simple_spinner_item, defectList );
|
||||||
defectSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
// defectSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
holder.defectSpinner.setAdapter(defectSpinnerAdapter);
|
holder.defectSpinner.setAdapter(defectSpinnerAdapter);
|
||||||
|
// Make the dropdown appear when clicking the AutoCompleteTextView
|
||||||
|
holder.defectSpinner.setOnClickListener(view -> holder.defectSpinner.showDropDown());
|
||||||
|
|
||||||
String defaultSelectedDefect = defect;
|
String defaultSelectedDefect = defect;
|
||||||
int defaultSelectedDefectPosition = defectList.indexOf(defaultSelectedDefect);
|
int defaultSelectedDefectPosition = defectList.indexOf(defaultSelectedDefect);
|
||||||
holder.defectSpinner.setSelection(defaultSelectedDefectPosition);
|
holder.defectSpinner.setText(defaultSelectedDefect);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateQuantity( DefectViewHolder holder ){
|
private void populateQuantity( DefectViewHolder holder ){
|
||||||
|
@ -107,17 +113,25 @@ public class DefectsAdapter extends RecyclerView.Adapter<DefectsAdapter.DefectVi
|
||||||
public void onNothingSelected(AdapterView<?> parent) {
|
public void onNothingSelected(AdapterView<?> parent) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
holder.defectSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
|
||||||
|
holder.defectSpinner.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
String selectedItem = parent.getItemAtPosition(position).toString();
|
String selectedItem = parent.getItemAtPosition(position).toString();
|
||||||
checkPoint.getDefectTitles().set( holder.getAdapterPosition(), selectedItem) ;
|
checkPoint.getDefectTitles().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() {
|
holder.quantity.addTextChangedListener(new TextWatcher() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -166,7 +180,8 @@ public class DefectsAdapter extends RecyclerView.Adapter<DefectsAdapter.DefectVi
|
||||||
|
|
||||||
public static class DefectViewHolder extends RecyclerView.ViewHolder{
|
public static class DefectViewHolder extends RecyclerView.ViewHolder{
|
||||||
|
|
||||||
private Spinner defectSpinner, defectTypeSpinner;
|
private AutoCompleteTextView defectSpinner;
|
||||||
|
private Spinner defectTypeSpinner;
|
||||||
private ImageButton deleteBtn;
|
private ImageButton deleteBtn;
|
||||||
private EditText quantity;
|
private EditText quantity;
|
||||||
|
|
||||||
|
|
|
@ -72,9 +72,12 @@ public class ReportAdapter extends
|
||||||
if( report.getReportResult().equalsIgnoreCase("FAILED") ){
|
if( report.getReportResult().equalsIgnoreCase("FAILED") ){
|
||||||
status.setBackgroundResource( R.drawable.failed_bg );
|
status.setBackgroundResource( R.drawable.failed_bg );
|
||||||
}
|
}
|
||||||
if( report.getReportResult().equalsIgnoreCase("Passed") ){
|
if( report.getReportResult().equalsIgnoreCase("PASSED") ){
|
||||||
status.setBackgroundResource( R.drawable.passed_bg );
|
status.setBackgroundResource( R.drawable.passed_bg );
|
||||||
}
|
}
|
||||||
|
if( report.getReportResult().equalsIgnoreCase("ON_HOLD") ){
|
||||||
|
status.setBackgroundResource( R.drawable.hold_bg );
|
||||||
|
}
|
||||||
status.setText( report.getReportResult() );
|
status.setText( report.getReportResult() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package com.utopiaindustries.qualitychecker.ui.fragments;
|
package com.utopiaindustries.qualitychecker.ui.fragments;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
|
@ -28,18 +31,23 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
|
import com.google.zxing.integration.android.IntentResult;
|
||||||
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.db.DimensionRepository;
|
||||||
|
import com.utopiaindustries.qualitychecker.db.ProductRepository;
|
||||||
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;
|
||||||
|
import com.utopiaindustries.qualitychecker.service.InspectionReportService;
|
||||||
import com.utopiaindustries.qualitychecker.store.Store;
|
import com.utopiaindustries.qualitychecker.store.Store;
|
||||||
import com.utopiaindustries.qualitychecker.ui.adapter.ItemHistoryAdapter;
|
import com.utopiaindustries.qualitychecker.ui.adapter.ItemHistoryAdapter;
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
import com.google.zxing.integration.android.IntentIntegrator;
|
import com.google.zxing.integration.android.IntentIntegrator;
|
||||||
import com.journeyapps.barcodescanner.CaptureActivity;
|
import com.journeyapps.barcodescanner.CaptureActivity;
|
||||||
|
|
||||||
|
import java.sql.SQLOutput;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -63,12 +71,15 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
|
||||||
private ApiService apiService;
|
private ApiService apiService;
|
||||||
private Store store;
|
private Store store;
|
||||||
|
|
||||||
|
private InspectionReportService inspectionReportService;
|
||||||
|
|
||||||
@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) {
|
||||||
View view = inflater.inflate(R.layout.fragment_first_step , container, false );
|
View view = inflater.inflate(R.layout.fragment_first_step , container, false );
|
||||||
initializeViews( view );
|
initializeViews( view );
|
||||||
apiService = ApiServiceFactory.getApiService();
|
apiService = ApiServiceFactory.getApiService();
|
||||||
|
inspectionReportService = InspectionReportService.getInstance();
|
||||||
store = Store.getInstance();
|
store = Store.getInstance();
|
||||||
// set on click listener
|
// set on click listener
|
||||||
leftFab.setOnClickListener( this );
|
leftFab.setOnClickListener( this );
|
||||||
|
@ -78,12 +89,7 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
|
||||||
showHistoryBtn.setOnClickListener( this );
|
showHistoryBtn.setOnClickListener( this );
|
||||||
populateItem( store.getProducts() );
|
populateItem( store.getProducts() );
|
||||||
prePopulateData( store.getProducts() );
|
prePopulateData( store.getProducts() );
|
||||||
|
updateProfileViews();
|
||||||
|
|
||||||
profileName.setText( store.getEmployeePhoto().getName() !=null ? store.getEmployeePhoto().getName() : "" );
|
|
||||||
Glide.with( getContext() )
|
|
||||||
.load( store.getProfileImage( ) )
|
|
||||||
.into( profileImage );
|
|
||||||
|
|
||||||
fri.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
fri.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||||
if( isChecked ){
|
if( isChecked ){
|
||||||
|
@ -284,43 +290,58 @@ 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
|
||||||
String skuStr = sku.getText().toString().trim();
|
String skuStr = sku.getText().toString().trim();
|
||||||
apiService.fetchProductBySku( skuStr ).enqueue(
|
List<Product> products = new ProductRepository( getContext() ).getProductBySku( skuStr );
|
||||||
new Callback<List<Product>>() {
|
Product product = products.stream().findFirst().orElse( new 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).setSku( skuStr );
|
||||||
store.getReport().getItems().get(0).setAsin( product.getAsin() );
|
store.getReport().getItems().get(0).setAsin( product.getAsin() );
|
||||||
populateItem( response.body() );
|
populateItem( products );
|
||||||
store.setProducts( response.body() );
|
store.setProducts( products );
|
||||||
} 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( skuStr ).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
|
// apiService.fetchProductBySku( skuStr ).enqueue(
|
||||||
public void onFailure(Call<List<InspectionDimension>> call, Throwable t) {
|
// new Callback<List<Product>>() {
|
||||||
System.out.println( t.getMessage() );
|
// @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 ){
|
||||||
|
@ -378,7 +399,6 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
|
||||||
String boxCartonText = String.valueOf( ( product.getInventory() / product.getItemPerBox() ) );
|
String boxCartonText = String.valueOf( ( product.getInventory() / product.getItemPerBox() ) );
|
||||||
|
|
||||||
@SuppressLint("DefaultLocale") String packagingDetailsText = String.format("%d Item per Pack, %d Pack per Box", product.getItemPerPack(), product.getItemPerBox() );
|
@SuppressLint("DefaultLocale") String packagingDetailsText = String.format("%d Item per Pack, %d Pack per Box", product.getItemPerPack(), product.getItemPerBox() );
|
||||||
|
|
||||||
itemPerBox.setText( inventory );
|
itemPerBox.setText( inventory );
|
||||||
pieces.setText( itemPerBoxText );
|
pieces.setText( itemPerBoxText );
|
||||||
boxCarton.setText( boxCartonText );
|
boxCarton.setText( boxCartonText );
|
||||||
|
@ -407,8 +427,9 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
|
||||||
private void populateSize( List<Product> products ){
|
private void populateSize( List<Product> products ){
|
||||||
List<String> sizes = Collections.singletonList("[Size]");
|
List<String> sizes = Collections.singletonList("[Size]");
|
||||||
if( ! products.isEmpty() ){
|
if( ! products.isEmpty() ){
|
||||||
sizes = products.stream().map( Product::getSmSize ).distinct().collect(Collectors.toList() );
|
sizes = products.stream().map( Product::getSmSize ).distinct().filter(Objects::nonNull).collect(Collectors.toList() );
|
||||||
}
|
}
|
||||||
|
if( !sizes.isEmpty() ){
|
||||||
ArrayAdapter<String> adapter = new ArrayAdapter<>( Objects.requireNonNull(getContext() ),
|
ArrayAdapter<String> adapter = new ArrayAdapter<>( Objects.requireNonNull(getContext() ),
|
||||||
android.R.layout.simple_spinner_dropdown_item, sizes.toArray( new String[0]) );
|
android.R.layout.simple_spinner_dropdown_item, sizes.toArray( new String[0]) );
|
||||||
size.setAdapter( adapter );
|
size.setAdapter( adapter );
|
||||||
|
@ -416,55 +437,64 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
|
||||||
String sizeOption = (String) size.getSelectedItem();
|
String sizeOption = (String) size.getSelectedItem();
|
||||||
store.getReport().getItems().get(0).setSmSize( sizeOption );
|
store.getReport().getItems().get(0).setSmSize( sizeOption );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void populateColor( List<Product> products ){
|
private void populateColor( List<Product> products ){
|
||||||
List<String> colors = Collections.singletonList("[Color]");
|
List<String> colors = Collections.singletonList("[Color]");
|
||||||
if( ! products.isEmpty() ){
|
if( ! products.isEmpty() ){
|
||||||
colors = products.stream().map( Product::getSmColor ).distinct().collect(Collectors.toList() );
|
colors = products.stream().map( Product::getSmColor ).distinct().filter(Objects::nonNull).collect(Collectors.toList() );
|
||||||
}
|
}
|
||||||
|
if( !colors.isEmpty() ){
|
||||||
|
|
||||||
ArrayAdapter<String> adapter = new ArrayAdapter<>( Objects.requireNonNull(getContext() ),
|
ArrayAdapter<String> adapter = new ArrayAdapter<>( Objects.requireNonNull(getContext() ),
|
||||||
android.R.layout.simple_spinner_dropdown_item, colors.toArray( new String[0]) );
|
android.R.layout.simple_spinner_dropdown_item, colors.toArray( new String[0]) );
|
||||||
color.setAdapter( adapter );
|
color.setAdapter( adapter );
|
||||||
String colorOption = (String) color.getSelectedItem();
|
String colorOption = (String) color.getSelectedItem();
|
||||||
store.getReport().getItems().get(0).setSmColor( colorOption );
|
store.getReport().getItems().get(0).setSmColor( colorOption );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void populateTitle( List<Product> products ){
|
private void populateTitle( List<Product> products ){
|
||||||
List<String> titles = Collections.singletonList("[Title]");
|
List<String> titles = Collections.singletonList("[Title]");
|
||||||
if( ! products.isEmpty() ){
|
if( ! products.isEmpty() ){
|
||||||
titles = products.stream().map( Product::getTitle ).distinct().collect(Collectors.toList()) ;
|
titles = products.stream().map( Product::getTitle ).distinct().filter(Objects::nonNull).collect(Collectors.toList()) ;
|
||||||
}
|
}
|
||||||
|
if( !titles.isEmpty() ){
|
||||||
ArrayAdapter<String> adapter = new ArrayAdapter<>( getContext(), android.R.layout.simple_spinner_dropdown_item, titles.toArray( new String[0] ));
|
ArrayAdapter<String> adapter = new ArrayAdapter<>( getContext(), android.R.layout.simple_spinner_dropdown_item, titles.toArray( new String[0] ));
|
||||||
title.setAdapter( adapter );
|
title.setAdapter( adapter );
|
||||||
//
|
|
||||||
String titleOption = (String) title.getSelectedItem();
|
String titleOption = (String) title.getSelectedItem();
|
||||||
store.getReport().getItems().get(0).setTitle( titleOption );
|
store.getReport().getItems().get(0).setTitle( titleOption );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void populateMmodelNumber( List<Product> products ){
|
private void populateMmodelNumber( List<Product> products ){
|
||||||
List<String> modelNumbers = Collections.singletonList("[Model Number]");
|
List<String> modelNumbers = Collections.singletonList("[Model Number]");
|
||||||
if( ! products.isEmpty() ){
|
if( ! products.isEmpty() ){
|
||||||
modelNumbers = products.stream().map( Product::getModelNumber ).distinct().collect(Collectors.toList()) ;
|
modelNumbers = products.stream().map( Product::getModelNumber ).distinct().filter(Objects::nonNull).collect(Collectors.toList() ) ;
|
||||||
}
|
}
|
||||||
|
if( !modelNumbers.isEmpty() ){
|
||||||
ArrayAdapter<String> adapter = new ArrayAdapter<>( getContext(), android.R.layout.simple_spinner_dropdown_item, modelNumbers.toArray(new String[0] ));
|
ArrayAdapter<String> adapter = new ArrayAdapter<>( getContext(), android.R.layout.simple_spinner_dropdown_item, modelNumbers.toArray(new String[0] ));
|
||||||
modelNumber.setAdapter( adapter );
|
modelNumber.setAdapter( adapter );
|
||||||
|
|
||||||
String modelOption = (String) modelNumber.getSelectedItem();
|
String modelOption = (String) modelNumber.getSelectedItem();
|
||||||
store.getReport().getItems().get(0).setMarketplace( modelOption );
|
store.getReport().getItems().get(0).setMarketplace( modelOption );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void populateMarketplaces( List<Product> products ){
|
private void populateMarketplaces( List<Product> products ){
|
||||||
List<String> marketplaces = Collections.singletonList("[ Marketplace ]");
|
List<String> marketplaces = Collections.singletonList("[ Marketplace ]");
|
||||||
if( ! products.isEmpty() ){
|
if( ! products.isEmpty() ){
|
||||||
marketplaces = products.stream().map( Product::getMarketplace ).distinct().collect(Collectors.toList() );
|
marketplaces = products.stream().map( Product::getMarketplace ).distinct().filter(Objects::nonNull).collect(Collectors.toList() );
|
||||||
}
|
}
|
||||||
|
if( ! marketplaces.isEmpty()){
|
||||||
ArrayAdapter<String> adapter = new ArrayAdapter<>( getContext(), android.R.layout.simple_spinner_dropdown_item, marketplaces.toArray(new String[0] ));
|
ArrayAdapter<String> adapter = new ArrayAdapter<>( getContext(), android.R.layout.simple_spinner_dropdown_item, marketplaces.toArray(new String[0] ));
|
||||||
markerplace.setAdapter( adapter );
|
markerplace.setAdapter( adapter );
|
||||||
//
|
//
|
||||||
String marketplaceOption = (String) markerplace.getSelectedItem();
|
String marketplaceOption = (String) markerplace.getSelectedItem();
|
||||||
store.getReport().getItems().get(0).setMarketplace( marketplaceOption );
|
store.getReport().getItems().get(0).setMarketplace( marketplaceOption );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -494,23 +524,11 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
|
||||||
scanBtn = view.findViewById( R.id.scan_sku_btn );
|
scanBtn = view.findViewById( R.id.scan_sku_btn );
|
||||||
showHistoryBtn = view.findViewById( R.id.button_show_history );
|
showHistoryBtn = view.findViewById( R.id.button_show_history );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onBarcodeScanResult( String result ){
|
public void onBarcodeScanResult( String result ){
|
||||||
if( result != null && ! result.isEmpty() ){
|
if( result != null && ! result.isEmpty() ){
|
||||||
apiService.fetchByFnsku( result ).enqueue(
|
store.getReport().getItems().get(0).setSku( result );
|
||||||
new Callback<Product>() {
|
sku.setText( result );
|
||||||
@Override
|
|
||||||
public void onResponse(Call<Product> call, Response<Product> response) {
|
|
||||||
if( response.isSuccessful() && response.body() != null ){
|
|
||||||
store.getReport().getItems().get(0).setSku( response.body().getSku() );
|
|
||||||
sku.setText( response.body().getSku() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onFailure(Call<Product> call, Throwable t) {
|
|
||||||
Toast.makeText( getContext(), t.getMessage().toString(), Toast.LENGTH_LONG ).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -562,4 +580,12 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
|
||||||
AlertDialog dialog = builder.create();
|
AlertDialog dialog = builder.create();
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateProfileViews( ) throws NullPointerException{
|
||||||
|
SharedPreferences sharedPreferences = getActivity().getSharedPreferences("login_prefs", Context.MODE_PRIVATE);
|
||||||
|
profileName.setText( sharedPreferences.getString("name", null ) );
|
||||||
|
Glide.with( getContext() )
|
||||||
|
.load( store.getProfileImage( ) )
|
||||||
|
.into( profileImage );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import static android.app.Activity.RESULT_OK;
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
|
@ -17,6 +18,7 @@ import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
@ -43,6 +45,7 @@ import com.utopiaindustries.qualitychecker.ui.adapter.CheckPointAdapter;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.time.Duration;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
@ -104,11 +107,6 @@ public class SecondStepFragment extends Fragment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
profileName.setText( store.getEmployeePhoto().getName() );
|
|
||||||
Glide.with( getContext() )
|
|
||||||
.load( store.getProfileImage( ) )
|
|
||||||
.into( profileImage );
|
|
||||||
|
|
||||||
adapter = new CheckPointAdapter( store.getReport().getItems().get( 0 ).getCheckPoints(),
|
adapter = new CheckPointAdapter( store.getReport().getItems().get( 0 ).getCheckPoints(),
|
||||||
store.getCheckPoints(),
|
store.getCheckPoints(),
|
||||||
store.getDefects(),
|
store.getDefects(),
|
||||||
|
@ -118,6 +116,7 @@ public class SecondStepFragment extends Fragment
|
||||||
// set on click listener
|
// set on click listener
|
||||||
leftFab.setOnClickListener( this );
|
leftFab.setOnClickListener( this );
|
||||||
rightFab.setOnClickListener( this );
|
rightFab.setOnClickListener( this );
|
||||||
|
updateProfileViews();
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +127,7 @@ public class SecondStepFragment extends Fragment
|
||||||
navController.navigate( R.id.action_secondStepFragment_to_firstStepFragment );
|
navController.navigate( R.id.action_secondStepFragment_to_firstStepFragment );
|
||||||
}
|
}
|
||||||
if( v.getId() == R.id.button_right_frag_2 ){
|
if( v.getId() == R.id.button_right_frag_2 ){
|
||||||
navController.navigate( R.id.action_secondStepFragment_to_thirdStepFragment );
|
checkIsRecyclerViewIsCompletelyScrolled( recyclerView );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,55 +151,28 @@ public class SecondStepFragment extends Fragment
|
||||||
} catch ( Exception e ){
|
} catch ( Exception e ){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
// store.getReport().getItems().get( 0 ).getCheckPoints().get( requestCode ).setFile(
|
|
||||||
// compressImageToMaxSize( getBytesFromUri( getContext(), selectedImageUri ), 200 )
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// private byte[] getBytesFromUri(Context context, Uri uri) {
|
private void checkIsRecyclerViewIsCompletelyScrolled( RecyclerView recyclerView ){
|
||||||
// if( uri != null ) {
|
if (recyclerView.getLayoutManager() instanceof LinearLayoutManager) {
|
||||||
// try {
|
LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
|
||||||
// InputStream inputStream = context.getContentResolver().openInputStream(uri);
|
int lastVisibleItemPosition = layoutManager.findLastCompletelyVisibleItemPosition();
|
||||||
// if (inputStream != null) {
|
int totalItemCount = layoutManager.getItemCount();
|
||||||
// ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream();
|
|
||||||
// byte[] buffer = new byte[1024];
|
if (lastVisibleItemPosition == totalItemCount - 1) {
|
||||||
// int len;
|
navController.navigate( R.id.action_secondStepFragment_to_thirdStepFragment );
|
||||||
// while ((len = inputStream.read(buffer)) != -1) {
|
} else {
|
||||||
// byteBuffer.write(buffer, 0, len);
|
Toast.makeText( getContext(), "Please Scroll at the bottom to continue", Toast.LENGTH_SHORT ).show();
|
||||||
// }
|
}
|
||||||
// inputStream.close();
|
}
|
||||||
// return byteBuffer.toByteArray();
|
}
|
||||||
// }
|
|
||||||
// } catch (IOException e) {
|
private void updateProfileViews( ) throws NullPointerException{
|
||||||
// System.out.println(e.getMessage());
|
SharedPreferences sharedPreferences = getActivity().getSharedPreferences("login_prefs", Context.MODE_PRIVATE);
|
||||||
// return null;
|
profileName.setText( sharedPreferences.getString("name", null ) );
|
||||||
// }
|
Glide.with( getContext() )
|
||||||
// }
|
.load( store.getProfileImage( ) )
|
||||||
// return null;
|
.into( profileImage );
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// 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,7 +1,11 @@
|
||||||
package com.utopiaindustries.qualitychecker.ui.fragments;
|
package com.utopiaindustries.qualitychecker.ui.fragments;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -34,7 +38,7 @@ import com.utopiaindustries.qualitychecker.apiservice.ApiServiceFactory;
|
||||||
import com.utopiaindustries.qualitychecker.models.InspectionItemCheckPoint;
|
import com.utopiaindustries.qualitychecker.models.InspectionItemCheckPoint;
|
||||||
import com.utopiaindustries.qualitychecker.models.InspectionItemDimension;
|
import com.utopiaindustries.qualitychecker.models.InspectionItemDimension;
|
||||||
import com.utopiaindustries.qualitychecker.models.InspectionReport;
|
import com.utopiaindustries.qualitychecker.models.InspectionReport;
|
||||||
import com.utopiaindustries.qualitychecker.models.SaveReportCallback;
|
import com.utopiaindustries.qualitychecker.models.callback.SaveReportCallback;
|
||||||
import com.utopiaindustries.qualitychecker.models.VoiceOfCustomer;
|
import com.utopiaindustries.qualitychecker.models.VoiceOfCustomer;
|
||||||
import com.utopiaindustries.qualitychecker.notification.NotificationHelper;
|
import com.utopiaindustries.qualitychecker.notification.NotificationHelper;
|
||||||
import com.utopiaindustries.qualitychecker.service.InspectionReportService;
|
import com.utopiaindustries.qualitychecker.service.InspectionReportService;
|
||||||
|
@ -79,6 +83,7 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
|
||||||
initializeViews( view );
|
initializeViews( view );
|
||||||
populateViews();
|
populateViews();
|
||||||
setOnClickListeners();
|
setOnClickListeners();
|
||||||
|
updateProfileViews();
|
||||||
vocRecyclerView.setLayoutManager( new LinearLayoutManager( getContext() ) );
|
vocRecyclerView.setLayoutManager( new LinearLayoutManager( getContext() ) );
|
||||||
itemDimensionsRecyclerView.setLayoutManager( new LinearLayoutManager( getContext() ) );
|
itemDimensionsRecyclerView.setLayoutManager( new LinearLayoutManager( getContext() ) );
|
||||||
|
|
||||||
|
@ -153,25 +158,31 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
|
||||||
progressBar.setVisibility(View.VISIBLE);
|
progressBar.setVisibility(View.VISIBLE);
|
||||||
NotificationHelper.showNotification(Objects.requireNonNull(getContext()),
|
NotificationHelper.showNotification(Objects.requireNonNull(getContext()),
|
||||||
"Utopia QA App",
|
"Utopia QA App",
|
||||||
"Report is uploading keep patience...");
|
"Report is saving keep patience...");
|
||||||
inspectionReportService.saveReport(store.getReport(), new SaveReportCallback() {
|
inspectionReportService.saveInLocalDb( getContext(), store.getReport(), new SaveReportCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
|
Handler handler = new Handler(Looper.getMainLooper());
|
||||||
|
handler.post(() -> {
|
||||||
Toast.makeText(getContext(), "Report saved Successfully", Toast.LENGTH_LONG).show();
|
Toast.makeText(getContext(), "Report saved Successfully", Toast.LENGTH_LONG).show();
|
||||||
progressBar.setVisibility(View.INVISIBLE);
|
progressBar.setVisibility(View.INVISIBLE);
|
||||||
Objects.requireNonNull(getActivity()).finish();
|
Objects.requireNonNull(getActivity()).finish();
|
||||||
NotificationHelper.showNotification(Objects.requireNonNull(getContext()),
|
NotificationHelper.showNotification(Objects.requireNonNull(getContext()),
|
||||||
"Utopia QA App",
|
"Utopia QA App",
|
||||||
"Report is uploaded successfully");
|
"Report is successfully saved");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable throwable) {
|
public void onFailure(Throwable throwable) {
|
||||||
|
Handler handler = new Handler(Looper.getMainLooper());
|
||||||
|
handler.post(() -> {
|
||||||
Toast.makeText(getContext(), throwable.getMessage(), Toast.LENGTH_LONG).show();
|
Toast.makeText(getContext(), throwable.getMessage(), Toast.LENGTH_LONG).show();
|
||||||
progressBar.setVisibility(View.INVISIBLE);
|
progressBar.setVisibility(View.INVISIBLE);
|
||||||
NotificationHelper.showNotification(Objects.requireNonNull(getContext()),
|
NotificationHelper.showNotification(Objects.requireNonNull(getContext()),
|
||||||
"Utopia QA App",
|
"Utopia QA App",
|
||||||
"Error in uploading report");
|
"Error in saving report");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
@ -236,12 +247,6 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
|
||||||
|
|
||||||
@SuppressLint("DefaultLocale")
|
@SuppressLint("DefaultLocale")
|
||||||
private void populateViews(){
|
private void populateViews(){
|
||||||
|
|
||||||
profileName.setText( store.getEmployeePhoto().getName() );
|
|
||||||
Glide.with( Objects.requireNonNull(getContext() ))
|
|
||||||
.load( store.getProfileImage( ) )
|
|
||||||
.into( profileImage );
|
|
||||||
|
|
||||||
generalRemarks.setText( store.getReport().getGeneralRemarks() );
|
generalRemarks.setText( store.getReport().getGeneralRemarks() );
|
||||||
|
|
||||||
ArrayAdapter<String> adapter = new ArrayAdapter<>( getContext(),
|
ArrayAdapter<String> adapter = new ArrayAdapter<>( getContext(),
|
||||||
|
@ -280,6 +285,7 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
|
||||||
for (InspectionItemCheckPoint itemCp : inspectionReport.getItems().get(0).getCheckPoints()) {
|
for (InspectionItemCheckPoint itemCp : inspectionReport.getItems().get(0).getCheckPoints()) {
|
||||||
for( int i = 0 ; i< itemCp.getDefectSeverites().size() ; i++ ){
|
for( int i = 0 ; i< itemCp.getDefectSeverites().size() ; i++ ){
|
||||||
String status = itemCp.getDefectSeverites().get( i );
|
String status = itemCp.getDefectSeverites().get( i );
|
||||||
|
System.out.println( status);
|
||||||
float quantity = itemCp.getQuantities().get(i);
|
float quantity = itemCp.getQuantities().get(i);
|
||||||
if( status.equalsIgnoreCase("minor") ){
|
if( status.equalsIgnoreCase("minor") ){
|
||||||
minor += (int) quantity;
|
minor += (int) quantity;
|
||||||
|
@ -301,21 +307,21 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
|
||||||
|
|
||||||
private void calculateDimensions(){
|
private void calculateDimensions(){
|
||||||
List<InspectionItemDimension> dimensions = store.getDimensions();
|
List<InspectionItemDimension> dimensions = store.getDimensions();
|
||||||
List<InspectionItemDimension> newDimensions = new ArrayList<>();
|
System.out.println( dimensions );
|
||||||
|
// List<InspectionItemDimension> newDimensions = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
if(! dimensions.isEmpty() ){
|
// if(! dimensions.isEmpty() ){
|
||||||
// calculations for averaging
|
// calculations for averaging
|
||||||
Map<String,List<InspectionItemDimension>> typeToDimensionsMap =
|
// Map<String,List<InspectionItemDimension>> typeToDimensionsMap =
|
||||||
dimensions.stream().collect(Collectors.groupingBy( InspectionItemDimension::getType) );
|
// dimensions.stream().collect(Collectors.groupingBy( InspectionItemDimension::getType) );
|
||||||
|
|
||||||
for( Map.Entry<String,List<InspectionItemDimension>> entry : typeToDimensionsMap.entrySet() ){
|
// for( Map.Entry<String,List<InspectionItemDimension>> entry : typeToDimensionsMap.entrySet() ){
|
||||||
InspectionItemDimension newDimen = getInspectionItemDimension( entry );
|
// InspectionItemDimension newDimen = getInspectionItemDimension( entry );
|
||||||
newDimensions.add( newDimen );
|
// newDimensions.add( newDimen );
|
||||||
}
|
// }
|
||||||
store.getReport().getItems().get(0).setDimensions( newDimensions );
|
store.getReport().getItems().get(0).setDimensions( dimensions );
|
||||||
ItemDimensionAdapter adapter = new ItemDimensionAdapter( store.getReport().getItems().get(0).getDimensions() );
|
ItemDimensionAdapter adapter = new ItemDimensionAdapter( dimensions );
|
||||||
itemDimensionsRecyclerView.setAdapter( adapter );
|
itemDimensionsRecyclerView.setAdapter( adapter );
|
||||||
}
|
|
||||||
} catch ( NullPointerException ex ){
|
} catch ( NullPointerException ex ){
|
||||||
Toast.makeText( getContext() , "Please fill the required Fields", Toast.LENGTH_LONG ).show();
|
Toast.makeText( getContext() , "Please fill the required Fields", Toast.LENGTH_LONG ).show();
|
||||||
}
|
}
|
||||||
|
@ -370,4 +376,12 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
|
||||||
backBtn.setOnClickListener( this );
|
backBtn.setOnClickListener( this );
|
||||||
openDimensionDialog.setOnClickListener( this);
|
openDimensionDialog.setOnClickListener( this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateProfileViews( ) throws NullPointerException{
|
||||||
|
SharedPreferences sharedPreferences = getActivity().getSharedPreferences("login_prefs", Context.MODE_PRIVATE);
|
||||||
|
profileName.setText( sharedPreferences.getString("name", null ) );
|
||||||
|
Glide.with( getContext() )
|
||||||
|
.load( store.getProfileImage( ) )
|
||||||
|
.into( profileImage );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
package com.utopiaindustries.qualitychecker.utils;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
|
|
||||||
|
public class FileUtils {
|
||||||
|
public static String writeFile( Context context ,
|
||||||
|
byte[] content,
|
||||||
|
String fileName ){
|
||||||
|
FileOutputStream fos = null;
|
||||||
|
try {
|
||||||
|
// Get the file path in the internal storage
|
||||||
|
File file = new File( context.getFilesDir(), fileName);
|
||||||
|
// Open the file output stream
|
||||||
|
fos = new FileOutputStream(file);
|
||||||
|
fos.write( content );
|
||||||
|
fos.flush();
|
||||||
|
return file.getAbsolutePath();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
if (fos != null) {
|
||||||
|
try {
|
||||||
|
fos.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] readFile(String filePath) throws IOException {
|
||||||
|
File file = new File(filePath);
|
||||||
|
try (FileInputStream fis = new FileInputStream(file);
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
int bytesRead;
|
||||||
|
while ((bytesRead = fis.read(buffer)) != -1) {
|
||||||
|
baos.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
return baos.toByteArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void deleteFile(String filePath) {
|
||||||
|
File file = new File(filePath);
|
||||||
|
if (file.exists()) {
|
||||||
|
if (file.delete()) {
|
||||||
|
System.out.println("File deleted successfully");
|
||||||
|
} else {
|
||||||
|
System.out.println("Failed to delete the file");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
System.out.println("File does not exist");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<solid android:color="#D0727377"/> <!-- Background color -->
|
||||||
|
<corners android:radius="20dp"/> <!-- Corner radius -->
|
||||||
|
</shape>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#818589" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||||
|
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M7,10l5,5 5,-5z"/>
|
||||||
|
|
||||||
|
</vector>
|
|
@ -48,7 +48,7 @@
|
||||||
android:id="@+id/username_title"
|
android:id="@+id/username_title"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Ameen ur Rehman"
|
android:text=""
|
||||||
android:textColor="#000000"
|
android:textColor="#000000"
|
||||||
android:textStyle="bold|italic"
|
android:textStyle="bold|italic"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
@ -143,5 +143,14 @@
|
||||||
android:layout_toStartOf="@id/refresh_btn"
|
android:layout_toStartOf="@id/refresh_btn"
|
||||||
android:text="Logout" />
|
android:text="Logout" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/fetch_product_btn"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignBaseline="@id/logout_btn"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:layout_toStartOf="@id/logout_btn"
|
||||||
|
android:text="Fetch" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -1,14 +1,22 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="50dp">
|
android:layout_height="50dp">
|
||||||
<Spinner
|
<AutoCompleteTextView
|
||||||
android:layout_width="wrap_content"
|
android:id="@+id/defect_spinner"
|
||||||
|
android:layout_width="250dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:layout_weight="1"
|
android:hint="Select an option"
|
||||||
android:padding="5dp"
|
android:drawableRight="@drawable/ic_down"
|
||||||
android:id="@+id/defect_spinner">
|
android:inputType="text" />
|
||||||
</Spinner>
|
<!-- <Spinner-->
|
||||||
|
<!-- android:layout_width="wrap_content"-->
|
||||||
|
<!-- android:layout_height="50dp"-->
|
||||||
|
<!-- android:layout_weight="1"-->
|
||||||
|
<!-- android:padding="5dp"-->
|
||||||
|
<!-- android:id="@+id/defect_spinner">-->
|
||||||
|
<!-- </Spinner>-->
|
||||||
|
|
||||||
<Spinner
|
<Spinner
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|
|
@ -47,7 +47,6 @@
|
||||||
android:id="@+id/textView4"
|
android:id="@+id/textView4"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Ameen ur Rehman"
|
|
||||||
android:textColor="#000000"
|
android:textColor="#000000"
|
||||||
android:textStyle="bold|italic"
|
android:textStyle="bold|italic"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
|
|
@ -1,15 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<network-security-config>
|
<network-security-config>
|
||||||
<base-config cleartextTrafficPermitted="true">
|
<domain-config cleartextTrafficPermitted="true">
|
||||||
<trust-anchors>
|
<domain includeSubdomains="true">192.168.91.16</domain>
|
||||||
<!-- Trust preinstalled CAs -->
|
|
||||||
<certificates src="system" />
|
|
||||||
</trust-anchors>
|
|
||||||
</base-config>
|
|
||||||
<domain-config>
|
|
||||||
<domain includeSubdomains="true">portal.utopiaindustries.pk</domain>
|
<domain includeSubdomains="true">portal.utopiaindustries.pk</domain>
|
||||||
<trust-anchors>
|
|
||||||
<certificates src="@raw/certificate"/>
|
|
||||||
</trust-anchors>
|
|
||||||
</domain-config>
|
</domain-config>
|
||||||
</network-security-config>
|
</network-security-config>
|
||||||
|
|
|
@ -16,8 +16,8 @@ dependencyResolutionManagement {
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
maven { url 'https://jitpack.io' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rootProject.name = "QualityChecker"
|
rootProject.name = "QualityChecker"
|
||||||
include ':app'
|
include ':app'
|
||||||
|
|
Loading…
Reference in New Issue