Search in sources :

Example 96 with ChatListener

use of com.fanap.podchat.chat.ChatListener in project pod-chat-android-sdk by FanapSoft.

the class TagCacheTest method populateCacheTags.

public void populateCacheTags() {
    chatListeners = new ChatListener() {

        @Override
        public void OnTagList(String content, ChatResponse<TagListResult> response) {
            if (response.isCache()) {
                System.out.println("Received List: " + content);
                cacheTags.addAll(response.getResult().getTags());
                chat.removeListener(chatListeners);
            }
            resumeProcess();
        }
    };
    chat.setListener(chatListeners);
    GetTagListRequest request = new GetTagListRequest.Builder().build();
    chat.getTagList(request);
    pauseProcess();
    System.out.println("Received List: " + cacheTags.size());
}
Also used : GetTagListRequest(com.fanap.podchat.chat.tag.request_model.GetTagListRequest) ChatListener(com.fanap.podchat.chat.ChatListener) TagListResult(com.fanap.podchat.chat.tag.result_model.TagListResult)

Example 97 with ChatListener

use of com.fanap.podchat.chat.ChatListener in project pod-chat-android-sdk by FanapSoft.

the class TagCacheTest method populateServerTags.

public void populateServerTags() {
    chatListeners = new ChatListener() {

        @Override
        public void OnTagList(String content, ChatResponse<TagListResult> response) {
            if (!response.isCache()) {
                System.out.println("Received List: " + content);
                serverTags.addAll(response.getResult().getTags());
                chat.removeListener(chatListeners);
            }
            resumeProcess();
        }
    };
    chat.setListener(chatListeners);
    GetTagListRequest request = new GetTagListRequest.Builder().withNoCache().build();
    chat.getTagList(request);
    pauseProcess();
    System.out.println("Received List: " + serverTags.size());
}
Also used : GetTagListRequest(com.fanap.podchat.chat.tag.request_model.GetTagListRequest) ChatListener(com.fanap.podchat.chat.ChatListener) TagListResult(com.fanap.podchat.chat.tag.result_model.TagListResult)

Example 98 with ChatListener

use of com.fanap.podchat.chat.ChatListener in project pod-chat-android-sdk by FanapSoft.

the class TagCacheTest method deleteTag.

public void deleteTag(long tagId) {
    chatListeners = new ChatListener() {

        @Override
        public void onTagDeleted(String content, ChatResponse<TagResult> response) {
            chat.removeListener(chatListeners);
            resumeProcess();
        }
    };
    chat.setListener(chatListeners);
    DeleteTagRequest request = new DeleteTagRequest.Builder(tagId).build();
    chat.deleteTag(request);
    pauseProcess();
    System.out.println("Tag Deleted: ");
}
Also used : DeleteTagRequest(com.fanap.podchat.chat.tag.request_model.DeleteTagRequest) ChatListener(com.fanap.podchat.chat.ChatListener) TagResult(com.fanap.podchat.chat.tag.result_model.TagResult)

Example 99 with ChatListener

use of com.fanap.podchat.chat.ChatListener in project pod-chat-android-sdk by FanapSoft.

the class TagCacheTest method addNewTag.

public void addNewTag() {
    chatListeners = new ChatListener() {

        @Override
        public void onTagCreated(String content, ChatResponse<TagResult> response) {
            chat.removeListener(chatListeners);
            resumeProcess();
            tagId = response.getResult().getTag().getTagId();
        }
    };
    chat.setListener(chatListeners);
    CreateTagRequest request = new CreateTagRequest.Builder("Tag_" + System.currentTimeMillis() / 1000).build();
    chat.createTag(request);
    pauseProcess();
    System.out.println("New Tag Created: ");
}
Also used : ChatListener(com.fanap.podchat.chat.ChatListener) CreateTagRequest(com.fanap.podchat.chat.tag.request_model.CreateTagRequest) TagResult(com.fanap.podchat.chat.tag.result_model.TagResult)

Example 100 with ChatListener

use of com.fanap.podchat.chat.ChatListener in project pod-chat-android-sdk by FanapSoft.

the class TagCacheTest method addTagParticipant.

public void addTagParticipant(long tagId) {
    chatListeners = new ChatListener() {

        @Override
        public void OnTagParticipantAdded(String content, ChatResponse<TagParticipantResult> response) {
            chat.removeListener(chatListeners);
            resumeProcess();
        }
    };
    chat.setListener(chatListeners);
    List<Long> threadIds = new ArrayList<>();
    threadIds.add(8688l);
    threadIds.add(8730l);
    threadIds.add(8729l);
    AddTagParticipantRequest request = new AddTagParticipantRequest.Builder(tagId, threadIds).build();
    chat.addTagParticipant(request);
    pauseProcess();
    System.out.println("Tag Participant Added: ");
}
Also used : AddTagParticipantRequest(com.fanap.podchat.chat.tag.request_model.AddTagParticipantRequest) ChatListener(com.fanap.podchat.chat.ChatListener) TagParticipantResult(com.fanap.podchat.chat.tag.result_model.TagParticipantResult) ArrayList(java.util.ArrayList)

Aggregations

ChatListener (com.fanap.podchat.chat.ChatListener)134 Test (org.junit.Test)87 RequestThread (com.fanap.podchat.requestobject.RequestThread)80 LargeTest (android.support.test.filters.LargeTest)63 Thread (com.fanap.podchat.mainmodel.Thread)61 ResultHistory (com.fanap.podchat.model.ResultHistory)44 ChatResponse (com.fanap.podchat.model.ChatResponse)40 ResultThreads (com.fanap.podchat.model.ResultThreads)39 RequestMessage (com.fanap.podchat.requestobject.RequestMessage)38 ArrayList (java.util.ArrayList)38 Date (java.util.Date)32 RequestConnect (com.fanap.podchat.requestobject.RequestConnect)31 RequestGetHistory (com.fanap.podchat.requestobject.RequestGetHistory)31 Before (org.junit.Before)31 ChatPresenter (com.example.chat.application.chatexample.ChatPresenter)29 MessageVO (com.fanap.podchat.mainmodel.MessageVO)23 FlakyTest (android.support.test.filters.FlakyTest)21 MediumTest (android.support.test.filters.MediumTest)21 ResultNewMessage (com.fanap.podchat.model.ResultNewMessage)21 Activity (android.app.Activity)18