use of com.fanap.podchat.model.OutPutParticipant in project pod-chat-android-sdk by FanapSoft.
the class ChatCore method loadAdminsFromCache.
private void loadAdminsFromCache(String uniqueId, int count, int offset, long threadId) {
try {
messageDatabaseHelper.getThreadAdmins(offset, count, threadId, (obj, listData) -> {
List<Participant> participants = (List<Participant>) listData;
long participantCount = (long) obj;
if (participants != null) {
ChatResponse<ResultParticipant> chatResponse = new ChatResponse<>();
ResultParticipant resultParticipant = new ResultParticipant();
resultParticipant.setThreadId(threadId);
resultParticipant.setContentCount(participants.size());
resultParticipant.setHasNext(participants.size() + offset < participantCount);
resultParticipant.setParticipants(participants);
chatResponse.setResult(resultParticipant);
chatResponse.setCache(true);
chatResponse.setUniqueId(uniqueId);
chatResponse.setSubjectId(threadId);
resultParticipant.setNextOffset(offset + participants.size());
String jsonParticipant = gson.toJson(chatResponse);
OutPutParticipant outPutParticipant = new OutPutParticipant();
outPutParticipant.setResult(resultParticipant);
listenerManager.callOnGetThreadAdmin(jsonParticipant, chatResponse);
showLog("RECEIVE ADMINS FROM CACHE", jsonParticipant);
}
});
} catch (RoomIntegrityException e) {
disableCache();
}
}
use of com.fanap.podchat.model.OutPutParticipant in project pod-chat-android-sdk by FanapSoft.
the class ChatCore method reformatThreadParticipants.
private ChatResponse<ResultParticipant> reformatThreadParticipants(Callback callback, ChatMessage chatMessage) {
ArrayList<Participant> participants = new ArrayList<>();
if (!Util.isNullOrEmpty(chatMessage.getContent())) {
try {
participants = gson.fromJson(chatMessage.getContent(), new TypeToken<ArrayList<Participant>>() {
}.getType());
} catch (Exception e) {
showErrorLog(e.getMessage());
onUnknownException(chatMessage.getUniqueId(), e);
}
}
if (cache) {
List<CacheParticipant> cacheParticipants = new ArrayList<>();
if (!Util.isNullOrEmpty(chatMessage.getContent())) {
try {
cacheParticipants = gson.fromJson(chatMessage.getContent(), new TypeToken<ArrayList<CacheParticipant>>() {
}.getType());
} catch (JsonSyntaxException e) {
showErrorLog(e.getMessage());
onUnknownException(chatMessage.getUniqueId(), e);
}
}
if (!cacheParticipants.isEmpty())
messageDatabaseHelper.saveParticipants(cacheParticipants, chatMessage.getSubjectId(), getExpireAmount());
}
ChatResponse<ResultParticipant> outPutParticipant = new ChatResponse<>();
outPutParticipant.setErrorCode(0);
outPutParticipant.setErrorMessage("");
outPutParticipant.setHasError(false);
outPutParticipant.setUniqueId(chatMessage.getUniqueId());
outPutParticipant.setSubjectId(chatMessage.getSubjectId());
ResultParticipant resultParticipant = new ResultParticipant();
resultParticipant.setContentCount(chatMessage.getContentCount());
resultParticipant.setThreadId(chatMessage.getSubjectId());
if (callback != null) {
resultParticipant.setHasNext(participants.size() + callback.getOffset() < chatMessage.getContentCount());
resultParticipant.setNextOffset(callback.getOffset() + participants.size());
}
resultParticipant.setParticipants(participants);
outPutParticipant.setResult(resultParticipant);
return outPutParticipant;
}
use of com.fanap.podchat.model.OutPutParticipant in project pod-chat-android-sdk by FanapSoft.
the class ChatCore method reformatThreadParticipantsForRemove.
private ChatResponse<ResultParticipant> reformatThreadParticipantsForRemove(Callback callback, ChatMessage chatMessage) {
ArrayList<Participant> participants = new ArrayList<>();
if (!Util.isNullOrEmpty(chatMessage.getContent())) {
try {
participants = gson.fromJson(chatMessage.getContent(), new TypeToken<ArrayList<Participant>>() {
}.getType());
} catch (Exception e) {
showErrorLog(e.getMessage());
onUnknownException(chatMessage.getUniqueId(), e);
}
}
if (cache) {
List<CacheParticipant> cacheParticipants = new ArrayList<>();
if (!Util.isNullOrEmpty(chatMessage.getContent())) {
try {
cacheParticipants = gson.fromJson(chatMessage.getContent(), new TypeToken<ArrayList<CacheParticipant>>() {
}.getType());
} catch (JsonSyntaxException e) {
showErrorLog(e.getMessage());
onUnknownException(chatMessage.getUniqueId(), e);
}
}
if (!cacheParticipants.isEmpty()) {
messageDatabaseHelper.deleteParticipant(chatMessage.getSubjectId(), cacheParticipants.get(0).getId());
}
}
ChatResponse<ResultParticipant> outPutParticipant = new ChatResponse<>();
outPutParticipant.setErrorCode(0);
outPutParticipant.setErrorMessage("");
outPutParticipant.setHasError(false);
outPutParticipant.setUniqueId(chatMessage.getUniqueId());
outPutParticipant.setSubjectId(chatMessage.getSubjectId());
ResultParticipant resultParticipant = new ResultParticipant();
resultParticipant.setContentCount(chatMessage.getContentCount());
resultParticipant.setThreadId(chatMessage.getSubjectId());
if (callback != null) {
resultParticipant.setHasNext(participants.size() + callback.getOffset() < chatMessage.getContentCount());
resultParticipant.setNextOffset(callback.getOffset() + participants.size());
}
resultParticipant.setParticipants(participants);
outPutParticipant.setResult(resultParticipant);
return outPutParticipant;
}
Aggregations