use of com.fanap.podchat.model.ResultBlockList in project pod-chat-android-sdk by FanapSoft.
the class ChatCore method getBlockList.
/**
* It gets the list of the contacts that is on block list
*/
public String getBlockList(RequestBlockList request, ChatHandler handler) {
String uniqueId = generateUniqueId();
PodThreadManager threadManager = new PodThreadManager();
threadManager.addTask(() -> {
if (cache && request.useCacheData()) {
List<BlockedContact> cacheContacts = messageDatabaseHelper.getBlockedContacts(request.getCount(), request.getOffset());
if (!Util.isNullOrEmpty(cacheContacts)) {
ChatResponse<ResultBlockList> chatResponse = ContactManager.prepareGetBlockListFromCache(uniqueId, cacheContacts);
listenerManager.callOnGetBlockList(gson.toJson(chatResponse), chatResponse);
if (sentryResponseLog) {
showLog("RECEIVE_GET_BLOCK_LIST_FROM_CACHE", gson.toJson(chatResponse));
} else {
showLog("RECEIVE_GET_BLOCK_LIST_FROM_CACHE");
}
}
}
});
threadManager.addTask(() -> {
if (chatReady) {
String asyncContent = ContactManager.prepareGetBlockListRequest(request.getCount(), request.getOffset(), uniqueId, getTypeCode(), getToken());
setCallBacks(null, null, null, true, Constants.GET_BLOCKED, null, uniqueId);
sendAsyncMessage(asyncContent, AsyncAckType.Constants.WITHOUT_ACK, "SEND_GET_BLOCK_LIST");
if (handler != null) {
handler.onGetBlockList(uniqueId);
}
} else {
captureError(ChatConstant.ERROR_CHAT_READY, ChatConstant.ERROR_CODE_CHAT_READY, uniqueId);
}
});
threadManager.runTasksSynced();
return uniqueId;
}
use of com.fanap.podchat.model.ResultBlockList in project pod-chat-android-sdk by FanapSoft.
the class ContactManager method prepareGetBlockListFromCache.
public static ChatResponse<ResultBlockList> prepareGetBlockListFromCache(String uniqueId, List<BlockedContact> cacheContacts) {
ChatResponse<ResultBlockList> chatResponse = new ChatResponse<>();
chatResponse.setErrorCode(0);
chatResponse.setHasError(false);
chatResponse.setUniqueId(uniqueId);
chatResponse.setCache(true);
ResultBlockList resultBlockList = new ResultBlockList();
resultBlockList.setContacts(cacheContacts);
chatResponse.setResult(resultBlockList);
return chatResponse;
}
use of com.fanap.podchat.model.ResultBlockList in project pod-chat-android-sdk by FanapSoft.
the class ContactManager method prepareBlockListResponse.
public static ChatResponse<ResultBlockList> prepareBlockListResponse(ChatMessage chatMessage) {
ChatResponse<ResultBlockList> chatResponse = new ChatResponse<>();
chatResponse.setErrorCode(0);
chatResponse.setHasError(false);
chatResponse.setUniqueId(chatMessage.getUniqueId());
ResultBlockList resultBlockList = new ResultBlockList();
List<BlockedContact> blockedContacts = App.getGson().fromJson(chatMessage.getContent(), new TypeToken<ArrayList<BlockedContact>>() {
}.getType());
resultBlockList.setContacts(blockedContacts);
chatResponse.setResult(resultBlockList);
return chatResponse;
}
Aggregations