Android开发融云删除消息列表上的会话
有时需要我们自己调方法删除消息列表上的会话,用普通列表的操作方法是不行的。
类似下面代码是不行的:
mListFragment.getWrappedAdapter().getData().remove(i);
mListFragment.getWrappedAdapter().notifyDataSetChanged();
正确代码如下:
在ConversationListViewModel里面建如下方法:
public void removeItemPrivateApp(String targetId){
if (mDataFilter != null && mUiConversationList != null && mConversationListLiveData != null){
BaseUiConversation oldItem =
findConversationFromList(
Conversation.ConversationType.PRIVATE,
targetId,
mDataFilter.isGathered(
new ConversationIdentifier(Conversation.ConversationType.PRIVATE, targetId)));
if (oldItem != null) {
mUiConversationList.remove(oldItem);
mConversationListLiveData.postValue(mUiConversationList);
}
}
}
调用示例代码:
mListFragment.mConversationListViewModel.removeItemPrivateApp(eventData.getTargetId());
还有问题或者融云im方面有问题,都可以私信我,我每天都看私信的