Search in sources :

Example 1 with ResultNotSeenDuration

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

the class ChatCore method handleGetNotSeenDuration.

private void handleGetNotSeenDuration(Callback callback, ChatMessage chatMessage, String messageUniqueId) {
    messageCallbacks.remove(messageUniqueId);
    if (callback != null && callback.isResult()) {
        ChatResponse<ResultNotSeenDuration> result = reformatNotSeenDuration(chatMessage, callback);
        if (result == null) {
            messageCallbacks.remove(messageUniqueId);
            return;
        }
        OutPutNotSeenDurations output = new OutPutNotSeenDurations();
        output.setResultNotSeenDuration(result.getResult());
        if (sentryResponseLog) {
            showLog("RECEIVE_NOT_SEEN_DURATION", chatMessage.getContent());
        } else {
            showLog("RECEIVE_NOT_SEEN_DURATION");
        }
        listenerManager.callOnGetNotSeenDuration(output);
    }
}
Also used : ResultNotSeenDuration(com.fanap.podchat.model.ResultNotSeenDuration) OutPutNotSeenDurations(com.fanap.podchat.model.OutPutNotSeenDurations)

Example 2 with ResultNotSeenDuration

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

the class ChatCore method reformatNotSeenDuration.

private ChatResponse<ResultNotSeenDuration> reformatNotSeenDuration(ChatMessage chatMessage, Callback callback) {
    ChatResponse<ResultNotSeenDuration> response = new ChatResponse<>();
    Map<String, Long> idNotSeenPairs = new HashMap<>();
    JsonParser parser = new JsonParser();
    JsonObject jsonObject;
    try {
        jsonObject = parser.parse(chatMessage.getContent()).getAsJsonObject();
    } catch (Exception e) {
        captureError(e.getMessage(), ChatConstant.ERROR_CODE_UNKNOWN_EXCEPTION, chatMessage.getUniqueId(), e);
        return null;
    }
    for (String key : jsonObject.keySet()) {
        idNotSeenPairs.put(key, jsonObject.get(key).getAsLong());
    }
    ResultNotSeenDuration resultNotSeenDuration = new ResultNotSeenDuration();
    resultNotSeenDuration.setIdNotSeenPair(idNotSeenPairs);
    response.setResult(resultNotSeenDuration);
    return response;
}
Also used : ResultNotSeenDuration(com.fanap.podchat.model.ResultNotSeenDuration) HashMap(java.util.HashMap) ChatResponse(com.fanap.podchat.model.ChatResponse) JsonObject(com.google.gson.JsonObject) 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) JsonParser(com.google.gson.JsonParser)

Example 3 with ResultNotSeenDuration

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

the class ContactManager method prepareUpdateLastSeenResponse.

public static ChatResponse<ResultNotSeenDuration> prepareUpdateLastSeenResponse(ChatMessage message, JsonParser parser) {
    ChatResponse<ResultNotSeenDuration> response = new ChatResponse<>();
    JsonObject jsonObject = Util.objectToJson(message.getContent(), parser);
    Map<String, Long> idLastSeen = new HashMap<>();
    for (String key : jsonObject.keySet()) {
        idLastSeen.put(key, jsonObject.get(key).getAsLong());
    }
    ResultNotSeenDuration resultNotSeenDuration = new ResultNotSeenDuration();
    resultNotSeenDuration.setIdNotSeenPair(idLastSeen);
    response.setResult(resultNotSeenDuration);
    return response;
}
Also used : ResultNotSeenDuration(com.fanap.podchat.model.ResultNotSeenDuration) HashMap(java.util.HashMap) ChatResponse(com.fanap.podchat.model.ChatResponse) JsonObject(com.google.gson.JsonObject)

Aggregations

ResultNotSeenDuration (com.fanap.podchat.model.ResultNotSeenDuration)3 ChatResponse (com.fanap.podchat.model.ChatResponse)2 JsonObject (com.google.gson.JsonObject)2 HashMap (java.util.HashMap)2 OutPutNotSeenDurations (com.fanap.podchat.model.OutPutNotSeenDurations)1 RoomIntegrityException (com.fanap.podchat.persistance.RoomIntegrityException)1 PodChatException (com.fanap.podchat.util.PodChatException)1 JsonParser (com.google.gson.JsonParser)1 JsonSyntaxException (com.google.gson.JsonSyntaxException)1 SentryException (io.sentry.core.protocol.SentryException)1 IOException (java.io.IOException)1 JSONException (org.json.JSONException)1