Skip to content

Commit

Permalink
Merge pull request #94 from JoshLipan/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
JoshLipan committed Dec 13, 2018
2 parents 941807e + ad4b094 commit 5ab8bac
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 60 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jmessage-phonegap-plugin",
"version": "4.0.0",
"version": "4.0.1",
"description": "JMessage Cordova Plugin.",
"cordova": {
"id": "jmessage-phonegap-plugin",
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="jmessage-phonegap-plugin"
version="4.0.0">
version="4.0.1">

<name>JMessage</name>
<description>集成极光 IM 和推送功能</description>
Expand Down
111 changes: 53 additions & 58 deletions src/android/JMessagePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ public void gotResult(int status, String desc) {

public void userLogin(JSONArray data, final CallbackContext callback) {
String username, password;

try {
JSONObject params = data.getJSONObject(0);
username = params.getString("username");
Expand Down Expand Up @@ -2758,7 +2757,6 @@ public void onEvent(MessageRetractEvent event) throws JSONException {
public void onEvent(CommandNotificationEvent event) throws JSONException {
final JSONObject result = new JSONObject();
result.put("content", event.getMsg());

event.getSenderUserInfo(new GetUserInfoCallback() {
@Override
public void gotResult(int status, String desc, UserInfo userInfo) {
Expand All @@ -2769,37 +2767,37 @@ public void gotResult(int status, String desc, UserInfo userInfo) {
e.printStackTrace();
}
}
}
});
event.getTargetInfo(new CommandNotificationEvent.GetTargetInfoCallback() {
@Override
public void gotResult(int status, String desc, Object obj, CommandNotificationEvent.Type type) {
if (status == 0) {
if (type == CommandNotificationEvent.Type.single) {
try {
UserInfo receiver = (UserInfo) obj;
result.put("receiver", toJson(receiver));
result.put("receiverType", "single");
} catch (JSONException e) {
e.printStackTrace();
}

event.getTargetInfo(new CommandNotificationEvent.GetTargetInfoCallback() {
@Override
public void gotResult(int status, String desc, Object obj, CommandNotificationEvent.Type type) {
if (status == 0) {
if (type == CommandNotificationEvent.Type.single) {
try {
UserInfo receiver = (UserInfo) obj;
result.put("receiver", toJson(receiver));
result.put("receiverType", "single");
} catch (JSONException e) {
e.printStackTrace();
} else {
try {
GroupInfo receiver = (GroupInfo) obj;
result.put("receiver", toJson(receiver));
result.put("receiverType", "group");
} catch (JSONException e) {
e.printStackTrace();
}
}
}
JSONObject eventJson = toJson("receiveTransCommand", result);
eventSuccess(eventJson);

} else {
try {
GroupInfo receiver = (GroupInfo) obj;
result.put("receiver", toJson(receiver));
result.put("receiverType", "group");
} catch (JSONException e) {
e.printStackTrace();
}
}

JSONObject eventJson = toJson("receiveTransCommand", result);
eventSuccess(eventJson);
}
});
}
});

}

/**
Expand Down Expand Up @@ -2845,24 +2843,23 @@ public void gotResult(int status, String desc, UserInfo userInfo) {
e.printStackTrace();
}
}
}
});
event.getApprovalUserInfoList(new GetUserInfoListCallback() {
@Override
public void gotResult(int status, String s, List<UserInfo> list) {
if (status == 0) {
try {
json.put("joinGroupUsers", toJson(list));
} catch (JSONException e) {
e.printStackTrace();
event.getApprovalUserInfoList(new GetUserInfoListCallback() {
@Override
public void gotResult(int status, String s, List<UserInfo> list) {
if (status == 0) {
try {
json.put("joinGroupUsers", toJson(list));
} catch (JSONException e) {
e.printStackTrace();
}
}
JSONObject eventJson = toJson("receiveApplyJoinGroupApproval", json);
eventSuccess(eventJson);
}
}
});
}
});

JSONObject eventJson = toJson("receiveApplyJoinGroupApproval", json);
eventSuccess(eventJson);

}

/**
Expand All @@ -2884,24 +2881,22 @@ public void gotResult(int status, String desc, UserInfo userInfo) {
e.printStackTrace();
}
}
}
});
event.getApprovedUserInfoList(new GetUserInfoListCallback() {
@Override
public void gotResult(int status, String s, List<UserInfo> list) {
if (status == 0) {
try {
json.put("users", toJson(list));
} catch (JSONException e) {
e.printStackTrace();
event.getApprovedUserInfoList(new GetUserInfoListCallback() {
@Override
public void gotResult(int status, String s, List<UserInfo> list) {
if (status == 0) {
try {
json.put("users", toJson(list));
} catch (JSONException e) {
e.printStackTrace();
}
}
JSONObject eventJson = toJson("receiveGroupAdminApproval", json);
eventSuccess(eventJson);
}
}
});
}
});

JSONObject eventJson = toJson("receiveGroupAdminApproval", json);
eventSuccess(eventJson);

}

/**
Expand All @@ -2919,15 +2914,15 @@ public void gotResult(int status, String desc, UserInfo userInfo) {
if (status == 0) {
try {
json.put("groupManager", toJson(userInfo));
JSONObject eventJson = toJson("receiveGroupAdminReject", json);
eventSuccess(eventJson);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
});

JSONObject eventJson = toJson("receiveGroupAdminReject", json);
eventSuccess(eventJson);
}

private void eventSuccess(JSONObject value) {
Expand Down

0 comments on commit 5ab8bac

Please sign in to comment.