Search in sources :

Example 26 with ResultHistory

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

the class ChatCore method publishChatHistoryServerResult.

private void publishChatHistoryServerResult(Callback callback, ChatMessage chatMessage, List<MessageVO> messageVOS) {
    ResultHistory resultHistory = new ResultHistory();
    if (cache) {
        // 
        // Observable.just(resultHistory)
        // .asObservable()
        // .map(resultHistoryEMP -> {
        // resultHistoryEMP.setSending(dataSource.getAllSendingQueueByThreadId(chatMessage.getSubjectId()));
        // return resultHistoryEMP;
        // })
        // .map(resultHistoryWithSending -> {
        // 
        // resultHistoryWithSending.setUploadingQueue(dataSource.getAllUploadingQueueByThreadId(chatMessage.getSubjectId()));
        // return  resultHistoryWithSending;
        // 
        // })
        // .map(resultHistoryWithUploading -> {
        // 
        // resultHistoryWithUploading.setFailed(dataSource.getAllWaitQueueCacheByThreadId(chatMessage.getSubjectId()));
        // return resultHistoryWithUploading;
        // 
        // });
        // resultHistory.setSending(messageDatabaseHelper.getAllSendingQueueByThreadId(chatMessage.getSubjectId()));
        // resultHistory.setUploadingQueue(messageDatabaseHelper.getAllUploadingQueueByThreadId(chatMessage.getSubjectId()));
        // resultHistory.setFailed(messageDatabaseHelper.getAllWaitQueueCacheByThreadId(chatMessage.getSubjectId()));
        // 
        resultHistory.setSending(dataSource.getAllSendingQueueByThreadId(chatMessage.getSubjectId()));
        resultHistory.setUploadingQueue(dataSource.getAllUploadingQueueByThreadId(chatMessage.getSubjectId()));
        resultHistory.setFailed(dataSource.getAllWaitQueueCacheByThreadId(chatMessage.getSubjectId()));
    }
    ChatResponse<ResultHistory> chatResponse = new ChatResponse<>();
    resultHistory.setNextOffset(callback.getOffset() + messageVOS.size());
    resultHistory.setContentCount(chatMessage.getContentCount());
    resultHistory.setHasNext(messageVOS.size() + callback.getOffset() < chatMessage.getContentCount());
    chatResponse.setSubjectId(chatMessage.getSubjectId());
    resultHistory.setHistory(messageVOS);
    chatResponse.setErrorCode(0);
    chatResponse.setHasError(false);
    chatResponse.setErrorMessage("");
    chatResponse.setResult(resultHistory);
    chatResponse.setUniqueId(chatMessage.getUniqueId());
    String json = gson.toJson(chatResponse);
    if (sentryResponseLog) {
        showLog("RECEIVE_GET_HISTORY", json);
    } else {
        showLog("RECEIVE_GET_HISTORY");
    }
    messageCallbacks.remove(chatMessage.getUniqueId());
    listenerManager.callOnGetThreadHistory(json, chatResponse);
}
Also used : ChatResponse(com.fanap.podchat.model.ChatResponse) ResultHistory(com.fanap.podchat.model.ResultHistory)

Example 27 with ResultHistory

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

the class ChatCore method notifyChatHistoryReceived.

private void notifyChatHistoryReceived(Callback callback, ChatMessage chatMessage, List<MessageVO> messageVOS) {
    ChatResponse<ResultHistory> chr = new ChatResponse<>();
    ResultHistory rh = new ResultHistory();
    rh.setHistory(messageVOS);
    chr.setResult(rh);
    chr.setSubjectId(chatMessage.getSubjectId());
    chr.setUniqueId(chatMessage.getUniqueId());
    Objects.requireNonNull(handlerSend.get(chatMessage.getUniqueId())).onGetHistory(chr, chatMessage, callback);
}
Also used : ChatResponse(com.fanap.podchat.model.ChatResponse) ResultHistory(com.fanap.podchat.model.ResultHistory)

Example 28 with ResultHistory

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

the class Mention method getHashTagListCacheResponse.

public static ChatResponse<ResultHistory> getHashTagListCacheResponse(RequestGetHashTagList request, List<MessageVO> messageVOS, String uniqueId, long contentCount) {
    ResultHistory resultHistory = new ResultHistory();
    resultHistory.setContentCount(contentCount);
    resultHistory.setHistory(messageVOS);
    ChatResponse<ResultHistory> finalResponse = new ChatResponse<>();
    finalResponse.setResult(resultHistory);
    finalResponse.setUniqueId(uniqueId);
    finalResponse.setSubjectId(request.getThreadId());
    finalResponse.setCache(true);
    return finalResponse;
}
Also used : ChatResponse(com.fanap.podchat.model.ChatResponse) ResultHistory(com.fanap.podchat.model.ResultHistory)

Example 29 with ResultHistory

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

the class Mention method getMentionListCacheResponse.

public static ChatResponse<ResultHistory> getMentionListCacheResponse(RequestGetMentionList request, List<MessageVO> messageVOS, String uniqueId, long contentCount) {
    ResultHistory resultHistory = new ResultHistory();
    resultHistory.setContentCount(contentCount);
    resultHistory.setHistory(messageVOS);
    ChatResponse<ResultHistory> finalResponse = new ChatResponse<>();
    finalResponse.setResult(resultHistory);
    finalResponse.setUniqueId(uniqueId);
    finalResponse.setSubjectId(request.getThreadId());
    finalResponse.setCache(true);
    return finalResponse;
}
Also used : ChatResponse(com.fanap.podchat.model.ChatResponse) ResultHistory(com.fanap.podchat.model.ResultHistory)

Example 30 with ResultHistory

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

the class HashTagManager method getMentionListCacheResponse.

public static ChatResponse<ResultHistory> getMentionListCacheResponse(RequestGetMentionList request, List<MessageVO> messageVOS, String uniqueId, long contentCount) {
    ResultHistory resultHistory = new ResultHistory();
    resultHistory.setContentCount(contentCount);
    resultHistory.setHistory(messageVOS);
    ChatResponse<ResultHistory> finalResponse = new ChatResponse<>();
    finalResponse.setResult(resultHistory);
    finalResponse.setUniqueId(uniqueId);
    finalResponse.setSubjectId(request.getThreadId());
    finalResponse.setCache(true);
    return finalResponse;
}
Also used : ChatResponse(com.fanap.podchat.model.ChatResponse) ResultHistory(com.fanap.podchat.model.ResultHistory)

Aggregations

ResultHistory (com.fanap.podchat.model.ResultHistory)47 ChatListener (com.fanap.podchat.chat.ChatListener)36 Thread (com.fanap.podchat.mainmodel.Thread)36 RequestThread (com.fanap.podchat.requestobject.RequestThread)36 Test (org.junit.Test)29 ArrayList (java.util.ArrayList)22 ChatResponse (com.fanap.podchat.model.ChatResponse)21 RequestMessage (com.fanap.podchat.requestobject.RequestMessage)21 Date (java.util.Date)21 MessageVO (com.fanap.podchat.mainmodel.MessageVO)18 LargeTest (android.support.test.filters.LargeTest)17 SearchSystemMetadataRequest (com.fanap.podchat.chat.messge.SearchSystemMetadataRequest)16 NosqlSearchMetadataCriteria (com.fanap.podchat.mainmodel.NosqlSearchMetadataCriteria)16 RequestGetHistory (com.fanap.podchat.requestobject.RequestGetHistory)15 ResultThreads (com.fanap.podchat.model.ResultThreads)11 Activity (android.app.Activity)10 Context (android.content.Context)10 Looper (android.os.Looper)10 InstrumentationRegistry (android.support.test.InstrumentationRegistry)10 ActivityTestRule (android.support.test.rule.ActivityTestRule)10