Skip to content

Commit

Permalink
made code more defensive with documents missing required fields
Browse files Browse the repository at this point in the history
  • Loading branch information
mschoch committed Aug 18, 2011
1 parent 63e44d4 commit db0b216
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/com/couchbase/grocerysync/CouchListAdapter.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -77,15 +77,22 @@ public View getView(int position, View itemView, ViewGroup parent) {
// JsonNode document = row.getDocAsNode(); // JsonNode document = row.getDocAsNode();
JsonNode document = (JsonNode)getItem(position); JsonNode document = (JsonNode)getItem(position);
JsonNode textNode = document.get("text"); JsonNode textNode = document.get("text");
label.setText(textNode.getTextValue()); if(textNode != null) {

label.setText(textNode.getTextValue());
JsonNode checkNode = document.get("check");
ImageView icon = (ImageView) v.findViewById(R.id.icon);
if(checkNode.getBooleanValue()) {
icon.setImageResource(R.drawable.list_area___checkbox___checked);
} }
else { else {
icon.setImageResource(R.drawable.list_area___checkbox___unchecked); label.setText("");
}

JsonNode checkNode = document.get("check");
if(checkNode != null) {
ImageView icon = (ImageView) v.findViewById(R.id.icon);
if(checkNode.getBooleanValue()) {
icon.setImageResource(R.drawable.list_area___checkbox___checked);
}
else {
icon.setImageResource(R.drawable.list_area___checkbox___unchecked);
}
} }




Expand Down

0 comments on commit db0b216

Please sign in to comment.