public String next() { ListEntry listEntry = entries.next(); StringBuffer line = new StringBuffer(); for (String tag : listEntry.getCustomElements().getTags()) { line.append("\"").append(listEntry.getCustomElements().getValue(tag)).append("\""); line.append(","); } if (line.length() > 0) { line.deleteCharAt(line.length() - 1); } return line.toString(); }
public JSONObject toJson() { JSONObject JSONObjectShoppingList = new JSONObject(); JSONArray JSONArrayListEntry = new JSONArray(); JSONArray JSONArrayUser = new JSONArray(); try { JSONObjectShoppingList.put("id", id).put("name", name).put("status", status); for (ListEntry le : this.listEntry) { JSONArrayListEntry.put(le.toJson()); } for (AppUser user : this.userList) { JSONArrayUser.put(user.toJson()); } JSONObjectShoppingList.put("listEntry", JSONArrayListEntry); JSONObjectShoppingList.put("user", JSONArrayUser); } catch (JSONException ex) { Logger.getLogger(ShoppingList.class.getName()).log(Level.SEVERE, null, ex); } return JSONObjectShoppingList; }
public void toggleCompleted(int index) { ListEntry entry = DbHelper.getItem((Cursor) mAdapter.getItem(index)); mDbHelper.updateCompleted(entry.getId(), !entry.isCompleted()); requery(); }