use of com.avos.avoscloud.im.v2.callback.AVIMConversationQueryCallback 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.callback.AVIMConversationQueryCallback 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);
}
});
}
}
}
});
}
Aggregations