use of com.avos.avoscloud.im.v2.callback.AVIMMessagesQueryCallback in project ride-read-android by Ride-Read.
the class ChatSingleActivity method initView.
@Override
public void initView() {
mUser = (UserBaseInfo) getIntent().getSerializableExtra(CHAT_USER);
mUserName = getIntent().getStringExtra(CHAT_USER_NAME);
if (TextUtils.isEmpty(mUserName))
mUserName = "消息";
new TitleBuilder(this).setTitleText(mUserName).IsBack(true).setLeftOnClickListener(v -> finish()).build();
mSwipeRefreshLayout.setEnabled(false);
layoutManager = new LinearLayoutManager(this);
mRecycleView.setLayoutManager(layoutManager);
mMsgAdapter = new ChatMsgAdapter();
mRecycleView.setAdapter(mMsgAdapter);
getConversation(mUser.getUid() + "");
mSwipeRefreshLayout.setOnRefreshListener(() -> {
AVIMMessage message = mMsgAdapter.getFirstMessage();
if (null != mImConversation) {
mImConversation.queryMessages(message.getMessageId(), message.getTimestamp(), 20, new AVIMMessagesQueryCallback() {
@Override
public void done(List<AVIMMessage> list, AVIMException e) {
mSwipeRefreshLayout.setRefreshing(false);
if (filterException(e)) {
if (null != list && list.size() > 0) {
mMsgAdapter.addMessageList(list);
mMsgAdapter.notifyDataSetChanged();
layoutManager.scrollToPositionWithOffset(list.size() - 1, 0);
}
}
}
});
} else {
mSwipeRefreshLayout.setRefreshing(false);
}
});
}
Aggregations