protected void onConversationInit() { conversation = EMClient.getInstance() .chatManager() .getConversation(toChatUsername, EaseCommonUtils.getConversationType(chatType), true); conversation.markAllMessagesAsRead(); // the number of messages loaded into conversation is getChatOptions().getNumberOfMessagesLoaded // you can change this number final List<EMMessage> msgs = conversation.getAllMessages(); int msgCount = msgs != null ? msgs.size() : 0; if (msgCount < conversation.getAllMsgCount() && msgCount < pagesize) { String msgId = null; if (msgs != null && msgs.size() > 0) { msgId = msgs.get(0).getMsgId(); } conversation.loadMoreMsgFromDB(msgId, pagesize - msgCount); } }
protected void onConversationInit() { // 获取当前conversation对象 conversation = EMClient.getInstance() .chatManager() .getConversation(toChatUsername, EaseCommonUtils.getConversationType(chatType), true); // 把此会话的未读数置为0 conversation.markAllMessagesAsRead(); // 初始化db时,每个conversation加载数目是getChatOptions().getNumberOfMessagesLoaded // 这个数目如果比用户期望进入会话界面时显示的个数不一样,就多加载一些 final List<EMMessage> msgs = conversation.getAllMessages(); int msgCount = msgs != null ? msgs.size() : 0; if (msgCount < conversation.getAllMsgCount() && msgCount < pagesize) { String msgId = null; if (msgs != null && msgs.size() > 0) { msgId = msgs.get(0).getMsgId(); } conversation.loadMoreMsgFromDB(msgId, pagesize - msgCount); } }
/** 加载所有新消息并且显示数据 建议在子线程中加载 */ public void loadAllNewAndShowData() { mConversation.markAllMessagesAsRead(); refreshOnUIThread(); }