Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
lhw5123 committed May 31, 2017
2 parents f26c1a6 + c5c821a commit 5f7fd1b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# JMessage PhoneGap / Cordova Plugin

[![release](https://img.shields.io/badge/release-2.4.2-blue.svg)](https://github.com/jpush/jmessage-phonegap-plugin/releases)
[![release](https://img.shields.io/badge/release-2.4.3-blue.svg)](https://github.com/jpush/jmessage-phonegap-plugin/releases)
[![platforms](https://img.shields.io/badge/platforms-iOS%7CAndroid-lightgrey.svg)](https://github.com/jpush/jmessage-phonegap-plugin)
[![QQ Group](https://img.shields.io/badge/QQ%20Group-413602425-red.svg)](https://github.com/jpush/jmessage-phonegap-plugin)
[![weibo](https://img.shields.io/badge/weibo-JPush-blue.svg)](http://weibo.com/jpush?refer_flag=1001030101_&is_all=1)
Expand Down
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": "2.4.2",
"version": "2.4.3",
"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="2.4.2">
version="2.4.3">

<name>JMessage</name>
<description>集成极光 IM 和推送功能</description>
Expand Down
13 changes: 11 additions & 2 deletions src/android/JMessagePlugin.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cn.jmessage.phonegap;
package cn.jiguang.cordova.im;

import android.Manifest;
import android.app.Activity;
Expand Down Expand Up @@ -149,9 +149,10 @@ public void onEvent(OfflineMessageEvent event) {
final JSONArray msgJsonArr = new JSONArray();
int lastMediaMsgIndex = -1;

for (int i = 0; i < event.getOfflineMessageList().size(); i++) {
for (int i = event.getOfflineMessageList().size() - 1; i >= 0; i--) {
if (isMediaMessage(event.getOfflineMessageList().get(i))) {
lastMediaMsgIndex = i;
break;
}
}

Expand All @@ -171,6 +172,7 @@ public void onEvent(OfflineMessageEvent event) {
public void onComplete(int status, String desc, File file) {
try {
msgJsonArr.put(getMessageJSONObject(msg));
json.put("messageList", msgJsonArr);
fireEvent("onSyncOfflineMessage", json.toString());
} catch (JSONException e) {
e.printStackTrace();
Expand All @@ -184,6 +186,7 @@ public void onComplete(int status, String desc, File file) {
public void onComplete(int status, String desc, File file) {
try {
msgJsonArr.put(getMessageJSONObject(msg));
json.put("messageList", msgJsonArr);
fireEvent("onSyncOfflineMessage", json.toString());
} catch (JSONException e) {
e.printStackTrace();
Expand All @@ -197,6 +200,7 @@ public void onComplete(int status, String desc, File file) {
public void onComplete(int status, String desc, File file) {
try {
msgJsonArr.put(getMessageJSONObject(msg));
json.put("messageList", msgJsonArr);
fireEvent("onSyncOfflineMessage", json.toString());
} catch (JSONException e) {
e.printStackTrace();
Expand All @@ -207,6 +211,11 @@ public void onComplete(int status, String desc, File file) {
}
}
}

if (lastMediaMsgIndex == -1) {
json.put("messageList", msgJsonArr);
fireEvent("onSyncOfflineMessage", json.toString());
}
} catch (JSONException e) {
e.printStackTrace();
}
Expand Down

0 comments on commit 5f7fd1b

Please sign in to comment.