Permalink
Browse files

made code more defensive with documents missing required fields

  • Loading branch information...
1 parent 63e44d4 commit db0b2166ab8beabaa8115a306f5905073a5a5598 @mschoch committed Aug 18, 2011
Showing with 14 additions and 7 deletions.
  1. +14 −7 src/com/couchbase/grocerysync/CouchListAdapter.java
@@ -77,15 +77,22 @@ public View getView(int position, View itemView, ViewGroup parent) {
// JsonNode document = row.getDocAsNode();
JsonNode document = (JsonNode)getItem(position);
JsonNode textNode = document.get("text");
- 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);
+ if(textNode != null) {
+ label.setText(textNode.getTextValue());
}
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);
+ }
}

0 comments on commit db0b216

Please sign in to comment.