//未读消息
public class CustomConversationEventHandler extends AVIMConversationEventHandler {
public void onOfflineMessagesUnread(AVIMClient client, AVIMConversation conversation, final int unreadCount) {
log.e("unreadCount>>>>>>>>>>>>>>>>>>>>>:", unreadCount+"//");
//如果有多个 conversation 有未读消息,此函数会执行多次
if (unreadCount > 0) {
// 可以根据 readCount 更新 UI
// 也可以拉取对应的未读消息
conversation.queryMessages(unreadCount, new AVIMMessagesQueryCallback() {
@Override
public void done(List<AVIMMessage> list, AVIMException e) {
if (e == null) {
for (int i = 0; i < list.size(); i++) {
Log.e("list>>>>>>>>>>>>>>>>>>:", list.get(i).getContent()+"//");
}
AVIMMessage message = list.get(list.size()-1);
// 获得对应的未读消息
Intent intent = new Intent();
intent.setAction(Contants.UNREAD_MESSAGE);
intent.putExtra("unreadCount", unreadCount);
Bundle bundle = new Bundle();
bundle.putParcelable("message", (Parcelable)message);
intent.putExtras(bundle);
ctx.sendBroadcast(intent);
}
}
});
}
}
@Override
public void onMemberLeft(AVIMClient client, AVIMConversation conversation, List<String> members,
String kickedBy) {
// 有其他成员离开时,执行此处逻辑
log.e("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
}
@Override
public void onMemberJoined(AVIMClient client, AVIMConversation conversation,
List<String> members, String invitedBy) {
// 手机屏幕上会显示一小段文字:Tom 加入到 551260efe4b01608686c3e0f ;操作者为:Tom
Toast.makeText(AVOSCloud.applicationContext,
members + "加入到" + conversation.getConversationId() + ";操作者为: "
+ invitedBy, Toast.LENGTH_SHORT).show();
log.e("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb","bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
}
@Override
public void onKicked(AVIMClient client, AVIMConversation conversation, String kickedBy) {
// 当前 ClientId(Bob) 被踢出对话,执行此处逻辑
log.e("ccccccccccccccccccccccccccccccccc","ccccccccccccccccccccccccccccccccc");
}
@Override
public void onInvited(AVIMClient client, AVIMConversation conversation, String invitedBy) {
// 当前 ClientId(Bob) 被邀请到对话,执行此处逻辑
log.e("ddddddddddddddddddddddddddddddd","ddddddddddddddddddddddddddddddd");
}
}