Search in sources :

Example 71 with ChatListener

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

the class AssistantCacheTest method createChat.

@Before
public void createChat() {
    view = Mockito.mock(ChatContract.view.class);
    chatActivity = chatActivityRule.getActivity();
    presenter = new ChatPresenter(appContext, view, chatActivity);
    RequestConnect rc = new RequestConnect.Builder(socketAddress, APP_ID, serverName, TOKEN, ssoHost, platformHost, fileServer, "podSpaceServer").build();
    chatListeners = new ChatListener() {

        @Override
        public void onChatState(String state) {
            if (state.equals(CHAT_READY)) {
                resumeProcess();
            }
        }
    };
    chat.addListener(chatListeners);
    chat.connect(rc);
    chat.isCacheables(CACHE);
    pauseProcess();
}
Also used : ChatPresenter(com.example.chat.application.chatexample.ChatPresenter) RequestConnect(com.fanap.podchat.requestobject.RequestConnect) ChatListener(com.fanap.podchat.chat.ChatListener) Before(org.junit.Before)

Example 72 with ChatListener

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

the class ChatTest method chatListeners.

@Test
public void chatListeners() {
    ChatListener listener1 = new ChatListener() {

        @Override
        public void onSent(String content, ChatResponse<ResultMessage> response) {
        }
    };
    chat.addListener(listener1);
    ChatListener listener2 = new ChatListener() {

        @Override
        public void onSent(String content, ChatResponse<ResultMessage> response) {
        }
    };
    chat.addListener(listener2);
    ChatListener listener3 = new ChatListener() {

        @Override
        public void onSent(String content, ChatResponse<ResultMessage> response) {
        }
    };
    chat.addListener(listener3);
    chat.removeListener(listener2);
    Assert.assertFalse(chat.getListeners().contains(listener2));
}
Also used : ChatResponse(com.fanap.podchat.model.ChatResponse) ChatListener(com.fanap.podchat.chat.ChatListener) FlakyTest(android.support.test.filters.FlakyTest) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test) LargeTest(android.support.test.filters.LargeTest)

Example 73 with ChatListener

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

the class ChatTest method createChat.

@Before
public void createChat() {
    Looper.prepare();
    view = Mockito.mock(ChatContract.view.class);
    chatActivity = chatActivityRule.getActivity();
    presenter = new ChatPresenter(appContext, view, chatActivity);
    RequestConnect rc = new RequestConnect.Builder(socketAddress, APP_ID, serverName, TOKEN, ssoHost, platformHost, fileServer, "podSpaceServer").build();
    chatListeners = new ChatListener() {

        @Override
        public void onChatState(String state) {
            if (state.equals(CHAT_READY)) {
                resumeProcess();
            }
        }
    };
    chat.addListener(chatListeners);
    chat.connect(rc);
    chat.isCacheables(CACHE);
    pauseProcess();
}
Also used : ChatPresenter(com.example.chat.application.chatexample.ChatPresenter) RequestConnect(com.fanap.podchat.requestobject.RequestConnect) ChatListener(com.fanap.podchat.chat.ChatListener) Before(org.junit.Before)

Example 74 with ChatListener

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

the class ChatTestIntegration method getAssistantTest.

@Test
@LargeTest
public void getAssistantTest() {
    long startTime = System.currentTimeMillis();
    ChatListener historyListeners = new ChatListener() {

        @Override
        public void onGetAssistants(ChatResponse<List<AssistantVo>> response) {
            System.out.println("onGetAssistants: " + response);
            Assert.assertTrue(true);
            resumeProcess();
        }
    };
    chat.addListener(historyListeners);
    getAssistants();
}
Also used : AssistantVo(com.fanap.podchat.chat.assistant.model.AssistantVo) ChatResponse(com.fanap.podchat.model.ChatResponse) ChatListener(com.fanap.podchat.chat.ChatListener) FlakyTest(android.support.test.filters.FlakyTest) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test) LargeTest(android.support.test.filters.LargeTest) LargeTest(android.support.test.filters.LargeTest)

Example 75 with ChatListener

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

the class NetworkPingSender method setStateListener.

public void setStateListener(Chat chat) {
    chat.addListener(new ChatListener() {

        @Override
        public void onChatState(String state) {
            Log.d(TAG, "CHAT STATE CHANGED: " + state);
            switch(state) {
                case ChatStateType.ChatSateConstant.CLOSING:
                case ChatStateType.ChatSateConstant.CLOSED:
                    {
                        connected = false;
                        isConnecting = false;
                        break;
                    }
            }
        }
    });
}
Also used : ChatListener(com.fanap.podchat.chat.ChatListener)

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