Search in sources :

Example 1 with AVIMTextMessage

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

the class LeftMsgHolder method bindData.

@Override
public void bindData(Object o) {
    AVIMMessage message = (AVIMMessage) o;
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
    String time = dateFormat.format(message.getTimestamp());
    String content = getContext().getString(R.string.unsupport_message_type);
    if (message instanceof AVIMTextMessage) {
        content = ((AVIMTextMessage) message).getText();
    }
    mTvChatTxtLeft.setText(content);
    mTvChatTime.setText(time);
//        nameView.setText(message.getFrom());
}
Also used : AVIMMessage(com.avos.avoscloud.im.v2.AVIMMessage) AVIMTextMessage(com.avos.avoscloud.im.v2.messages.AVIMTextMessage) SimpleDateFormat(java.text.SimpleDateFormat)

Example 2 with AVIMTextMessage

use of com.avos.avoscloud.im.v2.messages.AVIMTextMessage 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 3 with AVIMTextMessage

use of com.avos.avoscloud.im.v2.messages.AVIMTextMessage 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 4 with AVIMTextMessage

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

the class RightMsgHolder method bindData.

@Override
public void bindData(Object msg) {
    message = (AVIMMessage) msg;
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    String time = dateFormat.format(message.getTimestamp());
    String content = getContext().getString(R.string.unsupport_message_type);
    ;
    if (message instanceof AVIMTextMessage) {
        content = ((AVIMTextMessage) message).getText();
    }
    mTvChatTxtRight.setText(content);
    mTvChatTime.setText(time);
    if (AVIMMessage.AVIMMessageStatus.AVIMMessageStatusFailed == message.getMessageStatus()) {
        mImgChatStatusRight.setVisibility(View.VISIBLE);
        mPbChatProgressbarRight.setVisibility(View.GONE);
        mFlChatStatusRight.setVisibility(View.VISIBLE);
    } else if (AVIMMessage.AVIMMessageStatus.AVIMMessageStatusSending == message.getMessageStatus()) {
        mImgChatStatusRight.setVisibility(View.GONE);
        mPbChatProgressbarRight.setVisibility(View.VISIBLE);
        mFlChatStatusRight.setVisibility(View.VISIBLE);
    } else {
        mFlChatStatusRight.setVisibility(View.GONE);
    }
}
Also used : AVIMTextMessage(com.avos.avoscloud.im.v2.messages.AVIMTextMessage) SimpleDateFormat(java.text.SimpleDateFormat)

Example 5 with AVIMTextMessage

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

the class MessageHandler method sendNotification.

private void sendNotification(AVIMTypedMessage message, AVIMConversation conversation) {
    String notificationContent = message instanceof AVIMTextMessage ? ((AVIMTextMessage) message).getText() : context.getString(R.string.unspport_message_type);
    Intent intent = new Intent(context, NotificationBroadcastReceiver.class);
    intent.putExtra(Constants.CONVERSATION_ID, conversation.getConversationId());
    intent.putExtra(Constants.MEMBER_ID, message.getFrom());
    NotificationUtils.showNotification(context, "", notificationContent, null, intent);
}
Also used : AVIMTextMessage(com.avos.avoscloud.im.v2.messages.AVIMTextMessage) Intent(android.content.Intent)

Aggregations

AVIMTextMessage (com.avos.avoscloud.im.v2.messages.AVIMTextMessage)7 Intent (android.content.Intent)2 AVIMException (com.avos.avoscloud.im.v2.AVIMException)2 AVIMConversationCallback (com.avos.avoscloud.im.v2.callback.AVIMConversationCallback)2 ChatMessage (com.rideread.rideread.bean.ChatMessage)2 SimpleDateFormat (java.text.SimpleDateFormat)2 AVIMMessage (com.avos.avoscloud.im.v2.AVIMMessage)1 Subscribe (org.greenrobot.eventbus.Subscribe)1