Search in sources :

Example 1 with AVIMConversationQueryCallback

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;
                        }
                    });
                }
            }
        }
    });
}
Also used : AVIMConversationCreatedCallback(com.avos.avoscloud.im.v2.callback.AVIMConversationCreatedCallback) AVIMConversation(com.avos.avoscloud.im.v2.AVIMConversation) AVIMClient(com.avos.avoscloud.im.v2.AVIMClient) AVIMException(com.avos.avoscloud.im.v2.AVIMException) HashMap(java.util.HashMap) AVIMConversationQueryCallback(com.avos.avoscloud.im.v2.callback.AVIMConversationQueryCallback) AVIMConversationQuery(com.avos.avoscloud.im.v2.AVIMConversationQuery)

Example 2 with AVIMConversationQueryCallback

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);
                        }
                    });
                }
            }
        }
    });
}
Also used : AVIMConversationCreatedCallback(com.avos.avoscloud.im.v2.callback.AVIMConversationCreatedCallback) AVIMConversation(com.avos.avoscloud.im.v2.AVIMConversation) AVIMClient(com.avos.avoscloud.im.v2.AVIMClient) AVIMException(com.avos.avoscloud.im.v2.AVIMException) HashMap(java.util.HashMap) AVIMConversationQueryCallback(com.avos.avoscloud.im.v2.callback.AVIMConversationQueryCallback) AVIMConversationQuery(com.avos.avoscloud.im.v2.AVIMConversationQuery)

Aggregations

AVIMClient (com.avos.avoscloud.im.v2.AVIMClient)2 AVIMConversation (com.avos.avoscloud.im.v2.AVIMConversation)2 AVIMConversationQuery (com.avos.avoscloud.im.v2.AVIMConversationQuery)2 AVIMException (com.avos.avoscloud.im.v2.AVIMException)2 AVIMConversationCreatedCallback (com.avos.avoscloud.im.v2.callback.AVIMConversationCreatedCallback)2 AVIMConversationQueryCallback (com.avos.avoscloud.im.v2.callback.AVIMConversationQueryCallback)2 HashMap (java.util.HashMap)2