private void getMyGroupApiSuccess(Object obj) { if (obj instanceof Groups) { final Groups groups = (Groups) obj; if (groups.getCode() == 200) { List<Group> grouplist = new ArrayList<>(); if (groups.getResult() != null) { for (int i = 0; i < groups.getResult().size(); i++) { String id = groups.getResult().get(i).getId(); String name = groups.getResult().get(i).getName(); if (groups.getResult().get(i).getPortrait() != null) { Uri uri = Uri.parse(groups.getResult().get(i).getPortrait()); grouplist.add(new Group(id, name, uri)); } else { grouplist.add(new Group(id, name, null)); } } HashMap<String, Group> groupM = new HashMap<String, Group>(); for (int i = 0; i < grouplist.size(); i++) { groupM.put(groups.getResult().get(i).getId(), grouplist.get(i)); Log.e("login", "------get Group id---------" + groups.getResult().get(i).getId()); } if (DemoContext.getInstance() != null) DemoContext.getInstance().setGroupMap(groupM); if (grouplist.size() > 0) RongIM.getInstance() .getRongIMClient() .syncGroup( grouplist, new RongIMClient.OperationCallback() { @Override public void onSuccess() { Log.e(TAG, "---syncGroup-onSuccess---"); } @Override public void onError(RongIMClient.ErrorCode errorCode) { Log.e(TAG, "---syncGroup-onError---"); } }); } } else { // WinToast.toast(this, groups.getCode()); } } }
private void getMyGroupApiSuccess(Object obj) { if (obj instanceof Groups) { final Groups groups = (Groups) obj; if (groups.getCode() == 200) { List<Group> grouplist = new ArrayList<Group>(); if (groups.getResult() != null) { for (int i = 0; i < groups.getResult().size(); i++) { String id = groups.getResult().get(i).getId(); String name = groups.getResult().get(i).getName(); if (groups.getResult().get(i).getPortrait() != null) { Uri uri = Uri.parse(groups.getResult().get(i).getPortrait()); grouplist.add(new Group(id, name, uri)); } else { grouplist.add(new Group(id, name, null)); } } HashMap<String, Group> groupM = new HashMap<String, Group>(); for (int i = 0; i < grouplist.size(); i++) { groupM.put(groups.getResult().get(i).getId(), grouplist.get(i)); } if (DemoContext.getInstance() != null) DemoContext.getInstance().setGroupMap(groupM); Intent in = new Intent(); in.setAction(MainActivity.ACTION_DMEO_GROUP_MESSAGE); sendBroadcast(in); if (grouplist.size() > 0) RongIM.getInstance() .getRongIMClient() .syncGroup( grouplist, new RongIMClient.OperationCallback() { @Override public void onSuccess() { Log.e(TAG, "---syncGroup-onSuccess---"); } @Override public void onError(RongIMClient.ErrorCode errorCode) { Log.e(TAG, "---syncGroup-onError---"); } }); } } } }