如何在会话列表过滤会话?

IMKit SDK 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 SDK 5.X

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

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