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 { ...@@ -45,6 +45,9 @@ public class CatalogueVariable {
@SerializedName("Active") @SerializedName("Active")
@Expose @Expose
private boolean active; private boolean active;
@SerializedName("default_value")
@Expose
private String defaultValue;
// @SerializedName("type") // @SerializedName("type")
// @Expose // @Expose
...@@ -173,6 +176,14 @@ public class CatalogueVariable { ...@@ -173,6 +176,14 @@ public class CatalogueVariable {
this.active = active; this.active = active;
} }
public String getDefaultValue() {
return defaultValue;
}
public void setDefaultValue(String defaultValue) {
this.defaultValue = defaultValue;
}
public List<VariableChoice> getVariableChoiceList() { public List<VariableChoice> getVariableChoiceList() {
return mVariableChoiceList; return mVariableChoiceList;
} }
...@@ -181,9 +192,23 @@ public class CatalogueVariable { ...@@ -181,9 +192,23 @@ public class CatalogueVariable {
this.mVariableChoiceList = mVariableChoiceList; this.mVariableChoiceList = mVariableChoiceList;
} }
public String[] getDisplayChoiceText(Context context, boolean isNoneRequired) { public String[] getDisplayChoiceText(Context context) {
String[] choiceText; 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 = new String[mVariableChoiceList.size() + 1];
choiceText[0] = context.getString(R.string.none_string); choiceText[0] = context.getString(R.string.none_string);
for (int i = 0; i < mVariableChoiceList.size(); i++) { for (int i = 0; i < mVariableChoiceList.size(); i++) {
...@@ -230,7 +255,6 @@ public class CatalogueVariable { ...@@ -230,7 +255,6 @@ public class CatalogueVariable {
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
this.setType(ViewType.from(viewType)); this.setType(ViewType.from(viewType));
} }
...@@ -254,6 +278,7 @@ public class CatalogueVariable { ...@@ -254,6 +278,7 @@ public class CatalogueVariable {
", order=" + order + ", order=" + order +
", referenceColumnName='" + referenceColumnName + '\'' + ", referenceColumnName='" + referenceColumnName + '\'' +
", active=" + active + ", active=" + active +
", defaultValue='" + defaultValue + '\'' +
", type=" + type + ", type=" + type +
", mVariableChoiceList=" + mVariableChoiceList + ", mVariableChoiceList=" + mVariableChoiceList +
'}'; '}';
......
...@@ -354,7 +354,7 @@ public class Util { ...@@ -354,7 +354,7 @@ public class Util {
selectBoxSpinner.setPadding(0, (int) context.getResources().getDimension(R.dimen.normal_margin), selectBoxSpinner.setPadding(0, (int) context.getResources().getDimension(R.dimen.normal_margin),
0, (int) context.getResources().getDimension(R.dimen.normal_margin)); 0, (int) context.getResources().getDimension(R.dimen.normal_margin));
ArrayAdapter<String> selectBoxSpinnerArrayAdapter = 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); selectBoxSpinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
selectBoxSpinner.setAdapter(selectBoxSpinnerArrayAdapter); selectBoxSpinner.setAdapter(selectBoxSpinnerArrayAdapter);
container.setInputView(selectBoxSpinner); container.setInputView(selectBoxSpinner);
...@@ -494,6 +494,8 @@ public class Util { ...@@ -494,6 +494,8 @@ public class Util {
case SELECT_BOX: case SELECT_BOX:
Spinner selectBoxSpinner = (Spinner) view; Spinner selectBoxSpinner = (Spinner) view;
String value = catalogueVariable.getDisplayChoiceText(selectBoxSpinner.getSelectedItem().toString()); String value = catalogueVariable.getDisplayChoiceText(selectBoxSpinner.getSelectedItem().toString());
/*value = null mean selected value is none or default value.*/
value = value != null ? value : "";
return value; return value;
default: default:
return getVariableViewValue(view, catalogueVariable.getType()); 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