Search in sources :

Example 1 with UserBaseInfo

use of com.rideread.rideread.data.result.UserBaseInfo 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);
        }
    });
}
Also used : UserUtils(com.rideread.rideread.common.util.UserUtils) Arrays(java.util.Arrays) TitleBuilder(com.rideread.rideread.common.util.TitleBuilder) HashMap(java.util.HashMap) R(com.rideread.rideread.R) OnClick(butterknife.OnClick) BindView(butterknife.BindView) AVIMConversationCreatedCallback(com.avos.avoscloud.im.v2.callback.AVIMConversationCreatedCallback) UserBaseInfo(com.rideread.rideread.data.result.UserBaseInfo) AVIMMessage(com.avos.avoscloud.im.v2.AVIMMessage) AVIMConversationCallback(com.avos.avoscloud.im.v2.callback.AVIMConversationCallback) AVIMConversation(com.avos.avoscloud.im.v2.AVIMConversation) AVImClientManager(com.rideread.rideread.function.net.im.AVImClientManager) View(android.view.View) AVIMClient(com.avos.avoscloud.im.v2.AVIMClient) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) AVIMMessagesQueryCallback(com.avos.avoscloud.im.v2.callback.AVIMMessagesQueryCallback) AVIMTextMessage(com.avos.avoscloud.im.v2.messages.AVIMTextMessage) ChatMsgAdapter(com.rideread.rideread.common.adapter.ChatMsgAdapter) AVIMConversationQuery(com.avos.avoscloud.im.v2.AVIMConversationQuery) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) TextUtils(android.text.TextUtils) BaseActivity(com.rideread.rideread.common.base.BaseActivity) NotificationUtils(com.rideread.rideread.function.net.im.NotificationUtils) AVIMException(com.avos.avoscloud.im.v2.AVIMException) RecyclerView(android.support.v7.widget.RecyclerView) ImTypeMsgEvent(com.rideread.rideread.common.event.ImTypeMsgEvent) List(java.util.List) Subscribe(org.greenrobot.eventbus.Subscribe) MAIN(org.greenrobot.eventbus.ThreadMode.MAIN) AVIMConversationQueryCallback(com.avos.avoscloud.im.v2.callback.AVIMConversationQueryCallback) ImTypeMsgResendEvent(com.rideread.rideread.common.event.ImTypeMsgResendEvent) MsgUtils(com.rideread.rideread.common.util.MsgUtils) EditText(android.widget.EditText) AVIMMessagesQueryCallback(com.avos.avoscloud.im.v2.callback.AVIMMessagesQueryCallback) AVIMMessage(com.avos.avoscloud.im.v2.AVIMMessage) TitleBuilder(com.rideread.rideread.common.util.TitleBuilder) AVIMException(com.avos.avoscloud.im.v2.AVIMException) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ChatMsgAdapter(com.rideread.rideread.common.adapter.ChatMsgAdapter)

Aggregations

SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 TextUtils (android.text.TextUtils)1 View (android.view.View)1 EditText (android.widget.EditText)1 BindView (butterknife.BindView)1 OnClick (butterknife.OnClick)1 AVIMClient (com.avos.avoscloud.im.v2.AVIMClient)1 AVIMConversation (com.avos.avoscloud.im.v2.AVIMConversation)1 AVIMConversationQuery (com.avos.avoscloud.im.v2.AVIMConversationQuery)1 AVIMException (com.avos.avoscloud.im.v2.AVIMException)1 AVIMMessage (com.avos.avoscloud.im.v2.AVIMMessage)1 AVIMConversationCallback (com.avos.avoscloud.im.v2.callback.AVIMConversationCallback)1 AVIMConversationCreatedCallback (com.avos.avoscloud.im.v2.callback.AVIMConversationCreatedCallback)1 AVIMConversationQueryCallback (com.avos.avoscloud.im.v2.callback.AVIMConversationQueryCallback)1 AVIMMessagesQueryCallback (com.avos.avoscloud.im.v2.callback.AVIMMessagesQueryCallback)1 AVIMTextMessage (com.avos.avoscloud.im.v2.messages.AVIMTextMessage)1 R (com.rideread.rideread.R)1 ChatMsgAdapter (com.rideread.rideread.common.adapter.ChatMsgAdapter)1