Search in sources :

Example 1 with ChatThread

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

the class ThreadManager method prepareCreateThread.

public static String prepareCreateThread(int threadType, Invitee[] invitee, String threadTitle, String description, String image, String metadata, String uniqueId, String typecode, String token) {
    List<Invitee> invitees = new ArrayList<Invitee>(Arrays.asList(invitee));
    ChatThread chatThread = new ChatThread();
    chatThread.setType(threadType);
    chatThread.setInvitees(invitees);
    chatThread.setTitle(threadTitle);
    JsonObject chatThreadObject = (JsonObject) App.getGson().toJsonTree(chatThread);
    if (Util.isNullOrEmpty(description)) {
        chatThreadObject.remove("description");
    } else {
        chatThreadObject.remove("description");
        chatThreadObject.addProperty("description", description);
    }
    if (Util.isNullOrEmpty(image)) {
        chatThreadObject.remove("image");
    } else {
        chatThreadObject.remove("image");
        chatThreadObject.addProperty("image", image);
    }
    if (Util.isNullOrEmpty(metadata)) {
        chatThreadObject.remove("metadata");
    } else {
        chatThreadObject.remove("metadata");
        chatThreadObject.addProperty("metadata", metadata);
    }
    String contentThreadChat = chatThreadObject.toString();
    ChatMessage chatMessage = getChatMessage(contentThreadChat, uniqueId, typecode, token);
    JsonObject jsonObject = (JsonObject) App.getGson().toJsonTree(chatMessage);
    if (Util.isNullOrEmpty(typecode)) {
        jsonObject.remove("typeCode");
    } else {
        jsonObject.remove("typeCode");
        jsonObject.addProperty("typeCode", typecode);
    }
    String asyncContent = jsonObject.toString();
    return asyncContent;
}
Also used : Invitee(com.fanap.podchat.mainmodel.Invitee) ChatThread(com.fanap.podchat.mainmodel.ChatThread) ChatMessage(com.fanap.podchat.mainmodel.ChatMessage) ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject)

Aggregations

ChatMessage (com.fanap.podchat.mainmodel.ChatMessage)1 ChatThread (com.fanap.podchat.mainmodel.ChatThread)1 Invitee (com.fanap.podchat.mainmodel.Invitee)1 JsonObject (com.google.gson.JsonObject)1 ArrayList (java.util.ArrayList)1