Search in sources :

Example 1 with AVIMConversationCallback

use of com.avos.avoscloud.im.v2.callback.AVIMConversationCallback in project ride-read-android by Ride-Read.

the class ChatActivity method sendTextMessage.

private void sendTextMessage(String text) {
    final AVIMTextMessage message = new AVIMTextMessage();
    message.setText(text);
    datas.add(new ChatMessage(1, R.mipmap.me, null, text, null));
    adapter.notifyDataSetChanged();
    chatlist.smoothScrollToPosition(adapter.getCount() - 1);
    editor.setText("");
    imConversation.sendMessage(message, new AVIMConversationCallback() {

        @Override
        public void done(AVIMException e) {
            if (filterException(e)) {
                Log.e("信息发送", "信息发送成功");
            } else {
                Log.e("信息发送", "信息发送失败");
            }
        }
    });
}
Also used : AVIMConversationCallback(com.avos.avoscloud.im.v2.callback.AVIMConversationCallback) AVIMException(com.avos.avoscloud.im.v2.AVIMException) ChatMessage(com.rideread.rideread.bean.ChatMessage) AVIMTextMessage(com.avos.avoscloud.im.v2.messages.AVIMTextMessage)

Example 2 with AVIMConversationCallback

use of com.avos.avoscloud.im.v2.callback.AVIMConversationCallback in project ride-read-android by Ride-Read.

the class ChatSingleActivity method sendMsg.

private void sendMsg() {
    String msg = mEdtChatInput.getText().toString();
    AVIMTextMessage message = new AVIMTextMessage();
    if (!TextUtils.isEmpty(msg)) {
        message.setText(msg);
        mMsgAdapter.addMessage(message);
        mMsgAdapter.notifyDataSetChanged();
        scrollToBottom();
        mEdtChatInput.setText("");
        mImConversation.sendMessage(message, new AVIMConversationCallback() {

            @Override
            public void done(AVIMException e) {
                mMsgAdapter.notifyDataSetChanged();
                MsgUtils.addMsgInfo(mUser, msg, System.currentTimeMillis());
            }
        });
    }
}
Also used : AVIMConversationCallback(com.avos.avoscloud.im.v2.callback.AVIMConversationCallback) AVIMException(com.avos.avoscloud.im.v2.AVIMException) AVIMTextMessage(com.avos.avoscloud.im.v2.messages.AVIMTextMessage)

Example 3 with AVIMConversationCallback

use of com.avos.avoscloud.im.v2.callback.AVIMConversationCallback in project ride-read-android by Ride-Read.

the class ChatSingleActivity method onResendMsg.

/**
     * 重新发送已经发送失败的消息
     */
@Subscribe(threadMode = MAIN)
public void onResendMsg(ImTypeMsgResendEvent event) {
    if (null != mImConversation && null != event) {
        if (AVIMMessage.AVIMMessageStatus.AVIMMessageStatusFailed == event.message.getMessageStatus() && mImConversation.getConversationId().equals(event.message.getConversationId())) {
            mImConversation.sendMessage(event.message, new AVIMConversationCallback() {

                @Override
                public void done(AVIMException e) {
                    mMsgAdapter.notifyDataSetChanged();
                }
            });
            mMsgAdapter.notifyDataSetChanged();
        }
    }
}
Also used : AVIMConversationCallback(com.avos.avoscloud.im.v2.callback.AVIMConversationCallback) AVIMException(com.avos.avoscloud.im.v2.AVIMException) Subscribe(org.greenrobot.eventbus.Subscribe)

Aggregations

AVIMException (com.avos.avoscloud.im.v2.AVIMException)3 AVIMConversationCallback (com.avos.avoscloud.im.v2.callback.AVIMConversationCallback)3 AVIMTextMessage (com.avos.avoscloud.im.v2.messages.AVIMTextMessage)2 ChatMessage (com.rideread.rideread.bean.ChatMessage)1 Subscribe (org.greenrobot.eventbus.Subscribe)1