Skip to content

Commit

Permalink
Renamed Alias to Key. Fixed array error
Browse files Browse the repository at this point in the history
  • Loading branch information
rkodev committed May 6, 2019
1 parent 66df34c commit 2d166f7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class JsonFormConstants {
public static final String BEHAVIOUR = "behaviour";
public static final String RESULT = "result";
public static final String VALUE = "value";
public static final String ALIAS = "alias";
public static final String KEYS = "keys";
public static final String SECOND_VALUE = "second_value";
public static final String OPENMRS_ENTITY_PARENT = "openmrs_entity_parent";
public static final String OPENMRS_ENTITY = "openmrs_entity";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public void addFormElements() {

}

@SuppressLint ("ResourceAsColor")
@SuppressLint("ResourceAsColor")
public void setUpToolBar() {
getView().setActionBarTitle(mStepDetails.optString(JsonFormConstants.STEP_TITLE));
getView().setToolbarTitleColor(R.color.white);
Expand Down Expand Up @@ -257,7 +257,7 @@ protected void launchErrorDialog() {
errorFragment = new JsonFormErrorFragment();
}
FragmentManager fm = ((JsonFormFragment) getView()).getChildFragmentManager();
@SuppressLint ("CommitTransaction") FragmentTransaction ft = fm.beginTransaction();
@SuppressLint("CommitTransaction") FragmentTransaction ft = fm.beginTransaction();
errorFragment.show(ft, JsonFormErrorFragment.TAG);
}

Expand Down Expand Up @@ -520,7 +520,7 @@ private void resetWidgetReadOnly(View view) {
}
}

@SuppressWarnings ({"unchecked"})
@SuppressWarnings({"unchecked"})
private void setCheckboxesEditable(View editButton) {
List<View> checkboxLayouts = (ArrayList<View>) editButton.getTag(R.id.editable_view);
resetWidgetReadOnly(editButton);
Expand Down Expand Up @@ -691,15 +691,15 @@ public void onItemSelected(AdapterView<?> parent, View view, int position, long
String openMrsEntityParent = (String) parent.getTag(R.id.openmrs_entity_parent);
String openMrsEntity = (String) parent.getTag(R.id.openmrs_entity);
String openMrsEntityId = (String) parent.getTag(R.id.openmrs_entity_id);
JSONArray jsonArray = (JSONArray) parent.getTag(R.id.alias);
JSONArray jsonArray = (JSONArray) parent.getTag(R.id.keys);
CustomTextView customTextView = (CustomTextView) parent.getTag(R.id.number_selector_textview);
Boolean popup = (Boolean) parent.getTag(R.id.extraPopup);
if (popup == null) {
popup = false;
}

String value = parent.getItemAtPosition(position).toString();
if(jsonArray != null && position >0 && jsonArray.length() > 0){
if (jsonArray != null && position > -1 && jsonArray.length() > 0) {
try {
value = jsonArray.getString(position);
} catch (JSONException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ private void addSpinner(JSONObject jsonObject, RelativeLayout spinnerRelativeLay
spinner.setFloatingLabelText(jsonObject.getString(JsonFormConstants.HINT));
}

JSONArray aliasJson = null;
if (jsonObject.has(JsonFormConstants.ALIAS)) {
aliasJson = jsonObject.getJSONArray(JsonFormConstants.ALIAS);
spinner.setTag(R.id.alias, aliasJson);
JSONArray keysJson = null;
if (jsonObject.has(JsonFormConstants.KEYS)) {
keysJson = jsonObject.getJSONArray(JsonFormConstants.KEYS);
spinner.setTag(R.id.keys, keysJson);
}

setViewTags(jsonObject, canvasIds, stepName, popup, openMrsEntityParent, openMrsEntity, openMrsEntityId, spinner);
Expand Down Expand Up @@ -137,9 +137,9 @@ private void addSpinner(JSONObject jsonObject, RelativeLayout spinnerRelativeLay
values = new String[valuesJson.length()];
for (int i = 0; i < valuesJson.length(); i++) {
values[i] = valuesJson.optString(i);
if (aliasJson == null && valueToSelect.equals(values[i])) {
if (keysJson == null && valueToSelect.equals(values[i])) {
indexToSelect = i;
} else if (aliasJson != null && valueToSelect.equals(aliasJson.optString(i))) {
} else if (keysJson != null && valueToSelect.equals(keysJson.optString(i))) {
indexToSelect = i;
}
}
Expand Down
2 changes: 1 addition & 1 deletion android-json-form-wizard/src/main/res/values/ids.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<item name="openmrs_entity_parent" type='id' />
<item name="openmrs_entity" type='id' />
<item name="openmrs_entity_id" type='id' />
<item name="alias" type='id' />
<item name="keys" type='id' />
<item name="relevance" type="id" />
<item name="calculation" type="id" />
<item name="constraints" type="id" />
Expand Down
2 changes: 1 addition & 1 deletion sample/src/main/assets/json.form/single_form.json
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
"Ame OA",
"Haja OA"
],
"alias": [
"keys": [
"Married",
"Single"
],
Expand Down

0 comments on commit 2d166f7

Please sign in to comment.