Java源码示例:cn.jpush.im.android.api.callback.GetGroupInfoCallback
示例1
private void updateGroupInfo(MethodCall call, final Result result) {
HashMap<String, Object> map = call.arguments();
long groupId;
try {
JSONObject params = new JSONObject(map);
groupId = Long.parseLong(params.getString("id"));
} catch (JSONException e) {
e.printStackTrace();
handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, result);
return;
}
JMessageClient.getGroupInfo(groupId, new GetGroupInfoCallback() {
@Override
public void gotResult(int status, String desc, GroupInfo groupInfo) {
if (status == 0) {
handleResult(toJson(groupInfo), status, desc, result);
} else {
handleResult(status, desc, result);
}
}
});
}
示例2
private void groupSilenceMembers(MethodCall call, final Result result) {
HashMap<String, Object> map = call.arguments();
long groupId;
try {
JSONObject params = new JSONObject(map);
groupId = Long.parseLong(params.getString("groupId"));
} catch (JSONException e) {
e.printStackTrace();
handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, result);
return;
}
JMessageClient.getGroupInfo(groupId, new GetGroupInfoCallback() {
@Override
public void gotResult(int status, String desc, GroupInfo groupInfo) {
if (status == 0) {
List<GroupMemberInfo> groupSilenceMemberInfos = groupInfo.getGroupSilenceMemberInfos();
handleResult(toJson(groupSilenceMemberInfos), status, desc, result);
} else {
handleResult(status, desc, result);
}
}
});
}
示例3
public void isShowMore() {
JMessageClient.getGroupInfo(mGroupId, new GetGroupInfoCallback() {
@Override
public void gotResult(int responseCode, String responseMessage, GroupInfo groupInfo) {
if (responseCode == 0) {
List<UserInfo> groupMembers = groupInfo.getGroupMembers();
if (mIsCreator) {
if (groupMembers.size() > 13) {
mChatDetailView.isLoadMoreShow(true);
} else {
mChatDetailView.isLoadMoreShow(false);
}
} else {
if (groupMembers.size() > 14) {
mChatDetailView.isLoadMoreShow(true);
} else {
mChatDetailView.isLoadMoreShow(false);
}
}
}
}
});
}
示例4
private void downloadThumbGroupAvatar(MethodCall call, final Result result) {
HashMap<String, Object> map = call.arguments();
String id;
try {
JSONObject params = new JSONObject(map);
id = params.getString("id");
} catch (JSONException e) {
e.printStackTrace();
handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, result);
return;
}
JMessageClient.getGroupInfo(Long.parseLong(id), new GetGroupInfoCallback() {
@Override
public void gotResult(int status, String desc, GroupInfo groupInfo) {
if (status == 0) {
File avatarFile = groupInfo.getAvatarFile();
HashMap res= new HashMap();
res.put("id", groupInfo.getGroupID()+"");
String avatarFilePath = (avatarFile == null ? "" : avatarFile.getAbsolutePath());
res.put("filePath", avatarFilePath);
result.success(res);
} else {
handleResult(status, desc, result);
}
}
});
}
示例5
private void getGroupInfo(MethodCall call, final Result result) {
HashMap<String, Object> map = call.arguments();
long groupId;
try {
JSONObject params = new JSONObject(map);
groupId = Long.parseLong(params.getString("id"));
} catch (JSONException e) {
e.printStackTrace();
handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, result);
return;
}
JMessageClient.getGroupInfo(groupId, new GetGroupInfoCallback() {
@Override
public void gotResult(int status, String desc, GroupInfo groupInfo) {
if (status == 0) {
handleResult(toJson(groupInfo), status, desc, result);
} else {
handleResult(status, desc, result);
}
}
});
}
示例6
private void isGroupBlocked(MethodCall call, final Result result) {
HashMap<String, Object> map = call.arguments();
long groupId;
try {
JSONObject params = new JSONObject(map);
groupId = Long.parseLong(params.getString("id"));
} catch (JSONException e) {
e.printStackTrace();
handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, result);
return;
}
JMessageClient.getGroupInfo(groupId, new GetGroupInfoCallback() {
@Override
public void gotResult(int status, String desc, GroupInfo groupInfo) {
if (status != 0) {
handleResult(status, desc, result);
return;
}
boolean isBlocked = (groupInfo.isGroupBlocked() == 1);
HashMap res= new HashMap();
res.put("isBlocked", isBlocked);
handleResult(res, status, desc, result);
}
});
}
示例7
private void transferGroupOwner(MethodCall call, final Result result) {
HashMap<String, Object> map = call.arguments();
long groupId;
final String username;
final String appKey;
try {
JSONObject params = new JSONObject(map);
groupId = Long.parseLong(params.getString("groupId"));
username = params.getString("username");
appKey = params.has("appKey") ? params.getString("appKey") : JmessageFlutterPlugin.appKey;
} catch (JSONException e) {
e.printStackTrace();
handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, result);
return;
}
JMessageClient.getGroupInfo(groupId, new GetGroupInfoCallback() {
@Override
public void gotResult(final int status, final String desc, GroupInfo groupInfo) {
if (status == 0) {
groupInfo.changeGroupAdmin(username, appKey, new BasicCallback() {
@Override
public void gotResult(int i, String s) {
handleResult(status, desc, result);
}
});
} else {
handleResult(status, desc, result);
}
}
});
}
示例8
private void setGroupMemberSilence(MethodCall call, final Result result) {
HashMap<String, Object> map = call.arguments();
long groupId;
final String username;
final String appKey;
final Boolean isSilence;
try {
JSONObject params = new JSONObject(map);
groupId = Long.parseLong(params.getString("groupId"));
username = params.getString("username");
appKey = params.has("appKey") ? params.getString("appKey") : JmessageFlutterPlugin.appKey;
isSilence = params.getBoolean("isSilence");
} catch (JSONException e) {
e.printStackTrace();
handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, result);
return;
}
JMessageClient.getGroupInfo(groupId, new GetGroupInfoCallback() {
@Override
public void gotResult(final int status, final String desc, GroupInfo groupInfo) {
if (status == 0) {
groupInfo.setGroupMemSilence(username, appKey, isSilence, new BasicCallback() {
@Override
public void gotResult(int i, String s) {
handleResult(i, s, result);
}
});
} else {
handleResult(status, desc, result);
}
}
});
}
示例9
private void isSilenceMember(MethodCall call, final Result result) {
HashMap<String, Object> map = call.arguments();
long groupId;
final String username;
final String appKey;
try {
JSONObject params = new JSONObject(map);
groupId = Long.parseLong(params.getString("groupId"));
username = params.getString("username");
appKey = params.has("appKey") ? params.getString("appKey") : JmessageFlutterPlugin.appKey;
} catch (JSONException e) {
e.printStackTrace();
handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, result);
return;
}
JMessageClient.getGroupInfo(groupId, new GetGroupInfoCallback() {
@Override
public void gotResult(int status, String desc, GroupInfo groupInfo) {
if (status == 0) {
boolean isSilence = groupInfo.isKeepSilence(username, appKey);
HashMap res= new HashMap();
res.put("isSilence", isSilence);
handleResult(res, status, desc, result);
} else {
handleResult(status, desc, result);
}
}
});
}
示例10
public void setGroupAvatarChangeListener(final Activity context, final long groupId) {
photoUtils = new PhotoUtils(new PhotoUtils.OnPhotoResultListener() {
@Override
public void onPhotoResult(final Uri uri) {
jiguang.chat.utils.dialog.LoadDialog.show(context);
JMessageClient.getGroupInfo(groupId, new GetGroupInfoCallback() {
@Override
public void gotResult(int i, String s, GroupInfo groupInfo) {
if (i == 0) {
groupInfo.updateAvatar(new File(uri.getPath()), "", new BasicCallback() {
@Override
public void gotResult(int i, String s) {
jiguang.chat.utils.dialog.LoadDialog.dismiss(context);
if (i == 0) {
Intent intent = new Intent();
intent.putExtra("groupAvatarPath", uri.getPath());
context.setResult(Activity.RESULT_OK, intent);
ToastUtil.shortToast(context, "更新成功");
context.finish();
} else {
ToastUtil.shortToast(context, "更新失败");
context.finish();
}
}
});
} else {
HandleResponseCode.onHandle(context, i, false);
}
}
});
}
@Override
public void onPhotoCancel() {
}
});
}
示例11
private void initData() {
final Dialog dialog = DialogCreator.createLoadingDialog(this, this.getString(R.string.jmui_loading));
dialog.show();
final List<GroupInfo> infoList = new ArrayList<>();
JMessageClient.getGroupIDList(new GetGroupIDListCallback() {
@Override
public void gotResult(int responseCode, String responseMessage, final List<Long> groupIDList) {
if (responseCode == 0) {
final int[] groupSize = {groupIDList.size()};
if (groupIDList.size() > 0) {
for (Long id : groupIDList) {
JMessageClient.getGroupInfo(id, new GetGroupInfoCallback() {
@Override
public void gotResult(int i, String s, GroupInfo groupInfo) {
if (i == 0) {
groupSize[0] = groupSize[0] - 1;
infoList.add(groupInfo);
if (groupSize[0] == 0) {
setAdapter(infoList, dialog);
}
}
}
});
}
} else {
dialog.dismiss();
ToastUtil.shortToast(GroupActivity.this, "您还没有群组");
}
} else {
dialog.dismiss();
HandleResponseCode.onHandle(mContext, responseCode, false);
}
}
});
}