mirror of
https://github.com/WuKongIM/WuKongIMAndroidSDK
synced 2025-06-02 23:39:05 +00:00
add message sync completed
This commit is contained in:
parent
9d07754e5f
commit
a735d9d916
@ -23,6 +23,7 @@ import com.xinbida.wukongim.entity.WKMsgReaction;
|
||||
import com.xinbida.wukongim.entity.WKMsgSetting;
|
||||
import com.xinbida.wukongim.interfaces.IGetOrSyncHistoryMsgBack;
|
||||
import com.xinbida.wukongim.manager.MsgManager;
|
||||
import com.xinbida.wukongim.message.WKRead;
|
||||
import com.xinbida.wukongim.message.type.WKSendMsgResult;
|
||||
import com.xinbida.wukongim.msgmodel.WKMessageContent;
|
||||
import com.xinbida.wukongim.utils.WKTypeUtils;
|
||||
@ -844,6 +845,27 @@ public class MsgDbManager {
|
||||
|
||||
}
|
||||
|
||||
public synchronized boolean deleteWithMessageIDs(List<String> messageIDs) {
|
||||
String[] updateKey = new String[1];
|
||||
String[] updateValue = new String[1];
|
||||
updateKey[0] = WKDBColumns.WKMessageColumns.is_deleted;
|
||||
updateValue[0] = "1";
|
||||
String where = WKDBColumns.WKMessageColumns.message_id + "in (" + WKCursor.getPlaceholders(messageIDs.size()) + ")";
|
||||
String[] whereValue = messageIDs.toArray(new String[0]);
|
||||
int row = WKIMApplication.getInstance().getDbHelper()
|
||||
.update(message, updateKey, updateValue, where, whereValue);
|
||||
// if (row > 0) {
|
||||
// List<WKMsg> msgList = queryWithMsgIds(messageIDs);
|
||||
// if (msgList.size() > 0) {
|
||||
// for (WKMsg msg : msgList) {
|
||||
// WKIM.getInstance().getMsgManager().setDeleteMsg(msg);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
return row > 0;
|
||||
|
||||
}
|
||||
|
||||
private List<WKMsgExtra> queryMsgExtrasWithMsgIds(List<String> msgIds) {
|
||||
List<WKMsgExtra> list = new ArrayList<>();
|
||||
try (Cursor cursor = WKIMApplication.getInstance().getDbHelper().select(messageExtra, "message_id in (" + WKCursor.getPlaceholders(msgIds.size()) + ")", msgIds.toArray(new String[0]), null)) {
|
||||
|
@ -21,6 +21,7 @@ import com.xinbida.wukongim.interfaces.IDeleteConversationMsg;
|
||||
import com.xinbida.wukongim.interfaces.IRefreshConversationMsg;
|
||||
import com.xinbida.wukongim.interfaces.ISyncConversationChat;
|
||||
import com.xinbida.wukongim.interfaces.ISyncConversationChatBack;
|
||||
import com.xinbida.wukongim.message.type.WKConnectStatus;
|
||||
import com.xinbida.wukongim.utils.WKLoggerUtils;
|
||||
|
||||
import org.json.JSONException;
|
||||
@ -350,18 +351,18 @@ public class ConversationManager extends BaseManager {
|
||||
allMsgMap.put(wkMsg.channelID, list);
|
||||
}
|
||||
|
||||
for (Map.Entry<String, List<WKMsg>> entry : allMsgMap.entrySet()) {
|
||||
List<WKMsg> channelMsgList = entry.getValue();
|
||||
if (channelMsgList != null && channelMsgList.size() < 20) {
|
||||
Collections.sort(channelMsgList, new Comparator<WKMsg>() {
|
||||
@Override
|
||||
public int compare(WKMsg o1, WKMsg o2) {
|
||||
return Long.compare(o1.messageSeq, o2.messageSeq);
|
||||
}
|
||||
});
|
||||
MsgManager.getInstance().pushNewMsg(channelMsgList);
|
||||
}
|
||||
}
|
||||
// for (Map.Entry<String, List<WKMsg>> entry : allMsgMap.entrySet()) {
|
||||
// List<WKMsg> channelMsgList = entry.getValue();
|
||||
// if (channelMsgList != null && channelMsgList.size() < 20) {
|
||||
// Collections.sort(channelMsgList, new Comparator<WKMsg>() {
|
||||
// @Override
|
||||
// public int compare(WKMsg o1, WKMsg o2) {
|
||||
// return Long.compare(o1.messageSeq, o2.messageSeq);
|
||||
// }
|
||||
// });
|
||||
// MsgManager.getInstance().pushNewMsg(channelMsgList);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
@ -385,6 +386,7 @@ public class ConversationManager extends BaseManager {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
WKIM.getInstance().getConnectionManager().setConnectionStatus(WKConnectStatus.syncCompleted, "");
|
||||
iSaveSyncChatBack.onBack();
|
||||
}
|
||||
}
|
||||
|
@ -308,7 +308,7 @@ public class MsgManager extends BaseManager {
|
||||
// 显示最后一页数据
|
||||
// oldestOrderSeq = 0;
|
||||
tempOldestOrderSeq = getMessageOrderSeq(maxMsgSeq, channelId, channelType);
|
||||
if (tempOldestOrderSeq < aroundMsgOrderSeq){
|
||||
if (tempOldestOrderSeq < aroundMsgOrderSeq) {
|
||||
tempOldestOrderSeq = aroundMsgOrderSeq;
|
||||
}
|
||||
tempContain = true;
|
||||
@ -789,6 +789,7 @@ public class MsgManager extends BaseManager {
|
||||
if (list == null || list.size() == 0) return;
|
||||
List<WKMsgExtra> extraList = new ArrayList<>();
|
||||
List<String> messageIds = new ArrayList<>();
|
||||
List<String> deleteMsgIds = new ArrayList<>();
|
||||
for (int i = 0, size = list.size(); i < size; i++) {
|
||||
if (TextUtils.isEmpty(list.get(i).message_id)) {
|
||||
continue;
|
||||
@ -796,8 +797,14 @@ public class MsgManager extends BaseManager {
|
||||
WKMsgExtra extra = WKSyncExtraMsg2WKMsgExtra(channel.channelID, channel.channelType, list.get(i));
|
||||
extraList.add(extra);
|
||||
messageIds.add(list.get(i).message_id);
|
||||
if (extra.isMutualDeleted == 1) {
|
||||
deleteMsgIds.add(list.get(i).message_id);
|
||||
}
|
||||
}
|
||||
List<WKMsg> updatedMsgList = MsgDbManager.getInstance().insertOrUpdateMsgExtras(extraList);
|
||||
if (deleteMsgIds.size() > 0) {
|
||||
MsgDbManager.getInstance().deleteWithMessageIDs(deleteMsgIds);
|
||||
}
|
||||
getMsgReactionsAndRefreshMsg(messageIds, updatedMsgList);
|
||||
}
|
||||
|
||||
|
@ -17,4 +17,6 @@ public class WKConnectStatus {
|
||||
public static final int connecting = 4;
|
||||
//无网络
|
||||
public static final int noNetwork = 5;
|
||||
// 同步完成
|
||||
public static final int syncCompleted = 6;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user