Skip to content

Commit

Permalink
Merge pull request #93 from JoshLipan/dev
Browse files Browse the repository at this point in the history
Add setGroupNickname API
  • Loading branch information
JoshLipan committed Dec 12, 2018
2 parents 82c613a + b20105d commit 941807e
Showing 1 changed file with 39 additions and 10 deletions.
49 changes: 39 additions & 10 deletions src/android/JMessagePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -1475,7 +1475,6 @@ public void gotResult(int status, String desc) {
});
}


void downloadThumbGroupAvatar(JSONArray data, final CallbackContext callback) {
String id;

Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -2486,7 +2517,6 @@ public void gotResult(int status, String desc, GroupInfo groupInfo) {
e.printStackTrace();
}


} else {
handleResult(status, desc, callback);
}
Expand Down Expand Up @@ -2520,7 +2550,6 @@ public void gotResult(int status, String desc, GroupInfo groupInfo) {

}


// 群组相关 - end

// 事件处理 - start
Expand Down

0 comments on commit 941807e

Please sign in to comment.