use of com.avos.avoscloud.im.v2.AVIMConversation in project ride-read-android by Ride-Read.
the class ChatActivity method getConservation.
public void getConservation(final String menberId) {
final AVIMClient client = AVImClientManager.getInstance().getClient();
AVIMConversationQuery conversationQuery = client.getQuery();
conversationQuery.withMembers(Arrays.asList(menberId), true);
conversationQuery.whereEqualTo("customConversationType", 1);
conversationQuery.findInBackground(new AVIMConversationQueryCallback() {
@Override
public void done(List<AVIMConversation> list, AVIMException e) {
if (filterException(e)) {
//注意:此处仍有漏洞,如果获取了多个 conversation,默认取第一个
if (null != list && list.size() > 0) {
imConversation = list.get(0);
} else {
HashMap<String, Object> attributes = new HashMap<String, Object>();
attributes.put("customConversationType", 1);
client.createConversation(Arrays.asList(menberId), null, attributes, false, new AVIMConversationCreatedCallback() {
@Override
public void done(AVIMConversation avimConversation, AVIMException e) {
imConversation = avimConversation;
}
});
}
}
}
});
}
use of com.avos.avoscloud.im.v2.AVIMConversation in project ride-read-android by Ride-Read.
the class ChatSingleActivity method getConversation.
private void getConversation(final String memberId) {
final AVIMClient client = AVImClientManager.getInstance().getClient();
if (null == client)
return;
AVIMConversationQuery conversationQuery = client.getQuery();
conversationQuery.withMembers(Arrays.asList(memberId), true);
conversationQuery.whereEqualTo("customConversationType", 1);
conversationQuery.findInBackground(new AVIMConversationQueryCallback() {
@Override
public void done(List<AVIMConversation> list, AVIMException e) {
if (filterException(e)) {
//注意:此处仍有漏洞,如果获取了多个 conversation,默认取第一个
if (null != list && list.size() > 0) {
setConversation(list.get(0));
} else {
HashMap<String, Object> attributes = new HashMap<String, Object>();
attributes.put("customConversationType", 1);
client.createConversation(Arrays.asList(memberId), null, attributes, false, new AVIMConversationCreatedCallback() {
@Override
public void done(AVIMConversation avimConversation, AVIMException e) {
setConversation(avimConversation);
}
});
}
}
}
});
}
use of com.avos.avoscloud.im.v2.AVIMConversation 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);
}
use of com.avos.avoscloud.im.v2.AVIMConversation 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);
}
Aggregations