Skip to content

Commit

Permalink
feature/created constructionFormData class and populated it in action…
Browse files Browse the repository at this point in the history
…Listener
  • Loading branch information
IbrahimSaeedPurdue authored and IbrahimSaeedPurdue committed Mar 3, 2021
1 parent 34d9aa4 commit 042f8d4
Showing 1 changed file with 113 additions and 47 deletions.
160 changes: 113 additions & 47 deletions app/src/main/java/com/sf/stormwaterutilityandroid/InspectionForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

import me.riddhimanadib.formmaster.FormBuilder;
Expand All @@ -17,9 +18,7 @@
import me.riddhimanadib.formmaster.model.FormElementPickerMulti;
import me.riddhimanadib.formmaster.model.FormElementPickerSingle;
import me.riddhimanadib.formmaster.model.FormElementSwitch;
import me.riddhimanadib.formmaster.model.FormElementTextEmail;
import me.riddhimanadib.formmaster.model.FormElementTextMultiLine;
import me.riddhimanadib.formmaster.model.FormElementTextPhone;
import me.riddhimanadib.formmaster.model.FormElementTextSingleLine;
import me.riddhimanadib.formmaster.model.FormHeader;

Expand Down Expand Up @@ -105,49 +104,6 @@ private void setupForm() {
FormElementTextMultiLine evidenceTextField = FormElementTextMultiLine.createInstance().setTitle("Evidence of off-site sediment/pollutants.\nHere is a description of type and location:").setHint("Enter text here");


submitButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
System.out.println("HELLO");
String projectContact = projectTextField.getValue();
String address = addressTextField.getValue();
String inspector = inspectorTextField.getValue();
String dateInspected = dateInspectedDatePicker.getValue();

boolean projectRepPresent = getSwitchBool(projectRepPresentSwitch.getValue());

String projectManager = projectManagerTextField.getValue();
String siteManager = siteManagerTextField.getValue();
String projectOwner = projectOwnerTextField.getValue();

boolean correctiveAction1 = getSwitchBool(correctiveAction1Switch.getValue());
boolean correctiveAction2 = getSwitchBool(correctiveAction2Switch.getValue());
boolean correctiveAction3 = getSwitchBool(correctiveAction3Switch.getValue());
boolean correctiveAction4 = getSwitchBool(correctiveAction4Switch.getValue());

List<String> correctiveAction5 = correctiveAction5Multi.getOptionsSelected();

boolean correctiveAction6 = getSwitchBool(correctiveAction6Switch.getValue());
boolean correctiveAction7 = getSwitchBool(correctiveAction6Switch.getValue());
boolean correctiveAction8 = getSwitchBool(correctiveAction8Switch.getValue());
boolean correctiveAction9 = getSwitchBool(correctiveAction9Switch.getValue());

String correctiveAction10 = correctiveAction10Multi.getValue();

String otherCorrectiveAction1 = otherCorrectiveAction1TextField.getValue();
String otherCorrectiveAction2 = otherCorrectiveAction2TextField.getValue();
String otherCorrectiveAction3 = otherCorrectiveAction3TextField.getValue();

List<String> enforcementAction = enforcementActionPickerSingle.getOptionsSelected();

String evidence = evidenceTextField.getValue();


}
});



List<BaseFormElement> formItems = new ArrayList<>();

formItems.add(projectTextField);
Expand Down Expand Up @@ -192,13 +148,123 @@ public void onClick(View view) {

formItems.add(evidenceTextField);


// populate formBuilder with items
formBuilder.addFormElements(formItems);

// onSubmit
submitButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String contact = projectTextField.getValue();
String location = addressTextField.getValue();
String inspector = inspectorTextField.getValue();
String date = dateInspectedDatePicker.getValue();

ArrayList<String> answersList = new ArrayList<>(20);

boolean projectRepPresent = getSwitchBool(projectRepPresentSwitch.getValue());
answersList.add(projectRepPresent + "");

String projectManager = projectManagerTextField.getValue();
String siteManager = siteManagerTextField.getValue();
String projectOwner = projectOwnerTextField.getValue();
answersList.add(projectManager);
answersList.add(siteManager);
answersList.add(projectOwner);

boolean correctiveAction1 = getSwitchBool(correctiveAction1Switch.getValue());
boolean correctiveAction2 = getSwitchBool(correctiveAction2Switch.getValue());
boolean correctiveAction3 = getSwitchBool(correctiveAction3Switch.getValue());
boolean correctiveAction4 = getSwitchBool(correctiveAction4Switch.getValue());
answersList.add(correctiveAction1 + "");
answersList.add(correctiveAction2 + "");
answersList.add(correctiveAction3 + "");
answersList.add(correctiveAction4 + "");

List<String> correctiveAction5 = correctiveAction5Multi.getOptionsSelected();
answersList.addAll(correctiveAction5);

boolean correctiveAction6 = getSwitchBool(correctiveAction6Switch.getValue());
boolean correctiveAction7 = getSwitchBool(correctiveAction6Switch.getValue());
boolean correctiveAction8 = getSwitchBool(correctiveAction8Switch.getValue());
boolean correctiveAction9 = getSwitchBool(correctiveAction9Switch.getValue());
answersList.add(correctiveAction6 + "");
answersList.add(correctiveAction7 + "");
answersList.add(correctiveAction8 + "");
answersList.add(correctiveAction9 + "");

String correctiveAction10 = correctiveAction10Multi.getValue();
answersList.add(correctiveAction10);

String otherCorrectiveAction1 = otherCorrectiveAction1TextField.getValue();
String otherCorrectiveAction2 = otherCorrectiveAction2TextField.getValue();
String otherCorrectiveAction3 = otherCorrectiveAction3TextField.getValue();
answersList.add(otherCorrectiveAction1);
answersList.add(otherCorrectiveAction2);
answersList.add(otherCorrectiveAction3);


List<String> enforcementAction = enforcementActionPickerSingle.getOptionsSelected();
answersList.addAll(enforcementAction);

String[] imgLink = new String[]{evidenceTextField.getValue()};


String[] answers = answersList.toArray(new String[0]);
// System.out.println(Arrays.toString(answers));
ConstructionFormData constructionFormData = new ConstructionFormData(contact, date, inspector, location, answers, imgLink);
System.out.println(constructionFormData);
}
});




}

public boolean getSwitchBool(String value) {
private boolean getSwitchBool(String value) {
if (value.equals("yes")) return true;
return false;
}

private class ConstructionFormData {
String contact = "";
String date = "";
String inspector = "";
String location = "";
String[] answers;

// SortTimeStamp set in constructor
Date SortTimeStamp;

String[] imgLink;

public ConstructionFormData(String contact, String date, String inspector,
String location, String[] answers, String[] imgLink) {
this.contact = contact;
this.date = date;
this.inspector = inspector;
this.location = location;
this.answers = answers;

this.SortTimeStamp = new Date(System.currentTimeMillis());

this.answers = answers;
}



@Override
public String toString() {
return "ConstructionFormData{" +
"contact=" + contact + '\n' +
", date=" + date + '\n' +
", inspector=" + inspector + '\n' +
", location=" + location + '\n' +
", answers=" + Arrays.toString(answers) + "\n" +
", SortTimeStamp=" + SortTimeStamp + "\n" +
", imgLink=" + Arrays.toString(imgLink) + "\n" +
'}';
}
}
}

0 comments on commit 042f8d4

Please sign in to comment.