- minor changes

main
saif 2024-09-19 12:45:26 +05:00
parent e7e736c468
commit ee37ff3cf4
4 changed files with 35 additions and 19 deletions

View File

@ -19,8 +19,8 @@ import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.converter.gson.GsonConverterFactory;
public class RetrofitClient { public class RetrofitClient {
// private final static String BASE_URL = "https://portal.utopiaindustries.pk/uind/"; private final static String BASE_URL = "https://portal.utopiaindustries.pk/uind/";
private final static String BASE_URL = "http://192.168.91.16:8080/uind/"; // private final static String BASE_URL = "http://192.168.91.16:8080/uind/";
private static Retrofit retrofit; private static Retrofit retrofit;

View File

@ -1,5 +1,6 @@
package com.utopiaindustries.qualitychecker.service; package com.utopiaindustries.qualitychecker.service;
import android.annotation.SuppressLint;
import android.app.Service; import android.app.Service;
import android.content.Intent; import android.content.Intent;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
@ -13,6 +14,7 @@ import com.utopiaindustries.qualitychecker.db.ReportRepository;
import com.utopiaindustries.qualitychecker.models.InspectionReport; import com.utopiaindustries.qualitychecker.models.InspectionReport;
import com.utopiaindustries.qualitychecker.models.InspectionReportWrapper; import com.utopiaindustries.qualitychecker.models.InspectionReportWrapper;
import com.utopiaindustries.qualitychecker.models.callback.SaveReportCallback; import com.utopiaindustries.qualitychecker.models.callback.SaveReportCallback;
import com.utopiaindustries.qualitychecker.notification.NotificationHelper;
import com.utopiaindustries.qualitychecker.utils.FileUtils; import com.utopiaindustries.qualitychecker.utils.FileUtils;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@ -69,26 +71,40 @@ public class NetworkService extends Service {
} }
} }
@SuppressLint("DefaultLocale")
private void pushDataToInternet() { private void pushDataToInternet() {
ReportRepository repository = new ReportRepository( this ); ReportRepository repository = new ReportRepository( this );
List<InspectionReportWrapper> reportWrappers = repository.findAllUnsynced(); List<InspectionReportWrapper> reportWrappers = repository.findAllUnsynced();
InspectionReportService service = InspectionReportService.getInstance(); InspectionReportService service = InspectionReportService.getInstance();
try { try {
List<InspectionReport> reports = getReports( reportWrappers ); List<InspectionReport> reports = getReports( reportWrappers );
for ( InspectionReport report : reports ){ int size = reports.size();
service.saveReport(report, new SaveReportCallback() { if( size > 0 ){
@Override NotificationHelper.showNotification(
public void onSuccess() { this,
// update status "Uploading Reports",
repository.updateSyncStatus( report.getWrapperId() ); String.format(" %d report(s) uploading..", reports.size() )
// remove file );
FileUtils.deleteFile( report.getFilePath() ); for ( InspectionReport report : reports ){
} service.saveReport(report, new SaveReportCallback() {
@Override @Override
public void onFailure(Throwable throwable) { public void onSuccess() {
// update status
repository.updateSyncStatus( report.getWrapperId() );
// remove file
FileUtils.deleteFile( report.getFilePath() );
}
@Override
public void onFailure(Throwable throwable) {
} }
}); });
}
NotificationHelper.showNotification(
this,
"Uploading Reports",
String.format(" %d report(s) uploaded successfully..", reports.size() )
);
} }
} catch ( Exception e ) { } catch ( Exception e ) {
e.printStackTrace(); e.printStackTrace();

View File

@ -366,7 +366,7 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
if( populateMarketplace ){ if( populateMarketplace ){
populateMarketplaces( products ); populateMarketplaces( products );
} }
populateMmodelNumber(products ); populateModelNumber(products );
populateTitle( products ); populateTitle( products );
populateColor( products ); populateColor( products );
populateSize( products ); populateSize( products );
@ -451,7 +451,7 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
} }
private void populateMmodelNumber( List<Product> products ){ private void populateModelNumber( 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().filter(Objects::nonNull).collect(Collectors.toList() ) ; modelNumbers = products.stream().map( Product::getModelNumber ).distinct().filter(Objects::nonNull).collect(Collectors.toList() ) ;
@ -461,7 +461,7 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
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).setModelNumber( modelOption );
} }
} }

View File

@ -9,6 +9,6 @@
<color name="success">#20830E</color> <color name="success">#20830E</color>
<color name="red">#FF0000</color> <color name="red">#FF0000</color>
<color name="light_blue">#29DAF1</color> <color name="light_blue">#29DAF1</color>
<color name="light_blue_2">#6DE2F1</color> <color name="light_blue_2">#AFEEF6</color>
<color name="cp_bg_color">#FFFFFF</color> <color name="cp_bg_color">#FFFFFF</color>
</resources> </resources>