Rongyun IM SDK integration --- refresh the session interface and the session list interface

Rongyun IM SDK integration --- refresh the session interface and the session list interface

Recently integrated Rongyun IMkit found that the ConversationListFragment and ConversationFragment provided by Rongyun IMkit did not provide a refresh method.

We have a requirement that after using the extra value of Message to modify the value, but the interface is not refreshed, we need to call the code to refresh ourselves, but Rongyun does not provide a corresponding method to refresh the interface, so we can only look at the code.

To refresh the ListView, you need to get the Adapter, and then use the Adapter to refresh, but we can't get it directly from the ConversationListFragment, so what should I do?

We know that there is a getAdapter method in ListView. Then can we get the ListView control first? The answer is yes. We can get the ListView through the findById method. By searching, we can know that the id of the listView of the Rongyun session list is R.id.rc_list.

So the code is as follows.

ListView mList = (ListView)findViewById(R.id.rc_list);
HeaderViewListAdapter adapter = (HeaderViewListAdapter)mList.getAdapter();
ConversationListAdapter wrappedAdapter = (ConversationListAdapter)adapter.getWrappedAdapter();
if (adapter != null) {
    wrappedAdapter.notifyDataSetChanged();
}

Guess you like

Origin blog.51cto.com/15024061/2561890