Search in sources :

Example 46 with Thread

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

the class ChatCore method handleAddParticipant.

private void handleAddParticipant(ChatMessage chatMessage, String messageUniqueId) {
    Thread thread = gson.fromJson(chatMessage.getContent(), Thread.class);
    if (cache) {
        ThreadVo threadVo = gson.fromJson(chatMessage.getContent(), ThreadVo.class);
        List<CacheParticipant> cacheParticipants = threadVo.getParticipants();
        if (!Util.isNullOrEmpty(cacheParticipants))
            messageDatabaseHelper.saveParticipants(cacheParticipants, thread.getId(), getExpireAmount());
    }
    ChatResponse<ResultAddParticipant> chatResponse = ParticipantsManager.prepareAddParticipantResponse(chatMessage, thread);
    String jsonAddParticipant = gson.toJson(chatResponse);
    if (sentryResponseLog) {
        showLog("RECEIVE_ADD_PARTICIPANT", jsonAddParticipant);
    } else {
        showLog("RECEIVE_ADD_PARTICIPANT");
    }
    messageCallbacks.remove(messageUniqueId);
    listenerManager.callOnThreadAddParticipant(jsonAddParticipant, chatResponse);
}
Also used : ThreadVo(com.fanap.podchat.cachemodel.ThreadVo) ResultAddParticipant(com.fanap.podchat.model.ResultAddParticipant) CacheParticipant(com.fanap.podchat.cachemodel.CacheParticipant) RequestCreateThread(com.fanap.podchat.requestobject.RequestCreateThread) ResultPinThread(com.fanap.podchat.chat.pin.pin_thread.model.ResultPinThread) Thread(com.fanap.podchat.mainmodel.Thread) RequestLeaveThread(com.fanap.podchat.requestobject.RequestLeaveThread) HandlerThread(android.os.HandlerThread) PinThread(com.fanap.podchat.chat.pin.pin_thread.PinThread) ResultLeaveThread(com.fanap.podchat.model.ResultLeaveThread) RequestMuteThread(com.fanap.podchat.requestobject.RequestMuteThread) ResultJoinPublicThread(com.fanap.podchat.chat.thread.public_thread.ResultJoinPublicThread) RequestJoinPublicThread(com.fanap.podchat.chat.thread.public_thread.RequestJoinPublicThread) PublicThread(com.fanap.podchat.chat.thread.public_thread.PublicThread) RequestThread(com.fanap.podchat.requestobject.RequestThread) ResultThread(com.fanap.podchat.model.ResultThread) RequestPinThread(com.fanap.podchat.chat.pin.pin_thread.model.RequestPinThread)

Example 47 with Thread

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

the class ChatCore method handleThreadInfoUpdated.

private void handleThreadInfoUpdated(ChatMessage chatMessage) {
    ResultThread resultThread = new ResultThread();
    Thread thread = gson.fromJson(chatMessage.getContent(), Thread.class);
    resultThread.setThread(thread);
    ChatResponse<ResultThread> chatResponse = new ChatResponse<>();
    chatResponse.setResult(resultThread);
    chatResponse.setUniqueId(chatMessage.getUniqueId());
    if (sentryResponseLog) {
        showLog("THREAD_INFO_UPDATED", chatMessage.getContent());
    } else {
        showLog("THREAD_INFO_UPDATED");
    }
    if (cache) {
        dataSource.saveThreadResultFromServer(resultThread.getThread());
    }
    listenerManager.callOnThreadInfoUpdated(chatMessage.getContent(), chatResponse);
}
Also used : ChatResponse(com.fanap.podchat.model.ChatResponse) ResultThread(com.fanap.podchat.model.ResultThread) RequestCreateThread(com.fanap.podchat.requestobject.RequestCreateThread) ResultPinThread(com.fanap.podchat.chat.pin.pin_thread.model.ResultPinThread) Thread(com.fanap.podchat.mainmodel.Thread) RequestLeaveThread(com.fanap.podchat.requestobject.RequestLeaveThread) HandlerThread(android.os.HandlerThread) PinThread(com.fanap.podchat.chat.pin.pin_thread.PinThread) ResultLeaveThread(com.fanap.podchat.model.ResultLeaveThread) RequestMuteThread(com.fanap.podchat.requestobject.RequestMuteThread) ResultJoinPublicThread(com.fanap.podchat.chat.thread.public_thread.ResultJoinPublicThread) RequestJoinPublicThread(com.fanap.podchat.chat.thread.public_thread.RequestJoinPublicThread) PublicThread(com.fanap.podchat.chat.thread.public_thread.PublicThread) RequestThread(com.fanap.podchat.requestobject.RequestThread) ResultThread(com.fanap.podchat.model.ResultThread) RequestPinThread(com.fanap.podchat.chat.pin.pin_thread.model.RequestPinThread)

Example 48 with Thread

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

the class ChatCore method reformatCreateThread.

private ChatResponse<ResultThread> reformatCreateThread(ChatMessage chatMessage) {
    ChatResponse<ResultThread> chatResponse = new ChatResponse<>();
    chatResponse.setUniqueId(chatMessage.getUniqueId());
    ResultThread resultThread = new ResultThread();
    Thread thread = gson.fromJson(chatMessage.getContent(), Thread.class);
    resultThread.setThread(thread);
    chatResponse.setResult(resultThread);
    resultThread.setThread(thread);
    return chatResponse;
}
Also used : ChatResponse(com.fanap.podchat.model.ChatResponse) ResultThread(com.fanap.podchat.model.ResultThread) RequestCreateThread(com.fanap.podchat.requestobject.RequestCreateThread) ResultPinThread(com.fanap.podchat.chat.pin.pin_thread.model.ResultPinThread) Thread(com.fanap.podchat.mainmodel.Thread) RequestLeaveThread(com.fanap.podchat.requestobject.RequestLeaveThread) HandlerThread(android.os.HandlerThread) PinThread(com.fanap.podchat.chat.pin.pin_thread.PinThread) ResultLeaveThread(com.fanap.podchat.model.ResultLeaveThread) RequestMuteThread(com.fanap.podchat.requestobject.RequestMuteThread) ResultJoinPublicThread(com.fanap.podchat.chat.thread.public_thread.ResultJoinPublicThread) RequestJoinPublicThread(com.fanap.podchat.chat.thread.public_thread.RequestJoinPublicThread) PublicThread(com.fanap.podchat.chat.thread.public_thread.PublicThread) RequestThread(com.fanap.podchat.requestobject.RequestThread) ResultThread(com.fanap.podchat.model.ResultThread) RequestPinThread(com.fanap.podchat.chat.pin.pin_thread.model.RequestPinThread)

Example 49 with Thread

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

the class PublicThread method handleJoinThread.

public static ChatResponse<ResultJoinPublicThread> handleJoinThread(ChatMessage chatMessage) {
    Thread thread = new Thread();
    try {
        thread = App.getGson().fromJson(chatMessage.getContent(), Thread.class);
    } catch (JsonSyntaxException e) {
        e.printStackTrace();
    }
    ResultJoinPublicThread result = new ResultJoinPublicThread();
    result.setThread(thread);
    ChatResponse<ResultJoinPublicThread> response = new ChatResponse<>();
    response.setResult(result);
    return response;
}
Also used : JsonSyntaxException(com.google.gson.JsonSyntaxException) ChatResponse(com.fanap.podchat.model.ChatResponse) Thread(com.fanap.podchat.mainmodel.Thread)

Example 50 with Thread

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

the class AssistantCacheTest method populateParticipantList.

@Test
public void populateParticipantList() {
    populateThreadsListFromServerOnly();
    assert threads.size() > 0;
    Thread thread = getValidGroupThread();
    chatListeners = new ChatListener() {

        @Override
        public void onGetThreadParticipant(String content, ChatResponse<ResultParticipant> response) {
            System.out.println("Received Participant, Cache: " + response.isCache() + " Content: " + content);
            if (response.getResult().getParticipants().size() > 1) {
                threadParticipant.addAll(response.getResult().getParticipants());
                chat.removeListener(chatListeners);
                resumeProcess();
            } else {
                threads.remove(thread);
                Thread t2 = getValidGroupThread();
                print("try again changing thread...");
                RequestThreadParticipant request = new RequestThreadParticipant.Builder().threadId(t2.getId()).build();
                chat.getThreadParticipants(request, null);
            }
        }
    };
    chat.addListener(chatListeners);
    RequestThreadParticipant request = new RequestThreadParticipant.Builder().threadId(thread.getId()).build();
    chat.getThreadParticipants(request, null);
    pauseProcess();
}
Also used : ResultParticipant(com.fanap.podchat.model.ResultParticipant) ChatListener(com.fanap.podchat.chat.ChatListener) Thread(com.fanap.podchat.mainmodel.Thread) RequestThread(com.fanap.podchat.requestobject.RequestThread) RequestThreadParticipant(com.fanap.podchat.requestobject.RequestThreadParticipant) Test(org.junit.Test) LargeTest(android.support.test.filters.LargeTest)

Aggregations

Thread (com.fanap.podchat.mainmodel.Thread)95 RequestThread (com.fanap.podchat.requestobject.RequestThread)79 Test (org.junit.Test)55 ChatListener (com.fanap.podchat.chat.ChatListener)53 ArrayList (java.util.ArrayList)42 ResultHistory (com.fanap.podchat.model.ResultHistory)36 LargeTest (android.support.test.filters.LargeTest)35 RequestMessage (com.fanap.podchat.requestobject.RequestMessage)33 Date (java.util.Date)30 ChatResponse (com.fanap.podchat.model.ChatResponse)22 RequestGetHistory (com.fanap.podchat.requestobject.RequestGetHistory)22 MessageVO (com.fanap.podchat.mainmodel.MessageVO)20 SearchSystemMetadataRequest (com.fanap.podchat.chat.messge.SearchSystemMetadataRequest)16 NosqlSearchMetadataCriteria (com.fanap.podchat.mainmodel.NosqlSearchMetadataCriteria)16 ResultNewMessage (com.fanap.podchat.model.ResultNewMessage)16 ResultThreads (com.fanap.podchat.model.ResultThreads)16 FlakyTest (android.support.test.filters.FlakyTest)14 MediumTest (android.support.test.filters.MediumTest)14 Activity (android.app.Activity)10 Context (android.content.Context)10