Search in sources :

Example 6 with RequestThread

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

the class ChatPresenter method getThreads.

@Override
public void getThreads(Integer count, Long offset, ArrayList<Integer> threadIds, String threadName, long creatorCoreUserId, long partnerCoreUserId, long partnerCoreContactId, ChatHandler handler) {
    RequestThread request = new RequestThread.Builder().count(count).offset(offset).threadIds(threadIds).threadName(threadName).creatorCoreUserId(creatorCoreUserId).partnerCoreContactId(partnerCoreContactId).partnerCoreContactId(partnerCoreContactId).build();
    chat.getThreads(request, handler);
}
Also used : RequestThread(com.fanap.podchat.requestobject.RequestThread)

Example 7 with RequestThread

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

the class ChatPresenter method getThreads.

@Override
public void getThreads(Integer count, Long offset, ArrayList<Integer> threadIds, String threadName, boolean isNew, ChatHandler handler) {
    RequestThread request = new RequestThread.Builder().count(count).offset(offset).threadIds(threadIds).threadName(threadName).creatorCoreUserId(0).partnerCoreContactId(0).partnerCoreContactId(0).build();
    chat.getThreads(request, handler);
}
Also used : RequestThread(com.fanap.podchat.requestobject.RequestThread)

Example 8 with RequestThread

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

the class TextMessagesQueueTest method populateThreadsListFromServerOrCache.

// requests for list of threads
public void populateThreadsListFromServerOrCache() {
    chatListeners = new ChatListener() {

        @Override
        public void onGetThread(String content, ChatResponse<ResultThreads> thread) {
            System.out.println("Received List: " + content);
            threads.addAll(thread.getResult().getThreads());
            chat.removeListener(chatListeners);
        }
    };
    chat.addListener(chatListeners);
    RequestThread requestThread = new RequestThread.Builder().count(25).build();
    presenter.getThreads(requestThread, null);
    long t1 = System.currentTimeMillis();
    Mockito.verify(view, Mockito.after(10000).atLeastOnce()).onGetThreadList(Mockito.any(), Mockito.any());
    long t2 = System.currentTimeMillis();
    System.out.println("Received List: " + threads.size() + " after: " + (t2 - t1) + " ms");
}
Also used : ResultThreads(com.fanap.podchat.model.ResultThreads) ChatListener(com.fanap.podchat.chat.ChatListener) RequestThread(com.fanap.podchat.requestobject.RequestThread)

Example 9 with RequestThread

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

the class TextMessagesQueueTest method populateThreadsListFromCacheOnly.

// requests for list of threads from cache
public void populateThreadsListFromCacheOnly() {
    chatListeners = new ChatListener() {

        @Override
        public void onGetThread(String content, ChatResponse<ResultThreads> thread) {
            if (thread.isCache()) {
                System.out.println("Received List: " + content);
                threads.addAll(thread.getResult().getThreads());
                chat.removeListener(chatListeners);
                resumeProcess();
            }
        }
    };
    chat.addListener(chatListeners);
    RequestThread requestThread = new RequestThread.Builder().count(25).build();
    presenter.getThreads(requestThread, null);
    pauseProcess();
    System.out.println("Received List: " + threads.size());
}
Also used : ResultThreads(com.fanap.podchat.model.ResultThreads) ChatListener(com.fanap.podchat.chat.ChatListener) RequestThread(com.fanap.podchat.requestobject.RequestThread)

Example 10 with RequestThread

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

the class ThreadCacheTest method populateThreadsFromCache.

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

        @Override
        public void onGetThread(String content, ChatResponse<ResultThreads> thread) {
            if (thread.isCache()) {
                threadsInCache.addAll(thread.getResult().getThreads());
                chat.removeListener(chatListeners);
            } else
                Assert.assertEquals(0, 1);
            resumeProcess();
        }
    };
    chat.addListener(chatListeners);
    RequestThread requestThread = new RequestThread.Builder().count(25).build();
    presenter.getThreads(requestThread, null);
    long t1 = System.currentTimeMillis();
    pauseProcess();
    long t2 = System.currentTimeMillis();
    System.out.println("Received List: " + threadsInCache.size() + " after: " + (t2 - t1) + " ms");
}
Also used : ResultThreads(com.fanap.podchat.model.ResultThreads) ChatListener(com.fanap.podchat.chat.ChatListener) RequestThread(com.fanap.podchat.requestobject.RequestThread)

Aggregations

RequestThread (com.fanap.podchat.requestobject.RequestThread)28 ChatListener (com.fanap.podchat.chat.ChatListener)24 ResultThreads (com.fanap.podchat.model.ResultThreads)24 Test (org.junit.Test)14 LargeTest (android.support.test.filters.LargeTest)12 FlakyTest (android.support.test.filters.FlakyTest)5 MediumTest (android.support.test.filters.MediumTest)5 Thread (com.fanap.podchat.mainmodel.Thread)5 ArrayList (java.util.ArrayList)5 ResultHistory (com.fanap.podchat.model.ResultHistory)4 Activity (android.app.Activity)3 Context (android.content.Context)3 Looper (android.os.Looper)3 InstrumentationRegistry (android.support.test.InstrumentationRegistry)3 ActivityTestRule (android.support.test.rule.ActivityTestRule)3 AndroidJUnit4 (android.support.test.runner.AndroidJUnit4)3 BaseApplication (com.example.chat.application.chatexample.BaseApplication)3 ChatActivity (com.example.chat.application.chatexample.ChatActivity)3 APP_ID (com.example.chat.application.chatexample.ChatActivity.APP_ID)3 ChatContract (com.example.chat.application.chatexample.ChatContract)3