Search in sources :

Example 26 with RequestGetHistory

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

the class TextMessagesQueueTest method populateMessagesFromServer.

public void populateMessagesFromServer() {
    populateThreadsListFromServerOnly();
    assert threads.size() > 0;
    Thread thread = threads.get(0);
    chatListeners = new ChatListener() {

        @Override
        public void onGetHistory(String content, ChatResponse<ResultHistory> history) {
            if (!history.isCache()) {
                System.out.println("Received Message List Server: " + content);
                threadMessagesList.addAll(history.getResult().getHistory().stream().filter(messageVO -> messageVO.getMessage() != null).collect(Collectors.toList()));
                chat.removeListener(chatListeners);
                resumeProcess();
            }
        }
    };
    chat.addListener(chatListeners);
    RequestGetHistory requestGetHistory = new RequestGetHistory.Builder(thread.getId()).withNoCache().build();
    chat.getHistory(requestGetHistory, null);
    pauseProcess();
}
Also used : ResultThreads(com.fanap.podchat.model.ResultThreads) Context(android.content.Context) ResultNewMessage(com.fanap.podchat.model.ResultNewMessage) RequestConnect(com.fanap.podchat.requestobject.RequestConnect) BeforeClass(org.junit.BeforeClass) SendingQueueCache(com.fanap.podchat.cachemodel.queue.SendingQueueCache) Mock(org.mockito.Mock) Date(java.util.Date) 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) WaitQueueCache(com.fanap.podchat.cachemodel.queue.WaitQueueCache) 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) RequestMessage(com.fanap.podchat.requestobject.RequestMessage) Before(org.junit.Before) RequestGetHistory(com.fanap.podchat.requestobject.RequestGetHistory) 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) 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) List(java.util.List) ErrorOutPut(com.fanap.podchat.model.ErrorOutPut) ResultMessage(com.fanap.podchat.model.ResultMessage) Rule(org.junit.Rule) TextMessageType(com.fanap.podchat.util.TextMessageType) Assert(org.junit.Assert) Activity(android.app.Activity) Chat(com.fanap.podchat.chat.Chat) RequestGetHistory(com.fanap.podchat.requestobject.RequestGetHistory) ChatListener(com.fanap.podchat.chat.ChatListener) ResultHistory(com.fanap.podchat.model.ResultHistory) Thread(com.fanap.podchat.mainmodel.Thread) RequestThread(com.fanap.podchat.requestobject.RequestThread)

Example 27 with RequestGetHistory

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

the class ChatActivity method getThreadHistory.

public void getThreadHistory() {
    if (TEST_THREAD_LAST_SEEN_MESSAGE_TIME > 0) {
        showToast("Get History to time " + TEST_THREAD_LAST_SEEN_MESSAGE_TIME);
        RequestGetHistory request = new RequestGetHistory.Builder(TEST_THREAD_ID).offset(0).count(50).order(// .order("asc")
        "desc").toTime(TEST_THREAD_LAST_SEEN_MESSAGE_TIME).build();
        presenter.getHistory(request, null);
        showToast("Get History from time " + TEST_THREAD_LAST_SEEN_MESSAGE_TIME);
        request = new RequestGetHistory.Builder(TEST_THREAD_ID).offset(0).count(50).order(// .order("asc")
        "asc").fromTime(TEST_THREAD_LAST_SEEN_MESSAGE_TIME).build();
        presenter.getHistory(request, null);
    }
}
Also used : RequestGetHistory(com.fanap.podchat.requestobject.RequestGetHistory) GsonBuilder(com.google.gson.GsonBuilder)

Aggregations

RequestGetHistory (com.fanap.podchat.requestobject.RequestGetHistory)27 ChatListener (com.fanap.podchat.chat.ChatListener)23 Thread (com.fanap.podchat.mainmodel.Thread)18 RequestThread (com.fanap.podchat.requestobject.RequestThread)18 ResultHistory (com.fanap.podchat.model.ResultHistory)15 ChatResponse (com.fanap.podchat.model.ChatResponse)14 Test (org.junit.Test)14 MessageVO (com.fanap.podchat.mainmodel.MessageVO)9 ArrayList (java.util.ArrayList)9 ResultNewMessage (com.fanap.podchat.model.ResultNewMessage)8 RequestMessage (com.fanap.podchat.requestobject.RequestMessage)7 Date (java.util.Date)7 Activity (android.app.Activity)6 Context (android.content.Context)6 Looper (android.os.Looper)6 InstrumentationRegistry (android.support.test.InstrumentationRegistry)6 LargeTest (android.support.test.filters.LargeTest)6 ActivityTestRule (android.support.test.rule.ActivityTestRule)6 AndroidJUnit4 (android.support.test.runner.AndroidJUnit4)6 BaseApplication (com.example.chat.application.chatexample.BaseApplication)6