Search in sources :

Example 6 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.nonsupport_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)

Example 7 with AVIMTextMessage

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

the class ChatActivity method onEvent.

@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(ImTypeMessageEvent event) {
    if (null != imConversation && null != event && imConversation.getConversationId().equals(event.conversation.getConversationId())) {
        if (event.message instanceof AVIMTextMessage) {
            String msg = ((AVIMTextMessage) event.message).getText();
            ChatMessage chatMessage = new ChatMessage(0, R.mipmap.me, menberId, msg, null);
            adapter.addMessage(chatMessage);
            adapter.notifyDataSetChanged();
            chatlist.smoothScrollToPosition(adapter.getCount() - 1);
        }
    }
}
Also used : ChatMessage(com.rideread.rideread.bean.ChatMessage) AVIMTextMessage(com.avos.avoscloud.im.v2.messages.AVIMTextMessage) Subscribe(org.greenrobot.eventbus.Subscribe)

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