Search in sources :

Example 1 with RequestGetMentionList

use of com.fanap.podchat.chat.mention.model.RequestGetMentionList in project pod-chat-android-sdk by FanapSoft.

the class MentionCacheTest method populateMentionListFromServer.

public void populateMentionListFromServer(long threadId) {
    chatListeners = new ChatListener() {

        @Override
        public void onGetMentionList(ChatResponse<ResultHistory> response) {
            if (!response.isCache()) {
                System.out.println("Received Mention Message List Server: " + response.getJson());
                threadMentionMessagesListInServer.addAll(response.getResult().getHistory().stream().filter(messageVO -> messageVO.getMessage() != null).collect(Collectors.toList()));
                chat.removeListener(chatListeners);
                resumeProcess();
            }
        }
    };
    chat.setListener(chatListeners);
    RequestGetMentionList req = new RequestGetMentionList.Builder(threadId).offset(0).count(25).build();
    presenter.getMentionList(req);
    pauseProcess();
    System.out.println("Received Mention Message List Server: " + threadMentionMessagesListInServer.size());
}
Also used : ResultThreads(com.fanap.podchat.model.ResultThreads) Context(android.content.Context) RequestConnect(com.fanap.podchat.requestobject.RequestConnect) BeforeClass(org.junit.BeforeClass) Mock(org.mockito.Mock) Thread(com.fanap.podchat.mainmodel.Thread) RunWith(org.junit.runner.RunWith) ChatPresenter(com.example.chat.application.chatexample.ChatPresenter) ChatContract(com.example.chat.application.chatexample.ChatContract) ChatResponse(com.fanap.podchat.model.ChatResponse) ArrayList(java.util.ArrayList) R(com.fanap.podchat.example.R) ResultHistory(com.fanap.podchat.model.ResultHistory) Looper(android.os.Looper) BaseApplication(com.example.chat.application.chatexample.BaseApplication) ChatActivity(com.example.chat.application.chatexample.ChatActivity) RequestThread(com.fanap.podchat.requestobject.RequestThread) Before(org.junit.Before) CHAT_READY(com.fanap.podchat.util.ChatStateType.ChatSateConstant.CHAT_READY) ActivityTestRule(android.support.test.rule.ActivityTestRule) Test(org.junit.Test) InstrumentationRegistry(android.support.test.InstrumentationRegistry) AndroidJUnit4(android.support.test.runner.AndroidJUnit4) ChatListener(com.fanap.podchat.chat.ChatListener) RequestGetMentionList(com.fanap.podchat.chat.mention.model.RequestGetMentionList) MessageVO(com.fanap.podchat.mainmodel.MessageVO) Collectors(java.util.stream.Collectors) Mockito(org.mockito.Mockito) APP_ID(com.example.chat.application.chatexample.ChatActivity.APP_ID) Rule(org.junit.Rule) Assert(org.junit.Assert) Activity(android.app.Activity) Chat(com.fanap.podchat.chat.Chat) RequestGetMentionList(com.fanap.podchat.chat.mention.model.RequestGetMentionList) ChatListener(com.fanap.podchat.chat.ChatListener) ResultHistory(com.fanap.podchat.model.ResultHistory)

Example 2 with RequestGetMentionList

use of com.fanap.podchat.chat.mention.model.RequestGetMentionList in project pod-chat-android-sdk by FanapSoft.

the class ChatActivity method getMentionList.

private void getMentionList() {
    RequestGetMentionList req = new RequestGetMentionList.Builder(TEST_THREAD_ID).offset(0).count(25).build();
    presenter.getMentionList(req);
}
Also used : RequestGetMentionList(com.fanap.podchat.chat.mention.model.RequestGetMentionList)

Example 3 with RequestGetMentionList

use of com.fanap.podchat.chat.mention.model.RequestGetMentionList in project pod-chat-android-sdk by FanapSoft.

the class MentionCacheTest method populateMentionListFromCache.

public void populateMentionListFromCache(long threadId) {
    chatListeners = new ChatListener() {

        @Override
        public void onGetMentionList(ChatResponse<ResultHistory> response) {
            if (response.isCache()) {
                System.out.println("Received Mention Message List Server: " + response.getJson());
                threadMentionMessagesListInCache.addAll(response.getResult().getHistory().stream().filter(messageVO -> messageVO.getMessage() != null).collect(Collectors.toList()));
                chat.removeListener(chatListeners);
                resumeProcess();
            } else {
                Assert.assertEquals(5, 10);
                resumeProcess();
            }
        }
    };
    chat.setListener(chatListeners);
    RequestGetMentionList req = new RequestGetMentionList.Builder(threadId).offset(0).count(25).build();
    presenter.getMentionList(req);
    pauseProcess();
    System.out.println("Received Mention Message List Server: " + threadMentionMessagesListInCache.size());
}
Also used : ResultThreads(com.fanap.podchat.model.ResultThreads) Context(android.content.Context) RequestConnect(com.fanap.podchat.requestobject.RequestConnect) BeforeClass(org.junit.BeforeClass) Mock(org.mockito.Mock) Thread(com.fanap.podchat.mainmodel.Thread) RunWith(org.junit.runner.RunWith) ChatPresenter(com.example.chat.application.chatexample.ChatPresenter) ChatContract(com.example.chat.application.chatexample.ChatContract) ChatResponse(com.fanap.podchat.model.ChatResponse) ArrayList(java.util.ArrayList) R(com.fanap.podchat.example.R) ResultHistory(com.fanap.podchat.model.ResultHistory) Looper(android.os.Looper) BaseApplication(com.example.chat.application.chatexample.BaseApplication) ChatActivity(com.example.chat.application.chatexample.ChatActivity) RequestThread(com.fanap.podchat.requestobject.RequestThread) Before(org.junit.Before) CHAT_READY(com.fanap.podchat.util.ChatStateType.ChatSateConstant.CHAT_READY) ActivityTestRule(android.support.test.rule.ActivityTestRule) Test(org.junit.Test) InstrumentationRegistry(android.support.test.InstrumentationRegistry) AndroidJUnit4(android.support.test.runner.AndroidJUnit4) ChatListener(com.fanap.podchat.chat.ChatListener) RequestGetMentionList(com.fanap.podchat.chat.mention.model.RequestGetMentionList) MessageVO(com.fanap.podchat.mainmodel.MessageVO) Collectors(java.util.stream.Collectors) Mockito(org.mockito.Mockito) APP_ID(com.example.chat.application.chatexample.ChatActivity.APP_ID) Rule(org.junit.Rule) Assert(org.junit.Assert) Activity(android.app.Activity) Chat(com.fanap.podchat.chat.Chat) RequestGetMentionList(com.fanap.podchat.chat.mention.model.RequestGetMentionList) ChatListener(com.fanap.podchat.chat.ChatListener) ResultHistory(com.fanap.podchat.model.ResultHistory)

Aggregations

RequestGetMentionList (com.fanap.podchat.chat.mention.model.RequestGetMentionList)3 Activity (android.app.Activity)2 Context (android.content.Context)2 Looper (android.os.Looper)2 InstrumentationRegistry (android.support.test.InstrumentationRegistry)2 ActivityTestRule (android.support.test.rule.ActivityTestRule)2 AndroidJUnit4 (android.support.test.runner.AndroidJUnit4)2 BaseApplication (com.example.chat.application.chatexample.BaseApplication)2 ChatActivity (com.example.chat.application.chatexample.ChatActivity)2 APP_ID (com.example.chat.application.chatexample.ChatActivity.APP_ID)2 ChatContract (com.example.chat.application.chatexample.ChatContract)2 ChatPresenter (com.example.chat.application.chatexample.ChatPresenter)2 Chat (com.fanap.podchat.chat.Chat)2 ChatListener (com.fanap.podchat.chat.ChatListener)2 R (com.fanap.podchat.example.R)2 MessageVO (com.fanap.podchat.mainmodel.MessageVO)2 Thread (com.fanap.podchat.mainmodel.Thread)2 ChatResponse (com.fanap.podchat.model.ChatResponse)2 ResultHistory (com.fanap.podchat.model.ResultHistory)2 ResultThreads (com.fanap.podchat.model.ResultThreads)2