Beispiel #1
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;
  }
Beispiel #2
0
 public static Group fromJSON(JSONObject json) {
   try {
     Group g = new Group();
     g.id = json.getInt("groupId");
     g.imId = json.getString("chatGroupId");
     g.name = json.getString("groupName");
     g.img = json.getString("logo");
     g.userNum = json.getInt("userNum");
     g.mFirstPinYin = "*";
     g.owner = null;
     g.contactList = null;
     g.apps = null;
     return g;
   } catch (Exception e) {
     if (Logger.DEBUG) {
       e.printStackTrace();
     }
   }
   return null;
 }
Beispiel #3
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;
 }