Commit 24705d5a by Kunj Gupta

UOFLMA-119 - Fixed - Drop down by default it has to show "Select Group".

parent f0394a64
......@@ -45,6 +45,9 @@ public class CatalogueVariable {
@SerializedName("Active")
@Expose
private boolean active;
@SerializedName("default_value")
@Expose
private String defaultValue;
// @SerializedName("type")
// @Expose
......@@ -173,6 +176,14 @@ public class CatalogueVariable {
this.active = active;
}
public String getDefaultValue() {
return defaultValue;
}
public void setDefaultValue(String defaultValue) {
this.defaultValue = defaultValue;
}
public List<VariableChoice> getVariableChoiceList() {
return mVariableChoiceList;
}
......@@ -181,9 +192,23 @@ public class CatalogueVariable {
this.mVariableChoiceList = mVariableChoiceList;
}
public String[] getDisplayChoiceText(Context context, boolean isNoneRequired) {
public String[] getDisplayChoiceText(Context context) {
String[] choiceText;
if(isNoneRequired) {
if(defaultValue!=null) {
choiceText = new String[mVariableChoiceList.size() + 1];
choiceText[0] = defaultValue;
for (int i = 0; i < mVariableChoiceList.size(); i++) {
VariableChoice variableChoice = mVariableChoiceList.get(i);
/*(i+1) for add None text as a first Element*/
if(variableChoice.getMisc() > 0) {
choiceText[i + 1] = String.format(context.getString(R.string.variable_form_misc_info_string),
variableChoice.getText(),
variableChoice.getMisc());
} else {
choiceText[i + 1] = variableChoice.getText();
}
}
} else if(isNoneRequired) {
choiceText = new String[mVariableChoiceList.size() + 1];
choiceText[0] = context.getString(R.string.none_string);
for (int i = 0; i < mVariableChoiceList.size(); i++) {
......@@ -230,7 +255,6 @@ public class CatalogueVariable {
} catch (JSONException e) {
e.printStackTrace();
}
this.setType(ViewType.from(viewType));
}
......@@ -254,6 +278,7 @@ public class CatalogueVariable {
", order=" + order +
", referenceColumnName='" + referenceColumnName + '\'' +
", active=" + active +
", defaultValue='" + defaultValue + '\'' +
", type=" + type +
", mVariableChoiceList=" + mVariableChoiceList +
'}';
......
......@@ -354,7 +354,7 @@ public class Util {
selectBoxSpinner.setPadding(0, (int) context.getResources().getDimension(R.dimen.normal_margin),
0, (int) context.getResources().getDimension(R.dimen.normal_margin));
ArrayAdapter<String> selectBoxSpinnerArrayAdapter =
new ArrayAdapter<>(context, android.R.layout.simple_spinner_item, catalogueVariable.getDisplayChoiceText(context, catalogueVariable.isNoneRequired()));
new ArrayAdapter<>(context, android.R.layout.simple_spinner_item, catalogueVariable.getDisplayChoiceText(context));
selectBoxSpinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
selectBoxSpinner.setAdapter(selectBoxSpinnerArrayAdapter);
container.setInputView(selectBoxSpinner);
......@@ -494,6 +494,8 @@ public class Util {
case SELECT_BOX:
Spinner selectBoxSpinner = (Spinner) view;
String value = catalogueVariable.getDisplayChoiceText(selectBoxSpinner.getSelectedItem().toString());
/*value = null mean selected value is none or default value.*/
value = value != null ? value : "";
return value;
default:
return getVariableViewValue(view, catalogueVariable.getType());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment