- minor changes
parent
1b1f9f711e
commit
6d9ba4d87b
|
@ -3,20 +3,7 @@
|
||||||
<component name="deploymentTargetDropDown">
|
<component name="deploymentTargetDropDown">
|
||||||
<value>
|
<value>
|
||||||
<entry key="app">
|
<entry key="app">
|
||||||
<State>
|
<State />
|
||||||
<targetSelectedWithDropDown>
|
|
||||||
<Target>
|
|
||||||
<type value="QUICK_BOOT_TARGET" />
|
|
||||||
<deviceKey>
|
|
||||||
<Key>
|
|
||||||
<type value="VIRTUAL_DEVICE_PATH" />
|
|
||||||
<value value="C:\Users\saif.haq\.android\avd\Medium_Tablet_API_28.avd" />
|
|
||||||
</Key>
|
|
||||||
</deviceKey>
|
|
||||||
</Target>
|
|
||||||
</targetSelectedWithDropDown>
|
|
||||||
<timeTargetWasSelectedWithDropDown value="2024-05-10T06:56:17.553115500Z" />
|
|
||||||
</State>
|
|
||||||
</entry>
|
</entry>
|
||||||
</value>
|
</value>
|
||||||
</component>
|
</component>
|
||||||
|
|
|
@ -18,7 +18,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="31"
|
||||||
|
android:usesCleartextTraffic="true">
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.google.zxing.client.android.CaptureActivity"
|
android:name="com.google.zxing.client.android.CaptureActivity"
|
||||||
|
|
|
@ -11,6 +11,7 @@ import com.utopiaindustries.qualitychecker.models.Product;
|
||||||
import com.utopiaindustries.qualitychecker.models.VoiceOfCustomer;
|
import com.utopiaindustries.qualitychecker.models.VoiceOfCustomer;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.http.Body;
|
import retrofit2.http.Body;
|
||||||
|
@ -39,7 +40,7 @@ public interface ApiService {
|
||||||
);
|
);
|
||||||
|
|
||||||
@POST("rest/uic/inspection-report")
|
@POST("rest/uic/inspection-report")
|
||||||
Call<InspectionReport> saveInspectionReport(
|
Call<Map<String,String>> saveInspectionReport(
|
||||||
@Body InspectionReport inspectionReport
|
@Body InspectionReport inspectionReport
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,9 @@ 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 = "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;
|
||||||
|
|
||||||
public synchronized static Retrofit getClient() {
|
public synchronized static Retrofit getClient() {
|
||||||
|
|
|
@ -12,6 +12,7 @@ import com.utopiaindustries.qualitychecker.store.Store;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
|
@ -96,17 +97,25 @@ public class InspectionReportService {
|
||||||
}
|
}
|
||||||
// post object
|
// post object
|
||||||
apiService.saveInspectionReport( inspectionReport ).enqueue(
|
apiService.saveInspectionReport( inspectionReport ).enqueue(
|
||||||
new Callback<InspectionReport>() {
|
new Callback<Map<String,String>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<InspectionReport> call, Response<InspectionReport> response) {
|
public void onResponse(Call<Map<String,String>> call,
|
||||||
if (response.isSuccessful()) {
|
Response<Map<String,String>> response) {
|
||||||
callback.onSuccess();
|
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 {
|
} else {
|
||||||
callback.onFailure(new Exception("API call failed with status code: " + response.code()));
|
callback.onFailure(new Exception("API call failed with status code: " + response.code()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Call<InspectionReport> call, Throwable t) {
|
public void onFailure(Call<Map<String,String>> call, Throwable t) {
|
||||||
|
System.out.println( t );
|
||||||
callback.onFailure( t );
|
callback.onFailure( t );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import android.widget.ArrayAdapter;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
@ -134,18 +135,26 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveReportDialog(){
|
private void saveReportDialog(){
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder( getContext() );
|
LayoutInflater inflater = LayoutInflater.from( getContext() );
|
||||||
builder.setTitle("So you want to save report?")
|
View dialogView = inflater.inflate( R.layout.save_report_dialog, null);
|
||||||
|
// progress bar
|
||||||
|
ProgressBar progressBar = dialogView.findViewById( R.id.save_report_progress );
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder( Objects.requireNonNull(getContext()) );
|
||||||
|
builder.setView( dialogView )
|
||||||
|
.setTitle("So you want to save report?")
|
||||||
.setPositiveButton( "Save",(dialog, which) -> {
|
.setPositiveButton( "Save",(dialog, which) -> {
|
||||||
|
progressBar.setVisibility( View.VISIBLE );
|
||||||
inspectionReportService.saveReport(store.getReport(), new SaveReportCallback() {
|
inspectionReportService.saveReport(store.getReport(), new SaveReportCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
Toast.makeText( getContext(), "Report saved Successfully", Toast.LENGTH_LONG ).show();
|
Toast.makeText( getContext(), "Report saved Successfully", Toast.LENGTH_LONG ).show();
|
||||||
|
progressBar.setVisibility( View.INVISIBLE );
|
||||||
Objects.requireNonNull( getActivity() ).finish();
|
Objects.requireNonNull( getActivity() ).finish();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable throwable) {
|
public void onFailure(Throwable throwable) {
|
||||||
Toast.makeText( getContext(), throwable.getMessage(), Toast.LENGTH_LONG ).show();
|
Toast.makeText( getContext(), throwable.getMessage(), Toast.LENGTH_LONG ).show();
|
||||||
|
progressBar.setVisibility( View.INVISIBLE );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
@ -242,17 +251,19 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
|
||||||
List<InspectionItemDimension> dimensions = store.getDimensions();
|
List<InspectionItemDimension> dimensions = store.getDimensions();
|
||||||
List<InspectionItemDimension> newDimensions = new ArrayList<>();
|
List<InspectionItemDimension> newDimensions = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
// calculations for averaging
|
if(! dimensions.isEmpty() ){
|
||||||
Map<String,List<InspectionItemDimension>> typeToDimensionsMap =
|
// calculations for averaging
|
||||||
dimensions.stream().collect(Collectors.groupingBy( InspectionItemDimension::getType) );
|
Map<String,List<InspectionItemDimension>> typeToDimensionsMap =
|
||||||
|
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 );
|
||||||
|
ItemDimensionAdapter adapter = new ItemDimensionAdapter( store.getReport().getItems().get(0).getDimensions() );
|
||||||
|
itemDimensionsRecyclerView.setAdapter( adapter );
|
||||||
}
|
}
|
||||||
store.getReport().getItems().get(0).setDimensions( newDimensions );
|
|
||||||
ItemDimensionAdapter adapter = new ItemDimensionAdapter( store.getReport().getItems().get(0).getDimensions() );
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="16dp"
|
||||||
|
android:id="@+id/save_report_progress"
|
||||||
|
android:visibility="invisible"
|
||||||
|
>
|
||||||
|
</ProgressBar>
|
||||||
|
|
||||||
|
|
||||||
|
</RelativeLayout>
|
Loading…
Reference in New Issue