use of com.fanap.podchat.model.ResultThread in project pod-chat-android-sdk by FanapSoft.
the class ChatCore method createThreadWithFile.
//
// 1. Create thread.
// 2.1. Upload thread image and update thread info if RequestUploadImage is set.
// 2.2. Upload file to server with thread userGroupHash and send uploaded file as message by sendFileMessage.
//
public ArrayList<String> createThreadWithFile(RequestCreateThreadWithFile request, @Nullable ProgressHandler.sendFileMessage progressHandler) {
ArrayList<String> uniqueIds = new ArrayList<>();
String requestUniqueId = generateUniqueId();
uniqueIds.add(requestUniqueId);
if (needReadStoragePermission(request.getFile().getActivity()))
return uniqueIds;
if (chatReady) {
handlerSend.put(requestUniqueId, new ChatHandler() {
@Override
public void onThreadCreated(ResultThread thread) {
super.onThreadCreated(thread);
if (request.getUploadThreadImageRequest() != null)
new PodThreadManager().doThisAndGo(() -> updateThreadImage(thread, request.getUploadThreadImageRequest()));
RequestFileMessage.Builder requestFileBuilder = new RequestFileMessage.Builder(request.getMessage() != null ? request.getMessage().getText() : null, request.getFile().getActivity(), thread.getThread().getId(), request.getFile().getFileUri(), request.getMessage() != null ? request.getMessage().getSystemMetadata() : null, request.getMessageType(), thread.getThread().getUserGroupHash());
if (request.getFile() instanceof RequestUploadImage) {
requestFileBuilder.setImageHc(String.valueOf(((RequestUploadImage) request.getFile()).gethC()));
requestFileBuilder.setImageWc(String.valueOf(((RequestUploadImage) request.getFile()).getwC()));
requestFileBuilder.setImageXc(String.valueOf(((RequestUploadImage) request.getFile()).getxC()));
requestFileBuilder.setImageYc(String.valueOf(((RequestUploadImage) request.getFile()).getyC()));
}
RequestFileMessage requestFile = requestFileBuilder.build();
sendFileMessage(requestFile, requestUniqueId, progressHandler);
}
});
RequestCreateThread requestCreateThread = new RequestCreateThread.Builder(request.getType(), request.getInvitees()).title(request.getTitle()).withDescription(request.getDescription()).withImage(request.getImage()).withMetadata(request.getMessage() != null ? request.getMessage().getSystemMetadata() : null).build();
createThread(requestCreateThread, requestUniqueId);
// prepareCreateThreadWithFile(request, requestUniqueId, innerMessageUniqueId, forwardUniqueIds, "");
} else {
captureError(ChatConstant.ERROR_CHAT_READY, ChatConstant.ERROR_CODE_CHAT_READY, requestUniqueId);
}
return uniqueIds;
}
use of com.fanap.podchat.model.ResultThread 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;
}
use of com.fanap.podchat.model.ResultThread in project pod-chat-android-sdk by FanapSoft.
the class ChatCore method onThreadInfoUpdated.
private void onThreadInfoUpdated(Thread thread, String uniqueId, boolean needCacheUpdate) {
ResultThread resultThread = new ResultThread();
resultThread.setThread(thread);
ChatResponse<ResultThread> chatResponse = new ChatResponse<>();
chatResponse.setResult(resultThread);
chatResponse.setUniqueId(uniqueId);
chatResponse.setSubjectId(thread.getId());
if (cache && needCacheUpdate) {
dataSource.saveThreadResultFromServer(thread);
}
if (sentryResponseLog) {
showLog("RECEIVE_UPDATE_THREAD_INFO", chatResponse.getJson());
} else {
showLog("RECEIVE_UPDATE_THREAD_INFO");
}
messageCallbacks.remove(uniqueId);
listenerManager.callOnUpdateThreadInfo(chatResponse.getJson(), chatResponse);
}
Aggregations