use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.
the class ChannelServiceTest method removeMemberFromChannel_withSuccess.
@Test
public void removeMemberFromChannel_withSuccess() {
ApiResponse response = (ApiResponse) GsonUtils.getObjectFromJson(MockConstants.removeMemberSuccessResponse, ApiResponse.class);
when(channelClientService.removeMemberFromChannel(8905836, "reytum7")).thenReturn(response);
String status = channelService.removeMemberFromChannelProcess(8905836, "reytum7");
assertEquals(AlResponse.SUCCESS, status);
}
use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.
the class ChannelServiceTest method addMemberToChannel_withSuccess.
@Test
public void addMemberToChannel_withSuccess() {
ApiResponse response = (ApiResponse) GsonUtils.getObjectFromJson(MockConstants.addMemberSuccessResponse, ApiResponse.class);
when(channelClientService.addMemberToChannel(8905836, "reytum6")).thenReturn(response);
assertEquals(AlResponse.SUCCESS, channelService.addMemberToChannelProcess(8905836, "reytum6"));
}
use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.
the class ChannelServiceTest method addMemberToChannel_withError.
@Test
public void addMemberToChannel_withError() {
ApiResponse response = (ApiResponse) GsonUtils.getObjectFromJson(MockConstants.addMemberErrorResponse, ApiResponse.class);
when(channelClientService.addMemberToChannel(8905836, "reytum6")).thenReturn(response);
assertEquals(AlResponse.ERROR, channelService.addMemberToChannelProcess(8905836, "reytum6"));
}
use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.
the class ChannelServiceTest method removeMemberFromChannel_withError.
@Test
public void removeMemberFromChannel_withError() {
ApiResponse response = (ApiResponse) GsonUtils.getObjectFromJson(MockConstants.removeMemberErrorResponse, ApiResponse.class);
when(channelClientService.removeMemberFromChannel(8905836, "reytum700")).thenReturn(response);
assertEquals(AlResponse.ERROR, channelService.removeMemberFromChannelProcess(8905836, "reytum700"));
}
use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.
the class MobiComConversationService method getAlConversationList.
/**
* @deprecated This method is no longer used and will be deprecated soon.
*/
@Deprecated
public synchronized List<Message> getAlConversationList(int status, int pageSize, Long lastFetchTime, boolean makeServerCall) throws Exception {
List<Message> conversationList = new ArrayList<>();
List<Message> cachedConversationList = messageDatabaseService.getAlConversationList(status, lastFetchTime);
if (!makeServerCall && !cachedConversationList.isEmpty()) {
return cachedConversationList;
}
AlConversationResponse alConversationResponse = null;
try {
ApiResponse<AlConversationResponse> apiResponse = (ApiResponse<AlConversationResponse>) GsonUtils.getObjectFromJson(messageClientService.getAlConversationList(status, pageSize, lastFetchTime), new TypeToken<ApiResponse<AlConversationResponse>>() {
}.getType());
if (apiResponse != null) {
alConversationResponse = apiResponse.getResponse();
}
} catch (Exception e) {
e.printStackTrace();
throw e;
}
if (alConversationResponse == null) {
return null;
}
try {
if (alConversationResponse.getUserDetails() != null) {
processUserDetails(alConversationResponse.getUserDetails());
}
if (alConversationResponse.getGroupFeeds() != null) {
ChannelService.getInstance(context).processChannelFeedList(alConversationResponse.getGroupFeeds(), false);
}
Message[] messages = alConversationResponse.getMessage();
MobiComUserPreference userPreferences = MobiComUserPreference.getInstance(context);
if (messages != null && messages.length > 0 && cachedConversationList.size() > 0 && cachedConversationList.get(0).isLocalMessage()) {
if (cachedConversationList.get(0).equals(messages[0])) {
Utils.printLog(context, TAG, "Both messages are same.");
deleteMessage(cachedConversationList.get(0));
}
}
for (Message message : messages) {
if (!message.isCall() || userPreferences.isDisplayCallRecordEnable()) {
if (message.getTo() == null) {
continue;
}
if (message.hasAttachment() && !(message.getContentType() == Message.ContentType.TEXT_URL.getValue())) {
setFilePathifExist(message);
}
if (message.getContentType() == Message.ContentType.CONTACT_MSG.getValue()) {
FileClientService fileClientService = new FileClientService(context);
fileClientService.loadContactsvCard(message);
}
if (Message.MetaDataType.HIDDEN.getValue().equals(message.getMetaDataValueForKey(Message.MetaDataType.KEY.getValue())) || Message.MetaDataType.PUSHNOTIFICATION.getValue().equals(message.getMetaDataValueForKey(Message.MetaDataType.KEY.getValue()))) {
continue;
}
if (isHideActionMessage && message.isActionMessage()) {
message.setHidden(true);
}
if (messageDatabaseService.isMessagePresent(message.getKeyString(), Message.ReplyMessage.HIDE_MESSAGE.getValue())) {
messageDatabaseService.updateMessageReplyType(message.getKeyString(), Message.ReplyMessage.NON_HIDDEN.getValue());
} else {
messageDatabaseService.createMessage(message);
}
if (message.hasHideKey()) {
if (message.getGroupId() != null) {
Channel newChannel = ChannelService.getInstance(context).getChannelByChannelKey(message.getGroupId());
if (newChannel != null) {
getMessagesWithNetworkMetaData(null, null, null, newChannel, null, true, false);
}
} else {
getMessagesWithNetworkMetaData(null, null, new Contact(message.getContactIds()), null, null, true, false);
}
}
}
conversationList.add(message);
}
Intent intent = new Intent(MobiComKitConstants.APPLOZIC_UNREAD_COUNT);
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
List<Message> finalMessageList = messageDatabaseService.getAlConversationList(status, lastFetchTime);
List<String> messageKeys = new ArrayList<>();
for (Message msg : finalMessageList) {
if (msg.getTo() == null) {
continue;
}
if (Message.MetaDataType.HIDDEN.getValue().equals(msg.getMetaDataValueForKey(Message.MetaDataType.KEY.getValue())) || Message.MetaDataType.PUSHNOTIFICATION.getValue().equals(msg.getMetaDataValueForKey(Message.MetaDataType.KEY.getValue()))) {
continue;
}
if (msg.getMetadata() != null && msg.getMetaDataValueForKey(Message.MetaDataType.AL_REPLY.getValue()) != null && !messageDatabaseService.isMessagePresent(msg.getMetaDataValueForKey(Message.MetaDataType.AL_REPLY.getValue()))) {
messageKeys.add(msg.getMetaDataValueForKey(Message.MetaDataType.AL_REPLY.getValue()));
}
}
if (messageKeys != null && messageKeys.size() > 0) {
Message[] replyMessageList = getMessageListByKeyList(messageKeys);
if (replyMessageList != null) {
for (Message replyMessage : replyMessageList) {
if (replyMessage.getTo() == null) {
continue;
}
if (Message.MetaDataType.HIDDEN.getValue().equals(replyMessage.getMetaDataValueForKey(Message.MetaDataType.KEY.getValue())) || Message.MetaDataType.PUSHNOTIFICATION.getValue().equals(replyMessage.getMetaDataValueForKey(Message.MetaDataType.KEY.getValue()))) {
continue;
}
if (replyMessage.hasAttachment() && !(replyMessage.getContentType() == Message.ContentType.TEXT_URL.getValue())) {
setFilePathifExist(replyMessage);
}
if (replyMessage.getContentType() == Message.ContentType.CONTACT_MSG.getValue()) {
FileClientService fileClientService = new FileClientService(context);
fileClientService.loadContactsvCard(replyMessage);
}
replyMessage.setReplyMessage(Message.ReplyMessage.HIDE_MESSAGE.getValue());
messageDatabaseService.createMessage(replyMessage);
}
}
}
if (!conversationList.isEmpty()) {
Collections.sort(conversationList, new Comparator<Message>() {
@Override
public int compare(Message lhs, Message rhs) {
return lhs.getCreatedAtTime().compareTo(rhs.getCreatedAtTime());
}
});
}
return finalMessageList;
}
Aggregations