- minor changes

main
saif 2024-05-14 12:07:12 +05:00
parent 1b1f9f711e
commit 6d9ba4d87b
7 changed files with 59 additions and 32 deletions

View File

@ -3,20 +3,7 @@
<component name="deploymentTargetDropDown">
<value>
<entry key="app">
<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>
<State />
</entry>
</value>
</component>

View File

@ -18,7 +18,8 @@
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:targetApi="31">
tools:targetApi="31"
android:usesCleartextTraffic="true">
<activity
android:name="com.google.zxing.client.android.CaptureActivity"

View File

@ -11,6 +11,7 @@ import com.utopiaindustries.qualitychecker.models.Product;
import com.utopiaindustries.qualitychecker.models.VoiceOfCustomer;
import java.util.List;
import java.util.Map;
import retrofit2.Call;
import retrofit2.http.Body;
@ -39,7 +40,7 @@ public interface ApiService {
);
@POST("rest/uic/inspection-report")
Call<InspectionReport> saveInspectionReport(
Call<Map<String,String>> saveInspectionReport(
@Body InspectionReport inspectionReport
);

View File

@ -8,7 +8,9 @@ import retrofit2.converter.gson.GsonConverterFactory;
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 static Retrofit retrofit;
public synchronized static Retrofit getClient() {

View File

@ -12,6 +12,7 @@ import com.utopiaindustries.qualitychecker.store.Store;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import retrofit2.Call;
@ -96,17 +97,25 @@ public class InspectionReportService {
}
// post object
apiService.saveInspectionReport( inspectionReport ).enqueue(
new Callback<InspectionReport>() {
new Callback<Map<String,String>>() {
@Override
public void onResponse(Call<InspectionReport> call, Response<InspectionReport> response) {
if (response.isSuccessful()) {
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<InspectionReport> call, Throwable t) {
public void onFailure(Call<Map<String,String>> call, Throwable t) {
System.out.println( t );
callback.onFailure( t );
}
}

View File

@ -12,6 +12,7 @@ import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
@ -134,18 +135,26 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
}
private void saveReportDialog(){
AlertDialog.Builder builder = new AlertDialog.Builder( getContext() );
builder.setTitle("So you want to save report?")
LayoutInflater inflater = LayoutInflater.from( getContext() );
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) -> {
progressBar.setVisibility( View.VISIBLE );
inspectionReportService.saveReport(store.getReport(), new SaveReportCallback() {
@Override
public void onSuccess() {
Toast.makeText( getContext(), "Report saved Successfully", Toast.LENGTH_LONG ).show();
progressBar.setVisibility( View.INVISIBLE );
Objects.requireNonNull( getActivity() ).finish();
}
@Override
public void onFailure(Throwable throwable) {
Toast.makeText( getContext(), throwable.getMessage(), Toast.LENGTH_LONG ).show();
progressBar.setVisibility( View.INVISIBLE );
}
});
})
@ -242,6 +251,7 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
List<InspectionItemDimension> dimensions = store.getDimensions();
List<InspectionItemDimension> newDimensions = new ArrayList<>();
try {
if(! dimensions.isEmpty() ){
// calculations for averaging
Map<String,List<InspectionItemDimension>> typeToDimensionsMap =
dimensions.stream().collect(Collectors.groupingBy( InspectionItemDimension::getType) );
@ -253,6 +263,7 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
store.getReport().getItems().get(0).setDimensions( newDimensions );
ItemDimensionAdapter adapter = new ItemDimensionAdapter( store.getReport().getItems().get(0).getDimensions() );
itemDimensionsRecyclerView.setAdapter( adapter );
}
} catch ( NullPointerException ex ){
Toast.makeText( getContext() , "Please fill the required Fields", Toast.LENGTH_LONG ).show();
}

View File

@ -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>