Search in sources :

Example 6 with ResultParticipant

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

the class ChatCore method handleOutPutDeliveredMessageList.

private void handleOutPutDeliveredMessageList(ChatMessage chatMessage, Callback callback) {
    try {
        ChatResponse<ResultParticipant> chatResponse = new ChatResponse<>();
        chatResponse.setUniqueId(chatMessage.getUniqueId());
        ResultParticipant resultParticipant = new ResultParticipant();
        List<Participant> participants = gson.fromJson(chatMessage.getContent(), new TypeToken<ArrayList<Participant>>() {
        }.getType());
        resultParticipant.setParticipants(participants);
        resultParticipant.setContentCount(chatMessage.getContentCount());
        resultParticipant.setNextOffset(callback.getOffset() + participants.size());
        resultParticipant.setContentCount(chatMessage.getContentCount());
        resultParticipant.setHasNext(participants.size() + callback.getOffset() < chatMessage.getContentCount());
        chatResponse.setResult(resultParticipant);
        String content = gson.toJson(chatResponse);
        if (sentryResponseLog) {
            showLog("RECEIVE_DELIVERED_MESSAGE_LIST", content);
        } else {
            showLog("RECEIVE_DELIVERED_MESSAGE_LIST");
        }
        listenerManager.callOnDeliveredMessageList(content, chatResponse);
    } catch (Exception e) {
        showErrorLog(e.getMessage());
        onUnknownException(chatMessage.getUniqueId(), e);
    }
}
Also used : ResultAddParticipant(com.fanap.podchat.model.ResultAddParticipant) ResultParticipant(com.fanap.podchat.model.ResultParticipant) Participant(com.fanap.podchat.mainmodel.Participant) CacheParticipant(com.fanap.podchat.cachemodel.CacheParticipant) RequestThreadParticipant(com.fanap.podchat.requestobject.RequestThreadParticipant) OutPutParticipant(com.fanap.podchat.model.OutPutParticipant) ResultParticipant(com.fanap.podchat.model.ResultParticipant) TypeToken(com.google.gson.reflect.TypeToken) ChatResponse(com.fanap.podchat.model.ChatResponse) JSONException(org.json.JSONException) SentryException(io.sentry.core.protocol.SentryException) IOException(java.io.IOException) JsonSyntaxException(com.google.gson.JsonSyntaxException) PodChatException(com.fanap.podchat.util.PodChatException) RoomIntegrityException(com.fanap.podchat.persistance.RoomIntegrityException)

Example 7 with ResultParticipant

use of com.fanap.podchat.model.ResultParticipant 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

ResultParticipant (com.fanap.podchat.model.ResultParticipant)7 Participant (com.fanap.podchat.mainmodel.Participant)6 ChatResponse (com.fanap.podchat.model.ChatResponse)6 RequestThreadParticipant (com.fanap.podchat.requestobject.RequestThreadParticipant)6 CacheParticipant (com.fanap.podchat.cachemodel.CacheParticipant)5 OutPutParticipant (com.fanap.podchat.model.OutPutParticipant)5 ResultAddParticipant (com.fanap.podchat.model.ResultAddParticipant)5 RoomIntegrityException (com.fanap.podchat.persistance.RoomIntegrityException)5 ArrayList (java.util.ArrayList)4 PodChatException (com.fanap.podchat.util.PodChatException)3 JsonSyntaxException (com.google.gson.JsonSyntaxException)3 SentryException (io.sentry.core.protocol.SentryException)3 IOException (java.io.IOException)3 JSONException (org.json.JSONException)3 RequestGetHashTagList (com.fanap.podchat.chat.hashtag.model.RequestGetHashTagList)2 RequestGetMentionList (com.fanap.podchat.chat.mention.model.RequestGetMentionList)2 ResultBlockList (com.fanap.podchat.model.ResultBlockList)2 RequestBlockList (com.fanap.podchat.requestobject.RequestBlockList)2 RequestDeliveredMessageList (com.fanap.podchat.requestobject.RequestDeliveredMessageList)2 RequestSeenMessageList (com.fanap.podchat.requestobject.RequestSeenMessageList)2