Exemple #1
0
 public static List<Group> getGroupListFromJSON(JSONObject json) {
   List<Group> list = new ArrayList<Group>();
   try {
     JSONArray a = json.getJSONArray("data");
     for (int i = 0; i < a.length(); i++) {
       JSONObject o = a.getJSONObject(i);
       Group g = Group.fromJSON(o);
       list.add(g);
     }
     return list;
   } catch (JSONException e) {
     Logger.e("Group.getGroupListFromJSON", e.getMessage());
   }
   return null;
 }
Exemple #2
0
  public static Group updateFromJSON(Group group, JSONObject json) {
    try {
      if (json.has("groupId")) {
        group = Group.fromJSON(json);
        assert (group != null);
      }
      group.owner = Contact.fromJSON(json.getJSONObject("owner"));
      List<Contact> list = Contact.getContactsFromJSON(json, "members");
      if (list != null && group.owner != null) {
        list.add(0, group.owner);
      }
      group.contactList = list;

    } catch (JSONException e) {
      Logger.e(TAG, e.getMessage());
    }
    return group;
  }