Permit to work module working
parent
7c8cb2380c
commit
316589220b
|
@ -85,6 +85,7 @@
|
|||
<activity
|
||||
android:name=".activities.PermitToWorkForms.PermitTwoActivity"
|
||||
android:exported="false"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activities.PermitToWorkForms.PermitOneActivity"
|
||||
|
|
|
@ -1,26 +1,73 @@
|
|||
package com.utopiaindustries.hseobservationsapp.activities.PermitToWorkForms;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
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.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
import com.utopiaindustries.hseobservationsapp.R;
|
||||
import com.utopiaindustries.hseobservationsapp.activities.ObservationForms.ObservationThreeActivity;
|
||||
import com.utopiaindustries.hseobservationsapp.activities.ObservationForms.ObservationTwoActivity;
|
||||
import com.utopiaindustries.hseobservationsapp.adapters.BuildingsAdapter;
|
||||
import com.utopiaindustries.hseobservationsapp.adapters.FloorsAdapter;
|
||||
import com.utopiaindustries.hseobservationsapp.adapters.HsePtwTypeAdapter;
|
||||
import com.utopiaindustries.hseobservationsapp.adapters.WorkingTeamAdapter;
|
||||
import com.utopiaindustries.hseobservationsapp.helper.Helper;
|
||||
import com.utopiaindustries.hseobservationsapp.models.HseData.HseActivity;
|
||||
import com.utopiaindustries.hseobservationsapp.models.HseData.HseBuilding;
|
||||
import com.utopiaindustries.hseobservationsapp.models.HseData.HseFloor;
|
||||
import com.utopiaindustries.hseobservationsapp.models.HseData.HsePtwType;
|
||||
import com.utopiaindustries.hseobservationsapp.models.HseData.HseWorkingTeam;
|
||||
import com.utopiaindustries.hseobservationsapp.utils.StorageManager.StorageManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PermitOneActivity extends AppCompatActivity {
|
||||
|
||||
private Button btnNext;
|
||||
ImageView imgBack;
|
||||
|
||||
private AutoCompleteTextView locationTextview, subLocationTextView, ptwTypeTextView,
|
||||
ptwSubTypeTextView, workingTeamTextView;
|
||||
|
||||
private TextInputLayout ptwTextInputLayout;
|
||||
|
||||
private ArrayList<HseBuilding> locationArrayList_temp = new ArrayList<>();
|
||||
private ArrayList<HseBuilding> locationArrayList = new ArrayList<>();
|
||||
private BuildingsAdapter buildingAdapter;
|
||||
|
||||
private ArrayList<HseFloor> subLocationArrayList_temp = new ArrayList<>();
|
||||
private ArrayList<HseFloor> subLocationArrayList = new ArrayList<>();
|
||||
private FloorsAdapter floorsAdapter;
|
||||
|
||||
private ArrayList<HsePtwType> ptwTypeArrayList = new ArrayList<>();
|
||||
private HsePtwTypeAdapter ptwTypeAdapter;
|
||||
|
||||
|
||||
private ArrayList<HseWorkingTeam> workingTeamArrayList = new ArrayList<>();
|
||||
private WorkingTeamAdapter workingTeamAdapter;
|
||||
|
||||
String location = "", subLocation = "", ptwType = "", workingTeam = "";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -44,8 +91,45 @@ public class PermitOneActivity extends AppCompatActivity {
|
|||
btnNext.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(PermitOneActivity.this, PermitTwoActivity.class);
|
||||
startActivity(intent);
|
||||
if (isValidate()) {
|
||||
Intent intent = new Intent(PermitOneActivity.this, PermitTwoActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
locationTextview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
location = locationArrayList.get(position).getTitle();
|
||||
StorageManager.getInstance().getPermitToWorkModel().get(0).setLocationId(locationArrayList.get(position).getId());
|
||||
}
|
||||
});
|
||||
|
||||
subLocationTextView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
subLocation = subLocationArrayList.get(position).getTitle();
|
||||
StorageManager.getInstance().getPermitToWorkModel().get(0).setSubLocationId(subLocationArrayList.get(position).getId());
|
||||
}
|
||||
});
|
||||
|
||||
ptwTypeTextView.setOnClickListener(v -> {
|
||||
showMultiSelectDialog(ptwTypeArrayList, ptwTypeTextView);
|
||||
});
|
||||
|
||||
//ptwTextInputLayout
|
||||
ptwTextInputLayout.setEndIconMode(TextInputLayout.END_ICON_CUSTOM);
|
||||
ptwTextInputLayout.setEndIconDrawable(R.drawable.ic_arrow_drop_down);
|
||||
ptwTextInputLayout.setOnClickListener(v -> {
|
||||
showMultiSelectDialog(ptwTypeArrayList, ptwTypeTextView);
|
||||
});
|
||||
|
||||
workingTeamTextView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
workingTeam = workingTeamArrayList.get(position).getTitle();
|
||||
StorageManager.getInstance().getPermitToWorkModel().get(0).setWorkingTeamId(workingTeamArrayList.get(position).getId());
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -56,5 +140,113 @@ public class PermitOneActivity extends AppCompatActivity {
|
|||
btnNext = findViewById(R.id.btn_next);
|
||||
imgBack = findViewById(R.id.img_back);
|
||||
|
||||
locationTextview = findViewById(R.id.location_textview);
|
||||
subLocationTextView = findViewById(R.id.sub_location_textview);
|
||||
ptwTypeTextView = findViewById(R.id.ptw_type_textview);
|
||||
ptwTextInputLayout = findViewById(R.id.ptw_type_input);
|
||||
|
||||
ptwTypeTextView.setFocusable(false);
|
||||
ptwTypeTextView.setCursorVisible(false);
|
||||
ptwTypeTextView.setKeyListener(null); // disables keyboard
|
||||
ptwTypeTextView.setClickable(true);
|
||||
|
||||
workingTeamTextView = findViewById(R.id.working_team_textview);
|
||||
|
||||
locationArrayList_temp.addAll(Helper.getList(Helper.hseBuildings, this, HseBuilding.class));
|
||||
|
||||
//Location -- Building
|
||||
if (!locationArrayList_temp.isEmpty()) {
|
||||
|
||||
List<HseBuilding> filteredUnitItems = locationArrayList_temp.stream()
|
||||
.filter(item -> Objects.equals(item.getSiteId(), StorageManager.getInstance().getSite_id()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
locationArrayList.clear();
|
||||
locationArrayList.addAll(filteredUnitItems);
|
||||
buildingAdapter = new BuildingsAdapter(this, locationArrayList);
|
||||
locationTextview.setAdapter(buildingAdapter);
|
||||
}
|
||||
|
||||
subLocationArrayList_temp.addAll(Helper.getList(Helper.hseFloors, this, HseFloor.class));
|
||||
|
||||
//Sub Location -- floor
|
||||
if (!subLocationArrayList_temp.isEmpty()) {
|
||||
|
||||
List<HseFloor> filteredUnitItems = subLocationArrayList_temp.stream()
|
||||
.filter(item -> Objects.equals(item.getSiteId(), StorageManager.getInstance().getSite_id()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
subLocationArrayList.clear();
|
||||
subLocationArrayList.addAll(filteredUnitItems);
|
||||
floorsAdapter = new FloorsAdapter(this, subLocationArrayList);
|
||||
subLocationTextView.setAdapter(floorsAdapter);
|
||||
}
|
||||
|
||||
ptwTypeArrayList.addAll(Helper.getList(Helper.hsePtwType, this, HsePtwType.class));
|
||||
|
||||
workingTeamArrayList.addAll(Helper.getList(Helper.hseWorkingTeams, this, HseWorkingTeam.class));
|
||||
workingTeamAdapter = new WorkingTeamAdapter(this, workingTeamArrayList);
|
||||
workingTeamTextView.setAdapter(workingTeamAdapter);
|
||||
|
||||
}
|
||||
|
||||
public boolean isValidate() {
|
||||
boolean returnValue = true;
|
||||
String message = "";
|
||||
|
||||
/*if (workingTeam.isEmpty()) {
|
||||
message = "Please select working type.";
|
||||
returnValue = false;
|
||||
}*/
|
||||
|
||||
if (ptwType.isEmpty()) {
|
||||
message = "Please select ptw Type.";
|
||||
returnValue = false;
|
||||
}
|
||||
|
||||
if (subLocation.isEmpty()) {
|
||||
message = "Please select sub location.";
|
||||
returnValue = false;
|
||||
}
|
||||
|
||||
if (location.isEmpty()) {
|
||||
message = "Please select location.";
|
||||
returnValue = false;
|
||||
}
|
||||
|
||||
if (!returnValue) {
|
||||
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
private void showMultiSelectDialog(List<HsePtwType> ptwList, AutoCompleteTextView textView) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
View dialogView = LayoutInflater.from(this).inflate(R.layout.dialog_recycler, null);
|
||||
builder.setView(dialogView);
|
||||
|
||||
@SuppressLint({"MissingInflatedId", "LocalSuppress"}) RecyclerView recyclerView = dialogView.findViewById(R.id.dialogRecyclerView);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
HsePtwTypeAdapter adapter = new HsePtwTypeAdapter(this, ptwList);
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
builder.setPositiveButton("OK", (dialog, which) -> {
|
||||
List<HsePtwType> selected = adapter.getSelectedItems();
|
||||
if (selected.size() != 2) {
|
||||
Toast.makeText(this, "Please select exactly 2 items", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
String selectedTitles = selected.get(0).getTitle() + ", " + selected.get(1).getTitle();
|
||||
textView.setText(selectedTitles);
|
||||
ptwType = selectedTitles;
|
||||
});
|
||||
|
||||
builder.setNegativeButton("Cancel", (dialog, which) -> dialog.dismiss());
|
||||
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
}
|
|
@ -16,11 +16,16 @@ import android.os.Build;
|
|||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.Editable;
|
||||
import android.text.InputType;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
@ -45,6 +50,7 @@ import com.utopiaindustries.hseobservationsapp.activities.DashboardActivity;
|
|||
import com.utopiaindustries.hseobservationsapp.activities.ObservationForms.ObservationThreeActivity;
|
||||
import com.utopiaindustries.hseobservationsapp.adapters.PTWImageAdapter;
|
||||
import com.utopiaindustries.hseobservationsapp.models.DocumentTypeImageModel;
|
||||
import com.utopiaindustries.hseobservationsapp.utils.StorageManager.StorageManager;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
|
@ -67,13 +73,14 @@ public class PermitTwoActivity extends AppCompatActivity implements EasyPermissi
|
|||
RecyclerView ptwRecyclerView;
|
||||
PTWImageAdapter imagePaperAdapter;
|
||||
String paperFilePath = "no_pic";
|
||||
ArrayList<byte[]> PaperImageList = new ArrayList<>();
|
||||
ArrayList<byte[]> imageList = new ArrayList<>();
|
||||
String docTypeId = "";
|
||||
String docTypeTitle = "";
|
||||
private static final int CAMERA_REQUEST_PAPER = 101;
|
||||
private static final int GALLERY_REQUEST = 201;
|
||||
ImageView imgUpload, imgBack;
|
||||
Button btnSubmit;
|
||||
EditText etDescription;
|
||||
|
||||
// Activity Result Launcher for Gallery
|
||||
private final ActivityResultLauncher<Intent> imagePickerLauncher =
|
||||
|
@ -96,8 +103,8 @@ public class PermitTwoActivity extends AppCompatActivity implements EasyPermissi
|
|||
|
||||
//Log.e("doc-image: ",""+ documentImage);
|
||||
|
||||
int position = PaperImageList.size();
|
||||
PaperImageList.add(compressedImage);
|
||||
int position = imageList.size();
|
||||
imageList.add(compressedImage);
|
||||
imagePaperAdapter.notifyItemInserted(position);
|
||||
});
|
||||
},
|
||||
|
@ -144,8 +151,8 @@ public class PermitTwoActivity extends AppCompatActivity implements EasyPermissi
|
|||
|
||||
//Log.e("doc-image: ",""+ documentImage);
|
||||
|
||||
int position = PaperImageList.size();
|
||||
PaperImageList.add(imageBytes);
|
||||
int position = imageList.size();
|
||||
imageList.add(imageBytes);
|
||||
imagePaperAdapter.notifyItemInserted(position);
|
||||
|
||||
});
|
||||
|
@ -185,6 +192,7 @@ public class PermitTwoActivity extends AppCompatActivity implements EasyPermissi
|
|||
public void onClick(View v) {
|
||||
if (checkboxCompany.isChecked()) {
|
||||
checkboxContractor.setChecked(false);
|
||||
StorageManager.getInstance().getPermitToWorkModel().get(0).setWorkingPartyType("Company");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -194,6 +202,7 @@ public class PermitTwoActivity extends AppCompatActivity implements EasyPermissi
|
|||
public void onClick(View v) {
|
||||
if (checkboxContractor.isChecked()) {
|
||||
checkboxCompany.setChecked(false);
|
||||
StorageManager.getInstance().getPermitToWorkModel().get(0).setWorkingPartyType("Contractor");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -215,6 +224,7 @@ public class PermitTwoActivity extends AppCompatActivity implements EasyPermissi
|
|||
btnSubmit.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
StorageManager.getInstance().getPermitToWorkModel().get(0).setPictures(imageList);
|
||||
Toast.makeText(PermitTwoActivity.this,"Reported Submitted",Toast.LENGTH_SHORT).show();
|
||||
Intent intent = new Intent(PermitTwoActivity.this, DashboardActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
@ -223,6 +233,23 @@ public class PermitTwoActivity extends AppCompatActivity implements EasyPermissi
|
|||
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
|
||||
}
|
||||
});
|
||||
|
||||
etDescription.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
StorageManager.getInstance().getPermitToWorkModel().get(0).setDescription(s.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressLint("MissingInflatedId")
|
||||
|
@ -292,10 +319,13 @@ public class PermitTwoActivity extends AppCompatActivity implements EasyPermissi
|
|||
imgUpload = findViewById(R.id.img_upload);
|
||||
imgBack = findViewById(R.id.img_back);
|
||||
btnSubmit = findViewById(R.id.btn_submit);
|
||||
etDescription = findViewById(R.id.et_description);
|
||||
etDescription.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
etDescription.setRawInputType(InputType.TYPE_CLASS_TEXT);
|
||||
|
||||
ptwRecyclerView = findViewById(R.id.ptwRecyclerView);
|
||||
|
||||
imagePaperAdapter = new PTWImageAdapter(PaperImageList, this, "");
|
||||
imagePaperAdapter = new PTWImageAdapter(imageList, this, "");
|
||||
ptwRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
|
||||
ptwRecyclerView.setAdapter(imagePaperAdapter);
|
||||
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
package com.utopiaindustries.hseobservationsapp.adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.utopiaindustries.hseobservationsapp.R;
|
||||
import com.utopiaindustries.hseobservationsapp.models.HseData.HseBuilding;
|
||||
import com.utopiaindustries.hseobservationsapp.models.HseData.HseDepartment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BuildingsAdapter extends ArrayAdapter<HseBuilding> {
|
||||
|
||||
private final Context context;
|
||||
private final List<HseBuilding> items;
|
||||
|
||||
public BuildingsAdapter(Context context, List<HseBuilding> items) {
|
||||
super(context, 0, items);
|
||||
this.context = context;
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
if (convertView == null) {
|
||||
convertView = LayoutInflater.from(context).inflate(R.layout.list_items, parent, false);
|
||||
}
|
||||
|
||||
HseBuilding item = items.get(position);
|
||||
|
||||
TextView titleTextView = convertView.findViewById(R.id.item_text);
|
||||
|
||||
titleTextView.setText(item.getTitle());
|
||||
|
||||
return convertView;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package com.utopiaindustries.hseobservationsapp.adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.utopiaindustries.hseobservationsapp.R;
|
||||
import com.utopiaindustries.hseobservationsapp.models.HseData.HseBuilding;
|
||||
import com.utopiaindustries.hseobservationsapp.models.HseData.HseFloor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FloorsAdapter extends ArrayAdapter<HseFloor> {
|
||||
|
||||
private final Context context;
|
||||
private final List<HseFloor> items;
|
||||
|
||||
public FloorsAdapter(Context context, List<HseFloor> items) {
|
||||
super(context, 0, items);
|
||||
this.context = context;
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
if (convertView == null) {
|
||||
convertView = LayoutInflater.from(context).inflate(R.layout.list_items, parent, false);
|
||||
}
|
||||
|
||||
HseFloor item = items.get(position);
|
||||
|
||||
TextView titleTextView = convertView.findViewById(R.id.item_text);
|
||||
|
||||
titleTextView.setText(item.getTitle());
|
||||
|
||||
return convertView;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package com.utopiaindustries.hseobservationsapp.adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.utopiaindustries.hseobservationsapp.R;
|
||||
import com.utopiaindustries.hseobservationsapp.models.HseData.HsePtwType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HsePtwTypeAdapter extends RecyclerView.Adapter<HsePtwTypeAdapter.ViewHolder> {
|
||||
|
||||
private List<HsePtwType> list;
|
||||
private Context context;
|
||||
|
||||
public HsePtwTypeAdapter(Context context, List<HsePtwType> list) {
|
||||
this.context = context;
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
public List<HsePtwType> getSelectedItems() {
|
||||
List<HsePtwType> selected = new ArrayList<>();
|
||||
for (HsePtwType item : list) {
|
||||
if (item.isSelected()) selected.add(item);
|
||||
}
|
||||
return selected;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.item_ptw_type, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
HsePtwType item = list.get(position);
|
||||
holder.title.setText(item.getTitle());
|
||||
holder.checkbox.setChecked(item.isSelected());
|
||||
|
||||
holder.checkbox.setOnCheckedChangeListener(null); // Clear previous listener
|
||||
|
||||
holder.checkbox.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
int selectedCount = getSelectedItems().size();
|
||||
|
||||
if (isChecked && selectedCount >= 2) {
|
||||
holder.checkbox.setChecked(false);
|
||||
Toast.makeText(context, "Only 2 selections allowed", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
item.setSelected(isChecked);
|
||||
}
|
||||
});
|
||||
|
||||
holder.itemView.setOnClickListener(v -> {
|
||||
boolean newCheckedState = !holder.checkbox.isChecked();
|
||||
holder.checkbox.setChecked(newCheckedState);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
CheckBox checkbox;
|
||||
TextView title;
|
||||
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
checkbox = itemView.findViewById(R.id.checkbox);
|
||||
title = itemView.findViewById(R.id.title);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.utopiaindustries.hseobservationsapp.adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.utopiaindustries.hseobservationsapp.R;
|
||||
import com.utopiaindustries.hseobservationsapp.models.HseData.HseBuilding;
|
||||
import com.utopiaindustries.hseobservationsapp.models.HseData.HseWorkingTeam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class WorkingTeamAdapter extends ArrayAdapter<HseWorkingTeam> {
|
||||
|
||||
private final Context context;
|
||||
private final List<HseWorkingTeam> items;
|
||||
|
||||
public WorkingTeamAdapter(Context context, List<HseWorkingTeam> items) {
|
||||
super(context, 0, items);
|
||||
this.context = context;
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
if (convertView == null) {
|
||||
convertView = LayoutInflater.from(context).inflate(R.layout.list_items, parent, false);
|
||||
}
|
||||
|
||||
HseWorkingTeam item = items.get(position);
|
||||
|
||||
TextView titleTextView = convertView.findViewById(R.id.item_text);
|
||||
|
||||
titleTextView.setText(item.getTitle());
|
||||
|
||||
return convertView;
|
||||
}
|
||||
}
|
|
@ -303,6 +303,11 @@ public class HomeFragment extends Fragment {
|
|||
Helper.saveList(qcResponse.getHseBuildings(), Helper.hseBuildings, getActivity());
|
||||
}
|
||||
|
||||
if (!qcResponse.getHseWorkingTeam().isEmpty()) {
|
||||
|
||||
Helper.saveList(qcResponse.getHseWorkingTeam(), Helper.hseWorkingTeams, getActivity());
|
||||
}
|
||||
|
||||
if (!qcResponse.getHseInjuries().isEmpty()) {
|
||||
|
||||
Helper.saveList(qcResponse.getHseInjuries(), Helper.hseInjuries, getActivity());
|
||||
|
|
|
@ -50,6 +50,7 @@ public class Helper {
|
|||
|
||||
public static final String hseSafetyTrainingTopics = "hseSafetyTrainingTopics";
|
||||
public static final String hseBuildings = "hseBuildings";
|
||||
public static final String hseWorkingTeams = "hseWorkingTeams";
|
||||
|
||||
public static final String hseInjuries = "hseInjuries";
|
||||
|
||||
|
|
|
@ -40,4 +40,9 @@ public class HseBuilding {
|
|||
this.title = title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return title;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,4 +40,9 @@ public class HseFloor {
|
|||
this.title = title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return title;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ public class HsePtwType {
|
|||
@Expose
|
||||
private String title;
|
||||
|
||||
private boolean isSelected = false;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -29,4 +31,12 @@ public class HsePtwType {
|
|||
this.title = title;
|
||||
}
|
||||
|
||||
public boolean isSelected() {
|
||||
return isSelected;
|
||||
}
|
||||
|
||||
public void setSelected(boolean selected) {
|
||||
isSelected = selected;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,6 +43,9 @@ public class HseResponse {
|
|||
@SerializedName("hseBuildings")
|
||||
@Expose
|
||||
private List<HseBuilding> hseBuildings;
|
||||
@SerializedName("hseWorkingTeam")
|
||||
@Expose
|
||||
private List<HseWorkingTeam> hseWorkingTeam;
|
||||
@SerializedName("hseInjuries")
|
||||
@Expose
|
||||
private List<HseInjury> hseInjuries;
|
||||
|
@ -146,6 +149,15 @@ public class HseResponse {
|
|||
this.hseBuildings = hseBuildings;
|
||||
}
|
||||
|
||||
public List<HseWorkingTeam> getHseWorkingTeam() {
|
||||
return hseWorkingTeam;
|
||||
}
|
||||
|
||||
public void setHseWorkingTeam(List<HseWorkingTeam> hseWorkingTeam) {
|
||||
this.hseWorkingTeam = hseWorkingTeam;
|
||||
}
|
||||
|
||||
|
||||
public List<HseInjury> getHseInjuries() {
|
||||
return hseInjuries;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
|
||||
package com.utopiaindustries.hseobservationsapp.models.HseData;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class HseWorkingTeam {
|
||||
|
||||
@SerializedName("id")
|
||||
@Expose
|
||||
private Integer id;
|
||||
@SerializedName("title")
|
||||
@Expose
|
||||
private String title;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return title;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package com.utopiaindustries.hseobservationsapp.utils.StorageManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PermitToWorkModel {
|
||||
|
||||
private int locationId;
|
||||
private int subLocationId;
|
||||
private int typeId;
|
||||
private int subTypeId;
|
||||
private int workingTeamId;
|
||||
private String workingPartyType;
|
||||
|
||||
private String description;
|
||||
|
||||
private List<byte[]> pictures;
|
||||
|
||||
public int getLocationId() {
|
||||
return locationId;
|
||||
}
|
||||
|
||||
public void setLocationId(int locationId) {
|
||||
this.locationId = locationId;
|
||||
}
|
||||
|
||||
public int getSubLocationId() {
|
||||
return subLocationId;
|
||||
}
|
||||
|
||||
public void setSubLocationId(int subLocationId) {
|
||||
this.subLocationId = subLocationId;
|
||||
}
|
||||
|
||||
public int getTypeId() {
|
||||
return typeId;
|
||||
}
|
||||
|
||||
public void setTypeId(int typeId) {
|
||||
this.typeId = typeId;
|
||||
}
|
||||
|
||||
public int getSubTypeId() {
|
||||
return subTypeId;
|
||||
}
|
||||
|
||||
public void setSubTypeId(int subTypeId) {
|
||||
this.subTypeId = subTypeId;
|
||||
}
|
||||
|
||||
public int getWorkingTeamId() {
|
||||
return workingTeamId;
|
||||
}
|
||||
|
||||
public void setWorkingTeamId(int workingTeamId) {
|
||||
this.workingTeamId = workingTeamId;
|
||||
}
|
||||
|
||||
public String getWorkingPartyType() {
|
||||
return workingPartyType;
|
||||
}
|
||||
|
||||
public void setWorkingPartyType(String workingPartyType) {
|
||||
this.workingPartyType = workingPartyType;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public List<byte[]> getPictures() {
|
||||
return pictures;
|
||||
}
|
||||
|
||||
public void setPictures(List<byte[]> pictures) {
|
||||
this.pictures = pictures;
|
||||
}
|
||||
}
|
|
@ -21,6 +21,7 @@ public class StorageManager {
|
|||
private List<ObservationModel> observationsModel;
|
||||
private List<ReportActivityModel> reportActivityModel;
|
||||
private List<ReportActivityModel> progressiveActivityModel;
|
||||
private List<PermitToWorkModel> permitToWorkModel;
|
||||
|
||||
|
||||
private StorageManager() {
|
||||
|
@ -44,6 +45,9 @@ public class StorageManager {
|
|||
|
||||
progressiveActivityModel = new ArrayList<>();
|
||||
progressiveActivityModel.add(new ReportActivityModel());
|
||||
|
||||
permitToWorkModel = new ArrayList<>();
|
||||
permitToWorkModel.add(new PermitToWorkModel());
|
||||
}
|
||||
|
||||
public String getObservation_date() {
|
||||
|
@ -134,6 +138,14 @@ public class StorageManager {
|
|||
this.progressiveActivityModel = progressiveActivityModel;
|
||||
}
|
||||
|
||||
public List<PermitToWorkModel> getPermitToWorkModel() {
|
||||
return permitToWorkModel;
|
||||
}
|
||||
|
||||
public void setPermitToWorkModel(List<PermitToWorkModel> permitToWorkModel) {
|
||||
this.permitToWorkModel = permitToWorkModel;
|
||||
}
|
||||
|
||||
public void clearAllData() {
|
||||
|
||||
observation_date = null;
|
||||
|
@ -148,5 +160,6 @@ public class StorageManager {
|
|||
observationsModel.clear();
|
||||
reportActivityModel.clear();
|
||||
progressiveActivityModel.clear();
|
||||
permitToWorkModel.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<!-- In drawable/ic_arrow_drop_down.xml -->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#666"
|
||||
android:pathData="M7,10l5,5 5,-5z" />
|
||||
</vector>
|
|
@ -59,7 +59,7 @@
|
|||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginTop="15dp"
|
||||
android:gravity="left"
|
||||
android:padding="5dp"
|
||||
android:text="Location *"
|
||||
|
@ -90,7 +90,7 @@
|
|||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginTop="15dp"
|
||||
android:gravity="left"
|
||||
android:padding="5dp"
|
||||
android:text="Sub Location *"
|
||||
|
@ -121,7 +121,7 @@
|
|||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginTop="15dp"
|
||||
android:gravity="left"
|
||||
android:padding="5dp"
|
||||
android:text="PTW Type *"
|
||||
|
@ -146,10 +146,12 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="none"
|
||||
android:focusable="false"
|
||||
android:cursorVisible="false"
|
||||
android:textSize="16sp" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<TextView
|
||||
<!--<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
|
@ -178,13 +180,13 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:inputType="none"
|
||||
android:textSize="16sp" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
</com.google.android.material.textfield.TextInputLayout>-->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/observation_heading"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginTop="15dp"
|
||||
android:gravity="left"
|
||||
android:padding="5dp"
|
||||
android:text="Working Team *"
|
||||
|
|
|
@ -44,7 +44,8 @@
|
|||
<ScrollView
|
||||
android:id="@+id/scrollView2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:fillViewport="true"
|
||||
app:layout_constraintBottom_toTopOf="@+id/btn_submit"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="16dp">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/dialogRecyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="300dp" />
|
||||
</LinearLayout>
|
|
@ -0,0 +1,22 @@
|
|||
<?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="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="12dp">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusable="false"
|
||||
android:focusableInTouchMode="false" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_weight="1"
|
||||
android:textSize="16sp" />
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue