Skip to content

Commit

Permalink
copied form code into the form fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
will2312 committed Apr 1, 2021
1 parent 0c62627 commit a7c03b9
Showing 1 changed file with 180 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

import me.riddhimanadib.formmaster.FormBuilder;
import me.riddhimanadib.formmaster.model.BaseFormElement;
import me.riddhimanadib.formmaster.model.FormElementPickerDate;
import me.riddhimanadib.formmaster.model.FormElementPickerMulti;
import me.riddhimanadib.formmaster.model.FormElementSwitch;
import me.riddhimanadib.formmaster.model.FormElementTextNumber;
import me.riddhimanadib.formmaster.model.FormElementTextSingleLine;
import me.riddhimanadib.formmaster.model.FormHeader;
Expand Down Expand Up @@ -142,9 +145,109 @@ public void onClick(View v) {
}

private void setupFormGen() {
String nameOfInspector = "";
String nameOfSite = "";
String dateRow = "";

double outfall = 0.0;
double longitude = 0.0;
double latitude = 0.0;
double invertElevation = 0.0;

String type = "";
String pipeSize = "";
String channelBottomWidth = "";
String receivingWater = "";

boolgen = true;


fbGEn = new FormBuilder(getContext(), rvGen);

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

FormHeader title = (FormHeader) new FormHeader().setTitle("Report");
formItems.add(title);

FormElementTextSingleLine name = FormElementTextSingleLine.createInstance().setTitle("Name of Inspector").setValue("");
nameOfInspector = name.getValue();
formItems.add(name);

FormElementTextSingleLine site = FormElementTextSingleLine.createInstance().setTitle("Name of site").setValue("");
nameOfSite = site.getValue();
formItems.add(site);

FormElementPickerDate date = FormElementPickerDate.createInstance().setTitle("Date Row").setDateFormat("XX-XX-XXXX").setValue("");
dateRow = date.getValue();
formItems.add(date);

FormElementTextSingleLine outfallValue = FormElementTextSingleLine.createInstance().setTitle("Outfall").setValue("0");
outfall = Double.parseDouble(outfallValue.getValue());
formItems.add(outfallValue);

FormElementTextSingleLine longitudeValue = FormElementTextSingleLine.createInstance().setTitle("Longitude").setValue("0");
longitude = Double.parseDouble(longitudeValue.getValue());
formItems.add(longitudeValue);

FormElementTextSingleLine latitudeValue = FormElementTextSingleLine.createInstance().setTitle("Latitude").setValue("0");
latitude = Double.parseDouble(latitudeValue.getValue());
formItems.add(latitudeValue);

FormElementTextSingleLine invertElevationValue = FormElementTextSingleLine.createInstance().setTitle("Invert Elevation").setValue("0");
invertElevation = Double.parseDouble(invertElevationValue.getValue());
formItems.add(invertElevationValue);

List<String> pipeTypeOptions = new ArrayList<String>();
pipeTypeOptions.add("Enclosed Pipe");
pipeTypeOptions.add("Open Channel");
FormElementPickerMulti typeValue = FormElementPickerMulti.createInstance().setTitle("Type").setOptions(pipeTypeOptions);
type = typeValue.getValue();
formItems.add(typeValue);

List<String> pipeSizeOptions = new ArrayList<String>();
pipeSizeOptions.add("4\"");
pipeSizeOptions.add("6\"");
pipeSizeOptions.add("8\"");
pipeSizeOptions.add("10\"");
pipeSizeOptions.add("12\"");
pipeSizeOptions.add("14\"");
pipeSizeOptions.add("16\"");
pipeSizeOptions.add("18\"");
pipeSizeOptions.add("20\"");
pipeSizeOptions.add("24\"");
pipeSizeOptions.add("36\"");
FormElementPickerMulti pipeSizeValue = FormElementPickerMulti.createInstance().setTitle("Pipe Size").setOptions(pipeSizeOptions);
pipeSize = pipeSizeValue.getValue();
formItems.add(pipeSizeValue);

List<String> channelWidthOptions = new ArrayList<String>();
channelWidthOptions.add("2\"");
channelWidthOptions.add("4\"");
channelWidthOptions.add("6\"");
channelWidthOptions.add("8\"");
channelWidthOptions.add("10\"");
channelWidthOptions.add("12\"");
channelWidthOptions.add("14\"");
channelWidthOptions.add("16\"");
channelWidthOptions.add("18\"");
channelWidthOptions.add("20\"");
FormElementPickerMulti channelBottomWidthValue = FormElementPickerMulti.createInstance().setTitle("Channel Bottom Width")
.setOptions(channelWidthOptions);
channelBottomWidth = channelBottomWidthValue.getValue();
formItems.add(channelBottomWidthValue);

List<String> receivingWaterOptions = new ArrayList<String>();
receivingWaterOptions.add("Turkey Creek");
receivingWaterOptions.add("Deep River");
receivingWaterOptions.add("Un-Named Tributary");
receivingWaterOptions.add("Spring Run Ditch");
receivingWaterOptions.add("Hart Ditch");
receivingWaterOptions.add("Coffee Creek");
receivingWaterOptions.add("Niles Ditch");
receivingWaterOptions.add("Beaver Dam Ditch");
receivingWaterOptions.add("Kaiser Ditch");

FormElementPickerMulti receiving = FormElementPickerMulti.createInstance().setTitle("Receiving Water").setOptions(receivingWaterOptions);
receivingWater = receiving.getValue();
formItems.add(receiving);
}
private void setupFormHQ() {
boolhq = true;
Expand All @@ -168,7 +271,7 @@ private void setupFormHQ() {
FormElementTextNumber element18 = FormElementTextNumber.createInstance().setTitle("Land Use").setValue("0");
FormElementTextNumber element19 = FormElementTextNumber.createInstance().setTitle("Bank Erosion").setValue("0");

formItemsHQ = new ArrayList<>();
formItemsHQ = new ArrayList<>();

formItemsHQ.add(element2);
formItemsHQ.add(element3);
Expand All @@ -192,109 +295,120 @@ private void setupFormHQ() {

}
private void setupFormDWS() {
String flowVal = "";
String odorVal = "";
String colorVal = "";
String polutantsVal = "";
String obstructionVal = "";
String maintenanceVal = "";
String screenVal = "";

boolean flowPres = false;
boolean odorPres = false;
boolean colorPres = false;
boolean polutantsPres = false;
boolean obstructionPres = false;
boolean needMaintenance = false;
boolean screenOK = false;

booldws = true;
fbDWS = new FormBuilder(getContext(), rvDWS);

FormHeader title = (FormHeader) new FormHeader().setTitle("Dry Weather Screening");

//Outfall --> Question: How do you do a subheading?
FormElementTextSingleLine flow = new FormElementTextSingleLine().setTitle("Presence of Flow");
FormElementTextNumber flowData = FormElementTextNumber.createInstance(); //what data type is this?
FormElementSwitch flow = FormElementSwitch.createInstance().setTitle("Presence of Flow").setSwitchTexts("Yes", "No");
flowPres = convertToBoolean(flow.getValue());

FormElementTextSingleLine odor = new FormElementTextSingleLine().setTitle("Unusual Odor");
FormElementTextNumber odorData = FormElementTextNumber.createInstance();
FormElementSwitch odor = FormElementSwitch.createInstance().setTitle("Unusual Odor").setSwitchTexts("Yes", "No");
odorVal = odor.getValue();
odorPres = convertToBoolean(odorVal);

FormElementTextSingleLine color = new FormElementTextSingleLine().setTitle("Unusual Color");
FormElementTextNumber colorData = FormElementTextNumber.createInstance();
FormElementSwitch color = FormElementSwitch.createInstance().setTitle("Unusual Color").setSwitchTexts("Yes", "No");
colorVal = color.getValue();
colorPres = convertToBoolean(colorVal);

FormElementTextSingleLine polutants = new FormElementTextSingleLine().setTitle("Polutants Nearby");
FormElementTextNumber polutantsData = FormElementTextNumber.createInstance();
polutantsData.setTitle("Polutants Data");
FormElementSwitch polutants = FormElementSwitch.createInstance().setTitle("Polutants Nearby").setSwitchTexts("Yes", "No");
polutantsVal = polutants.getValue();
polutantsPres = convertToBoolean(polutantsVal);

FormElementTextSingleLine obstruction = new FormElementTextSingleLine().setTitle("Obstruction");
FormElementTextNumber obstructionData = FormElementTextNumber.createInstance();
FormElementSwitch obstruction = FormElementSwitch.createInstance().setTitle("Obstruction").setSwitchTexts("Yes", "No");
obstructionVal = obstruction.getValue();
obstructionPres = convertToBoolean(obstructionVal);

FormElementTextSingleLine maintenance = new FormElementTextSingleLine().setTitle("Needs Maintenance");
FormElementTextNumber maintenanceData = FormElementTextNumber.createInstance();
FormElementSwitch maintenance = FormElementSwitch.createInstance().setTitle("Needs Maintenance").setSwitchTexts("Yes", "No");
maintenanceVal = maintenance.getValue();
needMaintenance = convertToBoolean(maintenanceVal);

FormElementTextSingleLine screen = new FormElementTextSingleLine().setTitle("Screen OK");
FormElementTextNumber screenData = FormElementTextNumber.createInstance();
FormElementSwitch screen = FormElementSwitch.createInstance().setTitle("Screen OK").setSwitchTexts("Yes", "No");
screenVal = screen.getValue();
screenOK = convertToBoolean(screenVal);

formItemsDWS = new ArrayList<>();

formItemsDWS.add(flow);
formItemsDWS.add(flowData);
formItemsDWS.add(odor);
formItemsDWS.add(odorData);
formItemsDWS.add(color);
formItemsDWS.add(colorData);
formItemsDWS.add(polutants);
formItemsDWS.add(polutantsData);
formItemsDWS.add(obstruction);
formItemsDWS.add(obstructionData);
formItemsDWS.add(maintenance);
formItemsDWS.add(maintenanceData);
formItemsDWS.add(screen);
formItemsDWS.add(screenData);

fbDWS.addFormElements(formItemsDWS);
}
private void setupFormCT() {
boolct = true;
fbCT = new FormBuilder(getContext(), rvCT);

FormHeader title = (FormHeader) new FormHeader().setTitle("Chemical Testing");
double tempVal = 0.0;
double turbidityVal = 0.0;
double phVal = 0.0;
double nitrateVal = 0.0;
double phosphateVal = 0.0;
double oxygenVal = 0.0;
double coliVal = 0.0;
double other1Val = 0.0;
double other2Val = 0.0;

//Outfall --> Question: How do you do a subheading?

FormElementTextSingleLine temperature = new FormElementTextSingleLine().setTitle("Temperature (C) Change");
//FormHeader temp = FormHeader.createInstance("Temperature (C) Change");
FormElementTextNumber tempData = FormElementTextNumber.createInstance(); //what data type is this?
FormHeader title = (FormHeader) new FormHeader().setTitle("Chemical Testing");

FormElementTextSingleLine tubidity = new FormElementTextSingleLine().setTitle("Tubidity (NTU)");
FormElementTextNumber tubidityData = FormElementTextNumber.createInstance();
FormElementTextSingleLine temperature = new FormElementTextSingleLine().setTitle("Temperature (C) Change").setValue("0");
tempVal = Double.parseDouble(temperature.getValue());

FormElementTextSingleLine pH = new FormElementTextSingleLine().setTitle("pH");
FormElementTextNumber pHData = FormElementTextNumber.createInstance();
FormElementTextSingleLine tubidity = new FormElementTextSingleLine().setTitle("Tubidity (NTU)").setValue("0");
turbidityVal = Double.parseDouble(tubidity.getValue());

FormElementTextSingleLine nitrate = new FormElementTextSingleLine().setTitle("Nitrate (mg/L)");
FormElementTextNumber nitrateData = FormElementTextNumber.createInstance();
FormElementTextSingleLine pH = new FormElementTextSingleLine().setTitle("pH").setValue("0");
phVal = Double.parseDouble(pH.getValue());

FormElementTextSingleLine phosphate = new FormElementTextSingleLine().setTitle("Total Phosphate (mg/L)");
FormElementTextNumber phosphateData = FormElementTextNumber.createInstance();
FormElementTextSingleLine nitrate = new FormElementTextSingleLine().setTitle("Nitrate (mg/L)").setValue("0");
nitrateVal = Double.parseDouble(nitrate.getValue());

FormElementTextSingleLine oxygen = new FormElementTextSingleLine().setTitle("Dissolved Oxygen (mg/L)");
FormElementTextNumber oxygenData = FormElementTextNumber.createInstance();
FormElementTextSingleLine phosphate = new FormElementTextSingleLine().setTitle("Total Phosphate (mg/L)").setValue("0");
phosphateVal = Double.parseDouble(phosphate.getValue());

FormElementTextSingleLine coli = new FormElementTextSingleLine().setTitle("E Coli (col/100mL)");
FormElementTextNumber coliData = FormElementTextNumber.createInstance();
FormElementTextSingleLine oxygen = new FormElementTextSingleLine().setTitle("Dissolved Oxygen (mg/L)").setValue("0");
oxygenVal = Double.parseDouble(oxygen.getValue());

FormElementTextSingleLine other1 = new FormElementTextSingleLine().setTitle("Other 1");
FormElementTextNumber other1Data = FormElementTextNumber.createInstance();
FormElementTextSingleLine coli = new FormElementTextSingleLine().setTitle("E Coli (col/100mL)").setValue("0");
coliVal = Double.parseDouble(coli.getValue());

FormElementTextSingleLine other2 = new FormElementTextSingleLine().setTitle("Other 2");
FormElementTextNumber other2Data = FormElementTextNumber.createInstance();
FormElementTextSingleLine other1 = new FormElementTextSingleLine().setTitle("Other 1").setValue("");
other1Val = Double.parseDouble(other1.getValue());

formItemsCT = new ArrayList<>();
FormElementTextSingleLine other2 = new FormElementTextSingleLine().setTitle("Other 2").setValue("");
other2Val = Double.parseDouble(other2.getValue());
formItemsCT = new ArrayList<>();

formItemsCT.add(title);
formItemsCT.add(temperature);
formItemsCT.add(tempData);
formItemsCT.add(tubidity);
formItemsCT.add(tubidityData);
formItemsCT.add(pH);
formItemsCT.add(pHData);
formItemsCT.add(nitrate);
formItemsCT.add(nitrateData);
formItemsCT.add(phosphate);
formItemsCT.add(phosphateData);
formItemsCT.add(oxygen);
formItemsCT.add(oxygenData);
formItemsCT.add(coli);
formItemsCT.add(coliData);
formItemsCT.add(other1);
formItemsCT.add(other1Data);
formItemsCT.add(other2);
formItemsCT.add(other2Data);

fbCT.addFormElements(formItemsCT);

Expand All @@ -303,4 +417,12 @@ private void setupFormBM() {
boolbm = true;

}

public boolean convertToBoolean(String s) {
if (s.compareTo("Yes") == 0) {
return true;
} else {
return false;
}
}
}

0 comments on commit a7c03b9

Please sign in to comment.