Commit 54d3d903 by Kunj Gupta

UOFLMA-68: Added one more field "Order" in Variable Form, for sorting all items.

parent 8d8bd9c3
......@@ -93,8 +93,7 @@ public class CatalogueVariableApiManager {
JSONObject variableJsonObject = catalogueVariableJsonArray.getJSONObject(i);
CatalogueVariable catalogueVariable = gson.fromJson(variableJsonObject.toString(), CatalogueVariable.class);
catalogueVariable.parseJson(variableJsonObject);
// if(catalogueVariable.getName()!=null)
catalogueVariableList.add(catalogueVariable);
catalogueVariableList.add(catalogueVariable);
}
listener.onDoneApiCall(catalogueVariableList);
} else {
......
......@@ -17,7 +17,6 @@ import java.util.List;
* Created by Kunj on 12/8/16.
*/
public class CatalogueVariable {
private long catalogue_item_id = -1;
@SerializedName("name")
@Expose
......@@ -37,6 +36,9 @@ public class CatalogueVariable {
@SerializedName("reference_table")
@Expose
private String referenceTable;
@SerializedName("order")
@Expose
private int order;
// @SerializedName("type")
// @Expose
......@@ -44,14 +46,6 @@ public class CatalogueVariable {
private List<VariableChoice> mVariableChoiceList;
public long getCatalogueItemId() {
return catalogue_item_id;
}
public void setCatalogueItemId(long catalogue_item_id) {
this.catalogue_item_id = catalogue_item_id;
}
/**
*
* @return
......@@ -148,6 +142,14 @@ public class CatalogueVariable {
this.referenceTable = referenceTable;
}
public int getOrder() {
return order;
}
public void setOrder(int order) {
this.order = order;
}
public List<VariableChoice> getVariableChoiceList() {
return mVariableChoiceList;
}
......@@ -202,18 +204,19 @@ public class CatalogueVariable {
public static class Json {
public static final String SYS_ID = "sys_id";
public static final String TYPE = "type";
public static final String ORDER = "order";
}
@Override
public String toString() {
return "CatalogueVariable{" +
", catalogue_item_id=" + catalogue_item_id +
", name='" + name + '\'' +
"name='" + name + '\'' +
", questionText='" + questionText + '\'' +
", sysId='" + sysId + '\'' +
", mandatory=" + mandatory +
", isNoneRequired=" + isNoneRequired +
", referenceTable='" + referenceTable + '\'' +
", order=" + order +
", type=" + type +
", mVariableChoiceList=" + mVariableChoiceList +
'}';
......
......@@ -49,6 +49,8 @@ import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import butterknife.BindView;
......@@ -133,6 +135,14 @@ public class CatalogueVariableScreen extends AppCompatActivity {
@Override
public void onDoneApiCall(List<CatalogueVariable> catalogueVariableList) {
CatalogueLog.e("Data: catalogueVariableList: " + catalogueVariableList);
Collections.sort(catalogueVariableList, new Comparator<CatalogueVariable>() {
@Override
public int compare(CatalogueVariable lhs, CatalogueVariable rhs) {
return (lhs.getOrder() - rhs.getOrder());
}
});
mCatalogueVariableList = catalogueVariableList;
if(!catalogueVariableList.isEmpty()) {
......@@ -211,7 +221,7 @@ public class CatalogueVariableScreen extends AppCompatActivity {
for (int i = 0; i < mCatalogueVariableList.size(); i++) {
CatalogueVariable catalogueVariable = mCatalogueVariableList.get(i);
ViewType viewType = catalogueVariable.getType();
CatalogueLog.e("viewType: " + viewType);
CatalogueLog.e("viewType: " + viewType + ", Order: "+catalogueVariable.getOrder());
if (catalogueVariable.getName() == null) {
TextView nameNullView = new TextView(CatalogueVariableScreen.this);
nameNullView.setText(R.string.name_null_view_string);
......
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