@Override public void onPeerMessageACK(IMMessage im) { Log.i(TAG, "message ack on main"); int msgLocalID = im.msgLocalID; long uid = im.receiver; if (msgLocalID == 0) { MessageContent c = IMessage.fromRaw(im.plainContent); if (c.getType() == MessageContent.MessageType.MESSAGE_REVOKE) { Revoke r = (Revoke)c; int pos = -1; if (!im.secret) { pos = findConversationPosition(uid, Conversation.CONVERSATION_PEER); } else { pos = findConversationPosition(uid, Conversation.CONVERSATION_PEER_SECRET); } Conversation conversation = conversations.get(pos); if (r.msgid.equals(conversation.message.getUUID())) { conversation.message.setContent(r); updateNotificationDesc(conversation); updateConversationDetail(conversation); } } } }
public void onGroupMessage(IMMessage msg) { Log.i(TAG, "on group message"); IMessage imsg = new IMessage(); imsg.timestamp = msg.timestamp; imsg.msgLocalID = msg.msgLocalID; imsg.sender = msg.sender; imsg.receiver = msg.receiver; imsg.setContent(msg.content); int pos = findConversationPosition(msg.receiver, Conversation.CONVERSATION_GROUP); Conversation conversation = null; if (pos == -1) { conversation = newGroupConversation(msg.receiver); } else { conversation = conversations.get(pos); } conversation.message = imsg; updateConversationDetail(conversation); if (pos == -1) { conversations.add(0, conversation); adapter.notifyDataSetChanged(); } else if (pos > 0) { conversations.remove(pos); conversations.add(0, conversation); adapter.notifyDataSetChanged(); } else { //pos == 0 } } @Override
IMessage imsg = (IMessage) notification.obj; int pos = findConversationPosition(imsg.receiver, Conversation.CONVERSATION_PEER); Conversation conversation = null; if (pos == -1) { int pos = findConversationPosition(imsg.receiver, Conversation.CONVERSATION_GROUP); Conversation conversation = null; if (pos == -1) {
int pos = findConversationPosition(cid, Conversation.CONVERSATION_PEER); Conversation conversation = null; if (pos == -1) {
@Override public void onGroupMessageACK(IMMessage im) { int msgLocalID = im.msgLocalID; long gid = im.receiver; if (msgLocalID == 0) { MessageContent c = IMessage.fromRaw(im.content); if (c.getType() == MessageContent.MessageType.MESSAGE_REVOKE) { Revoke r = (Revoke)c; int pos = -1; pos = findConversationPosition(gid, Conversation.CONVERSATION_GROUP); Conversation conversation = conversations.get(pos); if (r.msgid.equals(conversation.message.getUUID())) { conversation.message.setContent(r); updateNotificationDesc(conversation); updateConversationDetail(conversation); } } } }
@Override public void onGroupNotification(String text) { GroupNotification groupNotification = GroupNotification.newGroupNotification(text); IMessage imsg = new IMessage(); imsg.sender = 0; imsg.receiver = groupNotification.groupID; imsg.timestamp = groupNotification.timestamp; imsg.setContent(groupNotification); int pos = findConversationPosition(groupNotification.groupID, Conversation.CONVERSATION_GROUP); Conversation conv = null; if (pos == -1) { conv = newGroupConversation(groupNotification.groupID); } else { conv = conversations.get(pos); } conv.message = imsg; updateNotificationDesc(conv); updateConversationDetail(conv); if (pos == -1) { conversations.add(0, conv); adapter.notifyDataSetChanged(); } else if (pos > 0) { //swap with 0 conversations.remove(pos); conversations.add(0, conv); adapter.notifyDataSetChanged(); } else { //pos == 0 } }