From b20105d3b435ef54b54486043a2e18bcf50ce236 Mon Sep 17 00:00:00 2001 From: JoshLi <542938192@qq.com> Date: Wed, 12 Dec 2018 18:33:47 +0800 Subject: [PATCH] Add setGroupNickname API --- src/android/JMessagePlugin.java | 49 ++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/src/android/JMessagePlugin.java b/src/android/JMessagePlugin.java index 1cbcd42..57a3ec7 100644 --- a/src/android/JMessagePlugin.java +++ b/src/android/JMessagePlugin.java @@ -1475,7 +1475,6 @@ public void gotResult(int status, String desc) { }); } - void downloadThumbGroupAvatar(JSONArray data, final CallbackContext callback) { String id; @@ -1495,7 +1494,7 @@ public void gotResult(int status, String desc, GroupInfo groupInfo) { File avatarFile = groupInfo.getAvatarFile(); JSONObject result = new JSONObject(); try { - result.put("id", groupInfo.getGroupID()+""); + result.put("id", groupInfo.getGroupID() + ""); String avatarFilePath = (avatarFile == null ? "" : avatarFile.getAbsolutePath()); result.put("filePath", avatarFilePath); } catch (JSONException e) { @@ -1546,7 +1545,7 @@ public void gotResult(int status, String desc, Bitmap bitmap) { try { JSONObject result = new JSONObject(); - result.put("id", groupInfo.getGroupID()+""); + result.put("id", groupInfo.getGroupID() + ""); result.put("filePath", filePath); callback.success(result); } catch (JSONException e) { @@ -1559,7 +1558,7 @@ public void gotResult(int status, String desc, Bitmap bitmap) { } else { JSONObject result = new JSONObject(); try { - result.put("id", groupInfo.getGroupID()+""); + result.put("id", groupInfo.getGroupID() + ""); result.put("filePath", groupInfo.getBigAvatarFile().getAbsolutePath()); callback.success(result); } catch (JSONException e) { @@ -2353,13 +2352,11 @@ public void gotResult(int status, String desc) { GroupApprovalEvent groupApprovalEvent = groupApprovalEventList.get(i); final int finalI = i; groupApprovalEvent.refuseGroupApproval(groupApprovalEvent.getFromUsername(), - groupApprovalEvent.getfromUserAppKey(), - reason, - new BasicCallback() { + groupApprovalEvent.getfromUserAppKey(), reason, new BasicCallback() { @Override public void gotResult(int status, String desc) { // 统一返回最后一个拒绝结果 - if(finalI == groupApprovalEventList.size()-1){ + if (finalI == groupApprovalEventList.size() - 1) { handleResult(status, desc, callback); } } @@ -2393,6 +2390,40 @@ public void gotResult(int status, String desc) { } + void setGroupNickname(JSONArray data, final CallbackContext callback) { + long groupId; + String username; + String appKey; + String nickName; + try { + JSONObject params = data.getJSONObject(0); + groupId = Long.parseLong(params.getString("groupId")); + username = params.getString("username"); + nickName = params.getString("nickName"); + appKey = params.has("appKey") ? params.getString("appKey") : ""; + } catch (JSONException e) { + e.printStackTrace(); + handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, callback); + return; + } + JMessageClient.getGroupInfo(groupId, new GetGroupInfoCallback() { + @Override + public void gotResult(int status, String desc, GroupInfo groupInfo) { + if (status == 0) { + groupInfo.setMemNickname(username, appKey, nickName, new BasicCallback() { + @Override + public void gotResult(int i, String s) { + handleResult(status, desc, callback); + } + }); + } else { + handleResult(status, desc, callback); + } + } + }); + + } + void transferGroupOwner(JSONArray data, final CallbackContext callback) { long groupId; String username; @@ -2486,7 +2517,6 @@ public void gotResult(int status, String desc, GroupInfo groupInfo) { e.printStackTrace(); } - } else { handleResult(status, desc, callback); } @@ -2520,7 +2550,6 @@ public void gotResult(int status, String desc, GroupInfo groupInfo) { } - // 群组相关 - end // 事件处理 - start