当前知识库站点已不再维护。请移步新版知识库:https://help.rongcloud.cn/

会话列表过滤会话 (IMKit 4.x/ 5.x)

会话列表过滤指定人的会话
发布时间: 2018-03-15 16:36

回答:

IMKit 4.x:

会话列表如何过滤会话

  1. 继承 ConversationListFragment

  2. 重载 public void onEventMainThread(Message message) 和 public boolean shouldFilterConversation(ConversationType type, String targetId)

  3. 在上面重载的两个方法里面,根据 targteId 过滤会话,参考代码如下

   public void onEventMainThread(Message message) {

        ConversationType conversationType = message.getConversationType();
        String targetId = message.getTargetId();

        if (targetId.equals("你想过滤的targetId")){
            return;
        }else {
            super.onEventMainThread(message);
        }
public boolean shouldFilterConversation(ConversationType type, String targetId) {
    if (targetId.equals("你想过滤的targetId")) return true;
    return false;
}

IMKit 5.x:

设置对应的数据处理器, 在filtered()回调中处理:

https://doc.rongcloud.cn/im/Android/5.X/ui/conversationlist/dataProcessor