parent
c574fa1199
commit
05f5b337f1
|
@ -19,12 +19,10 @@ import androidx.core.view.WindowInsetsCompat;
|
|||
import com.utopiaindustries.hseobservationsapp.R;
|
||||
import com.utopiaindustries.hseobservationsapp.adapters.ObservationClassAdapter;
|
||||
import com.utopiaindustries.hseobservationsapp.adapters.ObservationSubClassAdapter;
|
||||
import com.utopiaindustries.hseobservationsapp.adapters.ShiftAdapter;
|
||||
import com.utopiaindustries.hseobservationsapp.helper.Helper;
|
||||
import com.utopiaindustries.hseobservationsapp.models.HseData.HseObservationClass;
|
||||
import com.utopiaindustries.hseobservationsapp.models.HseData.HseObservationSubClass;
|
||||
import com.utopiaindustries.hseobservationsapp.models.HseData.Site;
|
||||
import com.utopiaindustries.hseobservationsapp.models.Shift;
|
||||
import com.utopiaindustries.hseobservationsapp.utils.ObservationStorageManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -93,6 +91,8 @@ public class ObservationOneActivity extends AppCompatActivity {
|
|||
observationClass = obClassArrayList.get(position).getTitle();
|
||||
HseObservationClass clickedItem = obClassArrayList.get(position);
|
||||
|
||||
ObservationStorageManager.getInstance().setObservationClassId(clickedItem.getId());
|
||||
|
||||
observationSubTextview.setText(null);
|
||||
|
||||
Log.e("ob-Sub-Class: ",""+obSubClassArrayList_temp.size());
|
||||
|
@ -102,13 +102,6 @@ public class ObservationOneActivity extends AppCompatActivity {
|
|||
.filter(item -> Objects.equals(item.getObservationClassId(), clickedItem.getId()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Log.e("clickedItem.getId(): ",""+clickedItem.getId());
|
||||
Log.e("filteredUnitItems: ",""+filteredUnitItems.size());
|
||||
|
||||
for (int i = 0; i < obSubClassArrayList_temp.size(); i++) {
|
||||
Log.e("Sub-Items: ",""+obSubClassArrayList_temp.get(i).getId());
|
||||
}
|
||||
|
||||
obSubClassArrayList.clear();
|
||||
obSubClassArrayList.addAll(filteredUnitItems);
|
||||
observationSubClassAdapter = new ObservationSubClassAdapter(ObservationOneActivity.this, filteredUnitItems);
|
||||
|
@ -123,7 +116,7 @@ public class ObservationOneActivity extends AppCompatActivity {
|
|||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
// Perform action when shiftTextview item is clicked
|
||||
//Toast.makeText(ObservationOneActivity.this, "Item clicked: " + obSubClassArrayList.get(position).getTitle(), Toast.LENGTH_SHORT).show();
|
||||
|
||||
ObservationStorageManager.getInstance().setObservationSubClassId(obSubClassArrayList.get(position).getId());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,22 +1,48 @@
|
|||
package com.utopiaindustries.hseobservationsapp.activities.ObservationForms;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.utopiaindustries.hseobservationsapp.R;
|
||||
import com.utopiaindustries.hseobservationsapp.activities.DashboardActivity;
|
||||
import com.utopiaindustries.hseobservationsapp.activities.PermitToWorkForms.PermitTwoActivity;
|
||||
import com.utopiaindustries.hseobservationsapp.activities.LoginActivity;
|
||||
import com.utopiaindustries.hseobservationsapp.helper.Helper;
|
||||
import com.utopiaindustries.hseobservationsapp.helper.Preference;
|
||||
import com.utopiaindustries.hseobservationsapp.utils.HSERequestModel;
|
||||
import com.utopiaindustries.hseobservationsapp.utils.ObservationStorageManager;
|
||||
import com.utopiaindustries.hseobservationsapp.utils.ProgressDialogFragment;
|
||||
import com.utopiaindustries.hseobservationsapp.viewmodels.LoginViewModel;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.Map;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
|
||||
public class ObservationThreeActivity extends AppCompatActivity {
|
||||
|
@ -25,6 +51,8 @@ public class ObservationThreeActivity extends AppCompatActivity {
|
|||
ImageView imgBack;
|
||||
Button btnSubmit, btnDraft;
|
||||
|
||||
LoginViewModel loginViewModel;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -49,13 +77,9 @@ public class ObservationThreeActivity extends AppCompatActivity {
|
|||
{
|
||||
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||
if (checkedId == R.id.rb_open) {
|
||||
// do operations specific to this selection
|
||||
// Toast.makeText(GeneralDetailActivity.this,"GPS Yes",Toast.LENGTH_SHORT).show();
|
||||
//bool_gps = true;
|
||||
ObservationStorageManager.getInstance().setObservationStatus(true);
|
||||
} else if (checkedId == R.id.rb_closed) {
|
||||
// do operations specific to this selection
|
||||
// Toast.makeText(GeneralDetailActivity.this,"GPS No",Toast.LENGTH_SHORT).show();
|
||||
//bool_gps = false;
|
||||
ObservationStorageManager.getInstance().setObservationStatus(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -63,12 +87,14 @@ public class ObservationThreeActivity extends AppCompatActivity {
|
|||
btnSubmit.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Toast.makeText(ObservationThreeActivity.this,"Reported Submitted",Toast.LENGTH_SHORT).show();
|
||||
|
||||
alertReportSubmit(ObservationThreeActivity.this);
|
||||
/*Toast.makeText(ObservationThreeActivity.this,"Reported Submitted",Toast.LENGTH_SHORT).show();
|
||||
Intent intent = new Intent(ObservationThreeActivity.this, DashboardActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
|
||||
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);*/
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -87,5 +113,127 @@ public class ObservationThreeActivity extends AppCompatActivity {
|
|||
|
||||
btnSubmit = findViewById(R.id.btn_submit);
|
||||
btnDraft = findViewById(R.id.btn_draft);
|
||||
|
||||
loginViewModel = new ViewModelProvider(this).get(LoginViewModel.class);
|
||||
|
||||
loginViewModel.getLoadingState().observe(this, isLoading -> {
|
||||
|
||||
if (isLoading != null && isLoading) {
|
||||
showProgressDialog();
|
||||
} else {
|
||||
dismissProgressDialog();
|
||||
}
|
||||
});
|
||||
|
||||
loginViewModel.getErrorMessage().observe(this, errorResponse -> {
|
||||
Toast.makeText(this, errorResponse, Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
|
||||
loginViewModel.getUserSaveLiveData().observe(this, hseSaveResponse -> {
|
||||
if (hseSaveResponse != null && hseSaveResponse.getStatus().equals("success")) {
|
||||
Toast.makeText(this, "Reported Submitted", Toast.LENGTH_SHORT).show();
|
||||
Intent intent = new Intent(ObservationThreeActivity.this, DashboardActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void alertReportSubmit(Context con) {
|
||||
ViewGroup viewGroup = findViewById(android.R.id.content);
|
||||
|
||||
TextView dialogOkBtn, dialogCancelBtn;
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(con);
|
||||
View view1 = LayoutInflater.from(con).inflate(R.layout.custom_layout_for_report_submission, viewGroup, false);
|
||||
builder.setCancelable(false);
|
||||
builder.setView(view1);
|
||||
|
||||
dialogOkBtn = view1.findViewById(R.id.dialogOkBtn);
|
||||
dialogCancelBtn = view1.findViewById(R.id.dialogCancelBtn);
|
||||
|
||||
AlertDialog alertDialog = builder.create();
|
||||
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
|
||||
dialogOkBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
alertDialog.dismiss();
|
||||
|
||||
// byte[] reportBytes = convertReportToByteArray();
|
||||
HSERequestModel requestModel = new HSERequestModel();
|
||||
requestModel.setSite_id(ObservationStorageManager.getInstance().getSiteId());
|
||||
requestModel.setSupervisorId(ObservationStorageManager.getInstance().getSupervisorId());
|
||||
requestModel.setObservation_date(ObservationStorageManager.getInstance().getReportDate());
|
||||
requestModel.setShift(ObservationStorageManager.getInstance().getShiftName());
|
||||
requestModel.setRecordTypeId(ObservationStorageManager.getInstance().getRecordTypeId());
|
||||
requestModel.setHseReportObservationRecord(ObservationStorageManager.getInstance());
|
||||
|
||||
// gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
//String jsonRequest = gson.toJson(requestModel);
|
||||
// Log.e("RequestModel JSON", requestModel.toString());
|
||||
|
||||
loginViewModel.saveHSEData(requestModel);
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
dialogCancelBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
alertDialog.dismiss();
|
||||
//Toast.makeText(con, "Cancel", Toast.LENGTH_SHORT).show();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
alertDialog.show();
|
||||
}
|
||||
|
||||
private byte[] convertReportToByteArray() {
|
||||
byte[] bytes = new byte[0];
|
||||
ByteArrayOutputStream byteArrayOutputStream = null;
|
||||
ObjectOutputStream objectOutputStream = null;
|
||||
try {
|
||||
ObservationStorageManager observationStorageManager = ObservationStorageManager.getInstance();
|
||||
// convert into byte array
|
||||
byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
objectOutputStream = new ObjectOutputStream( byteArrayOutputStream );
|
||||
objectOutputStream.writeObject( observationStorageManager );
|
||||
objectOutputStream.flush();
|
||||
bytes = byteArrayOutputStream.toByteArray();
|
||||
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
if (objectOutputStream != null) objectOutputStream.close();
|
||||
if (byteArrayOutputStream != null) byteArrayOutputStream.close();
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public void showProgressDialog() {
|
||||
ProgressDialogFragment progressDialog = new ProgressDialogFragment();
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show(getSupportFragmentManager(), "progressDialog");
|
||||
}
|
||||
|
||||
public void dismissProgressDialog() {
|
||||
ProgressDialogFragment progressDialog = (ProgressDialogFragment)
|
||||
getSupportFragmentManager().findFragmentByTag("progressDialog");
|
||||
if (progressDialog != null) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
package com.utopiaindustries.hseobservationsapp.activities.ObservationForms;
|
||||
|
||||
import static com.utopiaindustries.hseobservationsapp.R.*;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ActivityNotFoundException;
|
||||
|
@ -40,14 +38,11 @@ import androidx.core.view.WindowInsetsCompat;
|
|||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.utopiaindustries.hseobservationsapp.R;
|
||||
import com.utopiaindustries.hseobservationsapp.activities.DashboardActivity;
|
||||
import com.utopiaindustries.hseobservationsapp.activities.LoginActivity;
|
||||
import com.utopiaindustries.hseobservationsapp.adapters.DepartmentAdapter;
|
||||
import com.utopiaindustries.hseobservationsapp.adapters.ObservationClassAdapter;
|
||||
import com.utopiaindustries.hseobservationsapp.adapters.ObservationSubClassAdapter;
|
||||
import com.utopiaindustries.hseobservationsapp.adapters.RiskLevelAdapter;
|
||||
import com.utopiaindustries.hseobservationsapp.models.Department;
|
||||
import com.utopiaindustries.hseobservationsapp.models.Shift;
|
||||
import com.utopiaindustries.hseobservationsapp.helper.Helper;
|
||||
import com.utopiaindustries.hseobservationsapp.models.HseData.HseDepartment;
|
||||
import com.utopiaindustries.hseobservationsapp.utils.ObservationStorageManager;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
|
@ -57,7 +52,9 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import pub.devrel.easypermissions.AfterPermissionGranted;
|
||||
import pub.devrel.easypermissions.AppSettingsDialog;
|
||||
|
@ -74,8 +71,10 @@ public class ObservationTwoActivity extends AppCompatActivity implements EasyPer
|
|||
private DepartmentAdapter departmentAdapter;
|
||||
private RiskLevelAdapter riskLevelAdapter;
|
||||
|
||||
private ArrayList<Shift> departmentArrayList = new ArrayList<>();
|
||||
private ArrayList<Shift> riskLevelArrayList = new ArrayList<>();
|
||||
private ArrayList<HseDepartment> departmentArrayList = new ArrayList<>();
|
||||
private ArrayList<HseDepartment> departmentArrayList_temp = new ArrayList<>();
|
||||
|
||||
private ArrayList<String> riskLevelArrayList = new ArrayList<>();
|
||||
|
||||
private static final int CAMERA_REQUEST = 100;
|
||||
private static final int GALLERY_REQUEST = 200;
|
||||
|
@ -105,6 +104,10 @@ public class ObservationTwoActivity extends AppCompatActivity implements EasyPer
|
|||
.placeholder(R.drawable.img_load)
|
||||
.apply(new RequestOptions().centerCrop())
|
||||
.into(imgBefore);
|
||||
|
||||
List<byte[]> tempList = new ArrayList<>();
|
||||
tempList.add(compressedImage);
|
||||
ObservationStorageManager.getInstance().setBeforePictures(tempList);
|
||||
});
|
||||
},
|
||||
error -> {
|
||||
|
@ -129,6 +132,10 @@ public class ObservationTwoActivity extends AppCompatActivity implements EasyPer
|
|||
.placeholder(R.drawable.img_load)
|
||||
.apply(new RequestOptions().centerCrop())
|
||||
.into(imgAfter);
|
||||
|
||||
List<byte[]> tempList = new ArrayList<>();
|
||||
tempList.add(compressedImage);
|
||||
ObservationStorageManager.getInstance().setAfterPictures(tempList);
|
||||
});
|
||||
},
|
||||
error -> {
|
||||
|
@ -169,6 +176,10 @@ public class ObservationTwoActivity extends AppCompatActivity implements EasyPer
|
|||
.placeholder(R.drawable.img_load)
|
||||
.apply(new RequestOptions().centerCrop())
|
||||
.into(imgBefore);
|
||||
|
||||
List<byte[]> tempList = new ArrayList<>();
|
||||
tempList.add(compressedImage);
|
||||
ObservationStorageManager.getInstance().setBeforePictures(tempList);
|
||||
});
|
||||
},
|
||||
error -> {
|
||||
|
@ -194,6 +205,10 @@ public class ObservationTwoActivity extends AppCompatActivity implements EasyPer
|
|||
.placeholder(R.drawable.img_load)
|
||||
.apply(new RequestOptions().centerCrop())
|
||||
.into(imgAfter);
|
||||
|
||||
List<byte[]> tempList = new ArrayList<>();
|
||||
tempList.add(compressedImage);
|
||||
ObservationStorageManager.getInstance().setAfterPictures(tempList);
|
||||
});
|
||||
},
|
||||
error -> {
|
||||
|
@ -274,6 +289,7 @@ public class ObservationTwoActivity extends AppCompatActivity implements EasyPer
|
|||
departmentTextview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
ObservationStorageManager.getInstance().setDepartmentId(departmentArrayList.get(position).getId());
|
||||
|
||||
}
|
||||
});
|
||||
|
@ -282,6 +298,8 @@ public class ObservationTwoActivity extends AppCompatActivity implements EasyPer
|
|||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
|
||||
ObservationStorageManager.getInstance().setRiskLevel(riskLevelArrayList.get(position));
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -300,8 +318,23 @@ public class ObservationTwoActivity extends AppCompatActivity implements EasyPer
|
|||
departmentTextview = findViewById(R.id.department_textview);
|
||||
riskLevelTextview = findViewById(R.id.risk_textview);
|
||||
|
||||
departmentAdapter = new DepartmentAdapter(this, departmentArrayList);
|
||||
departmentTextview.setAdapter(departmentAdapter);
|
||||
departmentArrayList_temp.addAll(Helper.getList(Helper.hseDepartment, this, HseDepartment.class));
|
||||
|
||||
if (!departmentArrayList_temp.isEmpty()) {
|
||||
|
||||
List<HseDepartment> filteredUnitItems = departmentArrayList_temp.stream()
|
||||
.filter(item -> Objects.equals(item.getSiteId(), ObservationStorageManager.getInstance().getSiteId()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
departmentArrayList.clear();
|
||||
departmentArrayList.addAll(filteredUnitItems);
|
||||
departmentAdapter = new DepartmentAdapter(this, departmentArrayList);
|
||||
departmentTextview.setAdapter(departmentAdapter);
|
||||
}
|
||||
|
||||
riskLevelArrayList.add("High");
|
||||
riskLevelArrayList.add("Medium");
|
||||
riskLevelArrayList.add("Low");
|
||||
|
||||
riskLevelAdapter = new RiskLevelAdapter(this, riskLevelArrayList);
|
||||
riskLevelTextview.setAdapter(riskLevelAdapter);
|
||||
|
|
|
@ -8,16 +8,17 @@ import android.widget.ArrayAdapter;
|
|||
import android.widget.TextView;
|
||||
|
||||
import com.utopiaindustries.hseobservationsapp.R;
|
||||
import com.utopiaindustries.hseobservationsapp.models.HseData.HseDepartment;
|
||||
import com.utopiaindustries.hseobservationsapp.models.Shift;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DepartmentAdapter extends ArrayAdapter<Shift> {
|
||||
public class DepartmentAdapter extends ArrayAdapter<HseDepartment> {
|
||||
|
||||
private final Context context;
|
||||
private final List<Shift> items;
|
||||
private final List<HseDepartment> items;
|
||||
|
||||
public DepartmentAdapter(Context context, List<Shift> items) {
|
||||
public DepartmentAdapter(Context context, List<HseDepartment> items) {
|
||||
super(context, 0, items);
|
||||
this.context = context;
|
||||
this.items = items;
|
||||
|
@ -29,7 +30,7 @@ public class DepartmentAdapter extends ArrayAdapter<Shift> {
|
|||
convertView = LayoutInflater.from(context).inflate(R.layout.list_items, parent, false);
|
||||
}
|
||||
|
||||
Shift item = items.get(position);
|
||||
HseDepartment item = items.get(position);
|
||||
|
||||
TextView titleTextView = convertView.findViewById(R.id.item_text);
|
||||
|
||||
|
|
|
@ -12,12 +12,12 @@ import com.utopiaindustries.hseobservationsapp.models.Shift;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public class RiskLevelAdapter extends ArrayAdapter<Shift> {
|
||||
public class RiskLevelAdapter extends ArrayAdapter<String> {
|
||||
|
||||
private final Context context;
|
||||
private final List<Shift> items;
|
||||
private final List<String> items;
|
||||
|
||||
public RiskLevelAdapter(Context context, List<Shift> items) {
|
||||
public RiskLevelAdapter(Context context, List<String> items) {
|
||||
super(context, 0, items);
|
||||
this.context = context;
|
||||
this.items = items;
|
||||
|
@ -29,11 +29,11 @@ public class RiskLevelAdapter extends ArrayAdapter<Shift> {
|
|||
convertView = LayoutInflater.from(context).inflate(R.layout.list_items, parent, false);
|
||||
}
|
||||
|
||||
Shift item = items.get(position);
|
||||
String item = items.get(position);
|
||||
|
||||
TextView titleTextView = convertView.findViewById(R.id.item_text);
|
||||
|
||||
titleTextView.setText(item.getTitle());
|
||||
titleTextView.setText(item);
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package com.utopiaindustries.hseobservationsapp.apiservice;
|
||||
|
||||
import com.utopiaindustries.hseobservationsapp.models.HseData.HseResponse;
|
||||
import com.utopiaindustries.hseobservationsapp.models.HseData.HseSaveResponse;
|
||||
import com.utopiaindustries.hseobservationsapp.models.QualityControl;
|
||||
import com.utopiaindustries.hseobservationsapp.models.QualityControlResponse;
|
||||
import com.utopiaindustries.hseobservationsapp.models.QualitySaveResponse;
|
||||
import com.utopiaindustries.hseobservationsapp.utils.HSERequestModel;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.Body;
|
||||
|
@ -21,10 +23,9 @@ public interface ApiService {
|
|||
@GET("rest/uic/hse/get-hse-report-data")
|
||||
Call<HseResponse> getHseData();
|
||||
|
||||
|
||||
@POST("rest/uic/quality-control/save-quality-control")
|
||||
Call<QualitySaveResponse> saveQualityControlReport(
|
||||
@Body QualityControl request
|
||||
@POST("rest/uic/hse/save-hse-report")
|
||||
Call<HseSaveResponse> saveHseReport(
|
||||
@Body HSERequestModel request
|
||||
);
|
||||
|
||||
@POST("rest/authentication/authenticate-user")
|
||||
|
|
|
@ -38,6 +38,7 @@ import com.utopiaindustries.hseobservationsapp.models.HseData.RecordType;
|
|||
import com.utopiaindustries.hseobservationsapp.models.HseData.Site;
|
||||
import com.utopiaindustries.hseobservationsapp.models.HseData.Supervisor;
|
||||
import com.utopiaindustries.hseobservationsapp.models.Shift;
|
||||
import com.utopiaindustries.hseobservationsapp.utils.ObservationStorageManager;
|
||||
import com.utopiaindustries.hseobservationsapp.utils.ProgressDialogFragment;
|
||||
import com.utopiaindustries.hseobservationsapp.viewmodels.LoginViewModel;
|
||||
|
||||
|
@ -108,6 +109,7 @@ public class HomeFragment extends Fragment {
|
|||
siteName = siteArrayList.get(position).getTitle();
|
||||
Site clickedItem = siteArrayList.get(position);
|
||||
supervisorTextView.setText(null);
|
||||
ObservationStorageManager.getInstance().setSiteId(clickedItem.getId());
|
||||
|
||||
if (!supervisorArrayList_temp.isEmpty()) {
|
||||
List<Supervisor> filteredUnitItems = supervisorArrayList_temp.stream()
|
||||
|
@ -123,12 +125,22 @@ public class HomeFragment extends Fragment {
|
|||
}
|
||||
});
|
||||
|
||||
supervisorTextView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
// Perform action when supervisorTextView item is clicked
|
||||
//Toast.makeText(getActivity(), "Item clicked: " + supervisorArrayList.get(position).getTitle(), Toast.LENGTH_SHORT).show();
|
||||
ObservationStorageManager.getInstance().setSupervisorId(supervisorArrayList.get(position).getId());
|
||||
}
|
||||
});
|
||||
|
||||
shiftTextview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
// Perform action when shiftTextview item is clicked
|
||||
//Toast.makeText(getActivity(), "Item clicked: " + shiftArrayList.get(position).getTitle(), Toast.LENGTH_SHORT).show();
|
||||
shiftName = shiftArrayList.get(position).getTitle();
|
||||
ObservationStorageManager.getInstance().setShiftName(shiftName);
|
||||
|
||||
}
|
||||
});
|
||||
|
@ -139,6 +151,7 @@ public class HomeFragment extends Fragment {
|
|||
// Perform action when formTextview item is clicked
|
||||
// Toast.makeText(getActivity(), "Item clicked: " + formArrayList.get(position).getTitle(), Toast.LENGTH_SHORT).show();
|
||||
selectedOption = recordTypeArrayList.get(position).getId();
|
||||
ObservationStorageManager.getInstance().setRecordTypeId(selectedOption);
|
||||
|
||||
}
|
||||
});
|
||||
|
@ -341,9 +354,10 @@ public class HomeFragment extends Fragment {
|
|||
// Month is 0-indexed, so we add 1
|
||||
Calendar selectedCalendar = Calendar.getInstance();
|
||||
selectedCalendar.set(year, monthOfYear, dayOfMonth);
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy", Locale.getDefault());
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
|
||||
String selectedDate = dateFormat.format(selectedCalendar.getTime());
|
||||
txtDate.setText(selectedDate);
|
||||
ObservationStorageManager.getInstance().setReportDate(selectedDate);
|
||||
}
|
||||
},
|
||||
year, month, day
|
||||
|
|
|
@ -40,4 +40,9 @@ public class HseDepartment {
|
|||
this.siteId = siteId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return title;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
package com.utopiaindustries.hseobservationsapp.models.HseData;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class HseSaveResponse {
|
||||
|
||||
@SerializedName("status")
|
||||
@Expose
|
||||
private String status;
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package com.utopiaindustries.hseobservationsapp.utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class HSEReportActivityRequestModel {
|
||||
|
||||
private long id;
|
||||
private String activityName;
|
||||
private String description;
|
||||
private long reportId;
|
||||
private List<byte[]> pictures;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getActivityName() {
|
||||
return activityName;
|
||||
}
|
||||
|
||||
public void setActivityName(String activityName) {
|
||||
this.activityName = activityName;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public long getReportId() {
|
||||
return reportId;
|
||||
}
|
||||
|
||||
public void setReportId(long reportId) {
|
||||
this.reportId = reportId;
|
||||
}
|
||||
|
||||
public List<byte[]> getPictures() {
|
||||
return pictures;
|
||||
}
|
||||
|
||||
public void setPictures(List<byte[]> pictures) {
|
||||
this.pictures = pictures;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
package com.utopiaindustries.hseobservationsapp.utils;
|
||||
|
||||
public class HSERequestModel {
|
||||
|
||||
private long id;
|
||||
private long site_id;
|
||||
private String code;
|
||||
private long supervisorId;
|
||||
private String observation_date;
|
||||
private String shift;
|
||||
private String createdBy;
|
||||
private String createdAt;
|
||||
private long recordTypeId;
|
||||
private ObservationStorageManager hseReportObservationRecord;
|
||||
/*private HseReportInjuryRecord hseReportInjuryRecord;
|
||||
private HseReportActivityRecord hseReportActivityRecord;
|
||||
private HseReportSafetyTrainingRecord hseReportSafetyTrainingRecord;
|
||||
private HseReportPermitToWorkRecord hseReportPermitToWorkRecord;*/
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public long getSite_id() {
|
||||
return site_id;
|
||||
}
|
||||
|
||||
public void setSite_id(long site_id) {
|
||||
this.site_id = site_id;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public long getSupervisorId() {
|
||||
return supervisorId;
|
||||
}
|
||||
|
||||
public void setSupervisorId(long supervisorId) {
|
||||
this.supervisorId = supervisorId;
|
||||
}
|
||||
|
||||
public String getObservation_date() {
|
||||
return observation_date;
|
||||
}
|
||||
|
||||
public void setObservation_date(String observation_date) {
|
||||
this.observation_date = observation_date;
|
||||
}
|
||||
|
||||
public String getShift() {
|
||||
return shift;
|
||||
}
|
||||
|
||||
public void setShift(String shift) {
|
||||
this.shift = shift;
|
||||
}
|
||||
|
||||
public String getCreatedBy() {
|
||||
return createdBy;
|
||||
}
|
||||
|
||||
public void setCreatedBy(String createdBy) {
|
||||
this.createdBy = createdBy;
|
||||
}
|
||||
|
||||
public String getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(String createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public long getRecordTypeId() {
|
||||
return recordTypeId;
|
||||
}
|
||||
|
||||
public void setRecordTypeId(long recordTypeId) {
|
||||
this.recordTypeId = recordTypeId;
|
||||
}
|
||||
|
||||
public ObservationStorageManager getHseReportObservationRecord() {
|
||||
return hseReportObservationRecord;
|
||||
}
|
||||
|
||||
public void setHseReportObservationRecord(ObservationStorageManager hseReportObservationRecord) {
|
||||
this.hseReportObservationRecord = hseReportObservationRecord;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "HSERequestModel{" +
|
||||
"id=" + id +
|
||||
", site_id=" + site_id +
|
||||
", code='" + code + '\'' +
|
||||
", supervisorId=" + supervisorId +
|
||||
", observation_date='" + observation_date + '\'' +
|
||||
", shift='" + shift + '\'' +
|
||||
", createdBy='" + createdBy + '\'' +
|
||||
", createdAt='" + createdAt + '\'' +
|
||||
", recordTypeId=" + recordTypeId +
|
||||
", hseReportObservationRecord=" + hseReportObservationRecord +
|
||||
'}';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,244 @@
|
|||
package com.utopiaindustries.hseobservationsapp.utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class HseReportActivityStorageManager {
|
||||
private static HseReportActivityStorageManager instance;
|
||||
// private ArrayList<byte[]> imageListPaper;
|
||||
|
||||
private String reportDate;
|
||||
private int userId;
|
||||
private int siteId;
|
||||
private int supervisorId;
|
||||
private String supervisorName;
|
||||
private String shiftName;
|
||||
private int recordTypeId;
|
||||
private String recordTypeName;
|
||||
|
||||
private int observationClassId;
|
||||
private String hseObservationName;
|
||||
|
||||
private int observationSubClassId;
|
||||
private String hseObservationSubClassName;
|
||||
|
||||
private int departmentId;
|
||||
private String departmentName;
|
||||
|
||||
private List<byte[]> beforePictures;
|
||||
private List<byte[]> afterPictures;
|
||||
|
||||
private String riskLevel;
|
||||
private boolean observationStatus;
|
||||
private String description;
|
||||
|
||||
private HseReportActivityStorageManager() {
|
||||
|
||||
}
|
||||
|
||||
public static HseReportActivityStorageManager getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new HseReportActivityStorageManager();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public String getReportDate() {
|
||||
return reportDate;
|
||||
}
|
||||
|
||||
public void setReportDate(String reportDate) {
|
||||
this.reportDate = reportDate;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public int getSiteId() {
|
||||
return siteId;
|
||||
}
|
||||
|
||||
public void setSiteId(int siteId) {
|
||||
this.siteId = siteId;
|
||||
}
|
||||
|
||||
public int getSupervisorId() {
|
||||
return supervisorId;
|
||||
}
|
||||
|
||||
public void setSupervisorId(int supervisorId) {
|
||||
this.supervisorId = supervisorId;
|
||||
}
|
||||
|
||||
public String getSupervisorName() {
|
||||
return supervisorName;
|
||||
}
|
||||
|
||||
public void setSupervisorName(String supervisorName) {
|
||||
this.supervisorName = supervisorName;
|
||||
}
|
||||
|
||||
public String getShiftName() {
|
||||
return shiftName;
|
||||
}
|
||||
|
||||
public void setShiftName(String shiftName) {
|
||||
this.shiftName = shiftName;
|
||||
}
|
||||
|
||||
public int getRecordTypeId() {
|
||||
return recordTypeId;
|
||||
}
|
||||
|
||||
public void setRecordTypeId(int recordTypeId) {
|
||||
this.recordTypeId = recordTypeId;
|
||||
}
|
||||
|
||||
public String getRecordTypeName() {
|
||||
return recordTypeName;
|
||||
}
|
||||
|
||||
public void setRecordTypeName(String recordTypeName) {
|
||||
this.recordTypeName = recordTypeName;
|
||||
}
|
||||
|
||||
public int getObservationClassId() {
|
||||
return observationClassId;
|
||||
}
|
||||
|
||||
public void setObservationClassId(int observationClassId) {
|
||||
this.observationClassId = observationClassId;
|
||||
}
|
||||
|
||||
public String getHseObservationName() {
|
||||
return hseObservationName;
|
||||
}
|
||||
|
||||
public void setHseObservationName(String hseObservationName) {
|
||||
this.hseObservationName = hseObservationName;
|
||||
}
|
||||
|
||||
public int getObservationSubClassId() {
|
||||
return observationSubClassId;
|
||||
}
|
||||
|
||||
public void setObservationSubClassId(int observationSubClassId) {
|
||||
this.observationSubClassId = observationSubClassId;
|
||||
}
|
||||
|
||||
public String getHseObservationSubClassName() {
|
||||
return hseObservationSubClassName;
|
||||
}
|
||||
|
||||
public void setHseObservationSubClassName(String hseObservationSubClassName) {
|
||||
this.hseObservationSubClassName = hseObservationSubClassName;
|
||||
}
|
||||
|
||||
public int getDepartmentId() {
|
||||
return departmentId;
|
||||
}
|
||||
|
||||
public void setDepartmentId(int departmentId) {
|
||||
this.departmentId = departmentId;
|
||||
}
|
||||
|
||||
public String getDepartmentName() {
|
||||
return departmentName;
|
||||
}
|
||||
|
||||
public void setDepartmentName(String departmentName) {
|
||||
this.departmentName = departmentName;
|
||||
}
|
||||
|
||||
public List<byte[]> getBeforePictures() {
|
||||
return beforePictures;
|
||||
}
|
||||
|
||||
public void setBeforePictures(List<byte[]> beforePictures) {
|
||||
this.beforePictures = beforePictures;
|
||||
}
|
||||
|
||||
public List<byte[]> getAfterPictures() {
|
||||
return afterPictures;
|
||||
}
|
||||
|
||||
public void setAfterPictures(List<byte[]> afterPictures) {
|
||||
this.afterPictures = afterPictures;
|
||||
}
|
||||
|
||||
public String getRiskLevel() {
|
||||
return riskLevel;
|
||||
}
|
||||
|
||||
public void setRiskLevel(String riskLevel) {
|
||||
this.riskLevel = riskLevel;
|
||||
}
|
||||
|
||||
public boolean getObservationStatus() {
|
||||
return observationStatus;
|
||||
}
|
||||
|
||||
public void setObservationStatus(boolean observationStatus) {
|
||||
this.observationStatus = observationStatus;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public void clearAllData() {
|
||||
|
||||
reportDate = null;
|
||||
userId = 0;
|
||||
siteId = 0;
|
||||
supervisorId = 0;
|
||||
supervisorName = null;
|
||||
shiftName = null;
|
||||
recordTypeId = 0;
|
||||
recordTypeName = null;
|
||||
observationClassId = 0;
|
||||
hseObservationName = null;
|
||||
observationSubClassId = 0;
|
||||
hseObservationSubClassName = null;
|
||||
departmentId = 0;
|
||||
departmentName = null;
|
||||
beforePictures = null;
|
||||
afterPictures = null;
|
||||
riskLevel = null;
|
||||
observationStatus = false;
|
||||
description = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ObservationStorageManager{" +
|
||||
"reportDate='" + reportDate + '\'' +
|
||||
", userId=" + userId +
|
||||
", siteId=" + siteId +
|
||||
", supervisorId=" + supervisorId +
|
||||
", supervisorName='" + supervisorName + '\'' +
|
||||
", shiftName='" + shiftName + '\'' +
|
||||
", recordTypeId=" + recordTypeId +
|
||||
", recordTypeName='" + recordTypeName + '\'' +
|
||||
", observationClassId=" + observationClassId +
|
||||
", hseObservationName='" + hseObservationName + '\'' +
|
||||
", observationSubClassId=" + observationSubClassId +
|
||||
", hseObservationSubClassName='" + hseObservationSubClassName + '\'' +
|
||||
", departmentId=" + departmentId +
|
||||
", departmentName='" + departmentName + '\'' +
|
||||
", beforePicture=" + beforePictures +
|
||||
", afterPicture=" + afterPictures +
|
||||
", riskLevel='" + riskLevel + '\'' +
|
||||
", observationStatus='" + observationStatus + '\'' +
|
||||
", description='" + description + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,244 @@
|
|||
package com.utopiaindustries.hseobservationsapp.utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ObservationStorageManager {
|
||||
private static ObservationStorageManager instance;
|
||||
// private ArrayList<byte[]> imageListPaper;
|
||||
|
||||
private String reportDate;
|
||||
private int userId;
|
||||
private int siteId;
|
||||
private int supervisorId;
|
||||
private String supervisorName;
|
||||
private String shiftName;
|
||||
private int recordTypeId;
|
||||
private String recordTypeName;
|
||||
|
||||
private int observationClassId;
|
||||
private String hseObservationName;
|
||||
|
||||
private int observationSubClassId;
|
||||
private String hseObservationSubClassName;
|
||||
|
||||
private int departmentId;
|
||||
private String departmentName;
|
||||
|
||||
private List<byte[]> beforePictures;
|
||||
private List<byte[]> afterPictures;
|
||||
|
||||
private String riskLevel;
|
||||
private boolean observationStatus;
|
||||
private String description;
|
||||
|
||||
private ObservationStorageManager() {
|
||||
|
||||
}
|
||||
|
||||
public static ObservationStorageManager getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new ObservationStorageManager();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public String getReportDate() {
|
||||
return reportDate;
|
||||
}
|
||||
|
||||
public void setReportDate(String reportDate) {
|
||||
this.reportDate = reportDate;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public int getSiteId() {
|
||||
return siteId;
|
||||
}
|
||||
|
||||
public void setSiteId(int siteId) {
|
||||
this.siteId = siteId;
|
||||
}
|
||||
|
||||
public int getSupervisorId() {
|
||||
return supervisorId;
|
||||
}
|
||||
|
||||
public void setSupervisorId(int supervisorId) {
|
||||
this.supervisorId = supervisorId;
|
||||
}
|
||||
|
||||
public String getSupervisorName() {
|
||||
return supervisorName;
|
||||
}
|
||||
|
||||
public void setSupervisorName(String supervisorName) {
|
||||
this.supervisorName = supervisorName;
|
||||
}
|
||||
|
||||
public String getShiftName() {
|
||||
return shiftName;
|
||||
}
|
||||
|
||||
public void setShiftName(String shiftName) {
|
||||
this.shiftName = shiftName;
|
||||
}
|
||||
|
||||
public int getRecordTypeId() {
|
||||
return recordTypeId;
|
||||
}
|
||||
|
||||
public void setRecordTypeId(int recordTypeId) {
|
||||
this.recordTypeId = recordTypeId;
|
||||
}
|
||||
|
||||
public String getRecordTypeName() {
|
||||
return recordTypeName;
|
||||
}
|
||||
|
||||
public void setRecordTypeName(String recordTypeName) {
|
||||
this.recordTypeName = recordTypeName;
|
||||
}
|
||||
|
||||
public int getObservationClassId() {
|
||||
return observationClassId;
|
||||
}
|
||||
|
||||
public void setObservationClassId(int observationClassId) {
|
||||
this.observationClassId = observationClassId;
|
||||
}
|
||||
|
||||
public String getHseObservationName() {
|
||||
return hseObservationName;
|
||||
}
|
||||
|
||||
public void setHseObservationName(String hseObservationName) {
|
||||
this.hseObservationName = hseObservationName;
|
||||
}
|
||||
|
||||
public int getObservationSubClassId() {
|
||||
return observationSubClassId;
|
||||
}
|
||||
|
||||
public void setObservationSubClassId(int observationSubClassId) {
|
||||
this.observationSubClassId = observationSubClassId;
|
||||
}
|
||||
|
||||
public String getHseObservationSubClassName() {
|
||||
return hseObservationSubClassName;
|
||||
}
|
||||
|
||||
public void setHseObservationSubClassName(String hseObservationSubClassName) {
|
||||
this.hseObservationSubClassName = hseObservationSubClassName;
|
||||
}
|
||||
|
||||
public int getDepartmentId() {
|
||||
return departmentId;
|
||||
}
|
||||
|
||||
public void setDepartmentId(int departmentId) {
|
||||
this.departmentId = departmentId;
|
||||
}
|
||||
|
||||
public String getDepartmentName() {
|
||||
return departmentName;
|
||||
}
|
||||
|
||||
public void setDepartmentName(String departmentName) {
|
||||
this.departmentName = departmentName;
|
||||
}
|
||||
|
||||
public List<byte[]> getBeforePictures() {
|
||||
return beforePictures;
|
||||
}
|
||||
|
||||
public void setBeforePictures(List<byte[]> beforePictures) {
|
||||
this.beforePictures = beforePictures;
|
||||
}
|
||||
|
||||
public List<byte[]> getAfterPictures() {
|
||||
return afterPictures;
|
||||
}
|
||||
|
||||
public void setAfterPictures(List<byte[]> afterPictures) {
|
||||
this.afterPictures = afterPictures;
|
||||
}
|
||||
|
||||
public String getRiskLevel() {
|
||||
return riskLevel;
|
||||
}
|
||||
|
||||
public void setRiskLevel(String riskLevel) {
|
||||
this.riskLevel = riskLevel;
|
||||
}
|
||||
|
||||
public boolean getObservationStatus() {
|
||||
return observationStatus;
|
||||
}
|
||||
|
||||
public void setObservationStatus(boolean observationStatus) {
|
||||
this.observationStatus = observationStatus;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public void clearAllData() {
|
||||
|
||||
reportDate = null;
|
||||
userId = 0;
|
||||
siteId = 0;
|
||||
supervisorId = 0;
|
||||
supervisorName = null;
|
||||
shiftName = null;
|
||||
recordTypeId = 0;
|
||||
recordTypeName = null;
|
||||
observationClassId = 0;
|
||||
hseObservationName = null;
|
||||
observationSubClassId = 0;
|
||||
hseObservationSubClassName = null;
|
||||
departmentId = 0;
|
||||
departmentName = null;
|
||||
beforePictures = null;
|
||||
afterPictures = null;
|
||||
riskLevel = null;
|
||||
observationStatus = false;
|
||||
description = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ObservationStorageManager{" +
|
||||
"reportDate='" + reportDate + '\'' +
|
||||
", userId=" + userId +
|
||||
", siteId=" + siteId +
|
||||
", supervisorId=" + supervisorId +
|
||||
", supervisorName='" + supervisorName + '\'' +
|
||||
", shiftName='" + shiftName + '\'' +
|
||||
", recordTypeId=" + recordTypeId +
|
||||
", recordTypeName='" + recordTypeName + '\'' +
|
||||
", observationClassId=" + observationClassId +
|
||||
", hseObservationName='" + hseObservationName + '\'' +
|
||||
", observationSubClassId=" + observationSubClassId +
|
||||
", hseObservationSubClassName='" + hseObservationSubClassName + '\'' +
|
||||
", departmentId=" + departmentId +
|
||||
", departmentName='" + departmentName + '\'' +
|
||||
", beforePicture=" + beforePictures +
|
||||
", afterPicture=" + afterPictures +
|
||||
", riskLevel='" + riskLevel + '\'' +
|
||||
", observationStatus='" + observationStatus + '\'' +
|
||||
", description='" + description + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
|
@ -8,7 +8,8 @@ import androidx.lifecycle.ViewModel;
|
|||
import com.utopiaindustries.hseobservationsapp.apiservice.ApiService;
|
||||
import com.utopiaindustries.hseobservationsapp.apiservice.ApiServiceFactory;
|
||||
import com.utopiaindustries.hseobservationsapp.models.HseData.HseResponse;
|
||||
import com.utopiaindustries.hseobservationsapp.models.QualityControlResponse;
|
||||
import com.utopiaindustries.hseobservationsapp.models.HseData.HseSaveResponse;
|
||||
import com.utopiaindustries.hseobservationsapp.utils.HSERequestModel;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
@ -17,6 +18,7 @@ import retrofit2.Response;
|
|||
public class LoginViewModel extends ViewModel {
|
||||
|
||||
private MutableLiveData<HseResponse> userLiveData;
|
||||
private MutableLiveData<HseSaveResponse> userSaveLiveData;
|
||||
private MutableLiveData<Boolean> userLoginLiveData;
|
||||
private MutableLiveData<String> errorLiveData;
|
||||
private MutableLiveData<Boolean> isLoading;
|
||||
|
@ -25,6 +27,7 @@ public class LoginViewModel extends ViewModel {
|
|||
public LoginViewModel() {
|
||||
apiService = ApiServiceFactory.getApiService();
|
||||
userLiveData = new MutableLiveData<>();
|
||||
userSaveLiveData = new MutableLiveData<>();
|
||||
userLoginLiveData = new MutableLiveData<>();
|
||||
errorLiveData = new MutableLiveData<>();
|
||||
isLoading = new MutableLiveData<>();
|
||||
|
@ -34,6 +37,10 @@ public class LoginViewModel extends ViewModel {
|
|||
return userLiveData;
|
||||
}
|
||||
|
||||
public LiveData<HseSaveResponse> getUserSaveLiveData() {
|
||||
return userSaveLiveData;
|
||||
}
|
||||
|
||||
public LiveData<Boolean> getLoadingState() {
|
||||
|
||||
return isLoading;
|
||||
|
@ -91,6 +98,29 @@ public class LoginViewModel extends ViewModel {
|
|||
});
|
||||
}
|
||||
|
||||
public void saveHSEData(HSERequestModel hseRequestModel) {
|
||||
isLoading.setValue(true);
|
||||
apiService.saveHseReport(hseRequestModel).enqueue(new Callback<HseSaveResponse>() {
|
||||
@Override
|
||||
public void onResponse(Call<HseSaveResponse> call, Response<HseSaveResponse> response) {
|
||||
isLoading.setValue(false);
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
//Log.e("onResponse: ", "Successful");
|
||||
userSaveLiveData.setValue(response.body());
|
||||
} else {
|
||||
errorLiveData.setValue(response.message());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<HseSaveResponse> call, Throwable t) {
|
||||
//Log.e("onResponse: ", "Fail");
|
||||
isLoading.setValue(false);
|
||||
errorLiveData.setValue(t.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public LiveData<Boolean> getLoginUser() {
|
||||
return userLoginLiveData;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:background="@drawable/rounded_white"
|
||||
android:orientation="vertical"
|
||||
android:padding="15dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/message"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="15dp"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:paddingLeft="15dp"
|
||||
android:paddingRight="15dp"
|
||||
android:text="Submit the report?"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/_15sdp"
|
||||
android:textStyle="normal" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:layout_marginTop="7dp"
|
||||
android:background="@color/white" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:weightSum="3">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dialogCancelBtn"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.495"
|
||||
android:gravity="center"
|
||||
android:paddingTop="15dp"
|
||||
android:paddingBottom="15dp"
|
||||
android:background="@drawable/custom_button"
|
||||
android:text="No"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/_14sdp"
|
||||
android:textStyle="normal" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.05"
|
||||
android:background="@color/white"
|
||||
android:paddingTop="15dp"
|
||||
android:paddingBottom="15dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dialogOkBtn"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.495"
|
||||
android:gravity="center"
|
||||
android:paddingTop="15dp"
|
||||
android:paddingBottom="15dp"
|
||||
android:text="Yes"
|
||||
android:textAllCaps="false"
|
||||
android:background="@drawable/custom_button"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/_14sdp"
|
||||
android:textStyle="normal" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue