Search in sources :

Example 11 with ChannelFeed

use of com.applozic.mobicomkit.feed.ChannelFeed in project Applozic-Android-SDK by AppLozic.

the class ConversationService method createConversation.

public synchronized Integer createConversation(Conversation conversation) {
    ChannelFeed channelFeed = conversationClientService.createConversation(conversation);
    if (channelFeed != null) {
        if (conversation.getSupportIds() != null) {
            ChannelFeed[] channelFeeds = new ChannelFeed[1];
            channelFeeds[0] = channelFeed;
            ChannelService.getInstance(context).processChannelFeedList(channelFeeds, false);
            ;
        }
        if (channelFeed.getConversationPxy() != null) {
            addConversation(channelFeed.getConversationPxy());
            return channelFeed.getConversationPxy().getId();
        }
    }
    return null;
}
Also used : ChannelFeed(com.applozic.mobicomkit.feed.ChannelFeed)

Example 12 with ChannelFeed

use of com.applozic.mobicomkit.feed.ChannelFeed in project Applozic-Android-SDK by AppLozic.

the class ChannelClientService method createChannel.

public ChannelFeed createChannel(ChannelInfo channelInfo) {
    ChannelFeed channelFeed = null;
    try {
        String jsonFromObject = GsonUtils.getJsonFromObject(channelInfo, channelInfo.getClass());
        String createChannelResponse = httpRequestUtils.postData(getCreateChannelUrl(), "application/json", "application/json", jsonFromObject);
        Utils.printLog(context, TAG, "Create channel Response :" + createChannelResponse);
        ChannelFeedApiResponse channelFeedApiResponse = (ChannelFeedApiResponse) GsonUtils.getObjectFromJson(createChannelResponse, ChannelFeedApiResponse.class);
        if (channelFeedApiResponse != null && channelFeedApiResponse.isSuccess()) {
            channelFeed = channelFeedApiResponse.getResponse();
        }
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
    return channelFeed;
}
Also used : SyncChannelFeed(com.applozic.mobicomkit.sync.SyncChannelFeed) ChannelFeed(com.applozic.mobicomkit.feed.ChannelFeed) MultipleChannelFeedApiResponse(com.applozic.mobicomkit.MultipleChannelFeedApiResponse) ChannelFeedApiResponse(com.applozic.mobicomkit.feed.ChannelFeedApiResponse)

Example 13 with ChannelFeed

use of com.applozic.mobicomkit.feed.ChannelFeed in project Applozic-Android-SDK by AppLozic.

the class ChannelClientService method getMembersFromContactGroupOfType.

public ChannelFeed getMembersFromContactGroupOfType(String contactGroupId, String groupType) {
    String response;
    if (!TextUtils.isEmpty(contactGroupId) && !TextUtils.isEmpty(groupType)) {
        String url = String.format(getMembersFromContactGroupOfTypeUrl() + "?" + GROUPTYPE + "=" + groupType, contactGroupId);
        response = httpRequestUtils.getResponse(url, "application/json", "application/json");
        ChannelFeedApiResponse channelFeedApiResponse = (ChannelFeedApiResponse) GsonUtils.getObjectFromJson(response, ChannelFeedApiResponse.class);
        if (channelFeedApiResponse != null && channelFeedApiResponse.isSuccess()) {
            ChannelFeed channelFeed = channelFeedApiResponse.getResponse();
            return channelFeed;
        }
    }
    return null;
}
Also used : SyncChannelFeed(com.applozic.mobicomkit.sync.SyncChannelFeed) ChannelFeed(com.applozic.mobicomkit.feed.ChannelFeed) MultipleChannelFeedApiResponse(com.applozic.mobicomkit.MultipleChannelFeedApiResponse) ChannelFeedApiResponse(com.applozic.mobicomkit.feed.ChannelFeedApiResponse)

Example 14 with ChannelFeed

use of com.applozic.mobicomkit.feed.ChannelFeed in project Applozic-Android-SDK by AppLozic.

the class ChannelService method processChannelList.

public synchronized void processChannelList(List<ChannelFeed> channelFeedList) {
    if (channelFeedList != null && channelFeedList.size() > 0) {
        for (ChannelFeed channelFeed : channelFeedList) {
            Set<String> memberUserIds = channelFeed.getMembersName();
            Set<String> userIds = new HashSet<>();
            Channel channel = getChannel(channelFeed);
            if (channelDatabaseService.isChannelPresent(channel.getKey())) {
                channelDatabaseService.updateChannel(channel);
                channelDatabaseService.deleteChannelUserMappers(channel.getKey());
            } else {
                channelDatabaseService.addChannel(channel);
            }
            if (memberUserIds != null && memberUserIds.size() > 0) {
                for (String userId : memberUserIds) {
                    ChannelUserMapper channelUserMapper = new ChannelUserMapper(channelFeed.getId(), userId);
                    channelDatabaseService.addChannelUserMapper(channelUserMapper);
                    if (!baseContactService.isContactExists(userId)) {
                        userIds.add(userId);
                    }
                }
                if (userIds != null && userIds.size() > 0) {
                    userService.processUserDetailsByUserIds(userIds);
                }
            }
            if (channelFeed.getGroupUsers() != null && channelFeed.getGroupUsers().size() > 0) {
                for (ChannelUsersFeed channelUsers : channelFeed.getGroupUsers()) {
                    if (channelUsers.getRole() != null) {
                        channelDatabaseService.updateRoleInChannelUserMapper(channelFeed.getId(), channelUsers.getUserId(), channelUsers.getRole());
                    }
                }
            }
        }
    }
}
Also used : ChannelUsersFeed(com.applozic.mobicomkit.feed.ChannelUsersFeed) Channel(com.applozic.mobicommons.people.channel.Channel) SyncChannelFeed(com.applozic.mobicomkit.sync.SyncChannelFeed) ChannelFeed(com.applozic.mobicomkit.feed.ChannelFeed) ChannelUserMapper(com.applozic.mobicommons.people.channel.ChannelUserMapper) HashSet(java.util.HashSet)

Example 15 with ChannelFeed

use of com.applozic.mobicomkit.feed.ChannelFeed in project Applozic-Android-SDK by AppLozic.

the class ChannelService method createGroupOfTwo.

public Channel createGroupOfTwo(ChannelInfo channelInfo) {
    if (channelInfo == null) {
        return null;
    }
    if (!TextUtils.isEmpty(channelInfo.getClientGroupId())) {
        Channel channel = channelDatabaseService.getChannelByClientGroupId(channelInfo.getClientGroupId());
        if (channel != null) {
            return channel;
        } else {
            ChannelFeedApiResponse channelFeedApiResponse = channelClientService.createChannelWithResponse(channelInfo);
            if (channelFeedApiResponse == null) {
                return null;
            }
            if (channelFeedApiResponse.isSuccess()) {
                ChannelFeed channelFeed = channelFeedApiResponse.getResponse();
                if (channelFeed != null) {
                    ChannelFeed[] channelFeeds = new ChannelFeed[1];
                    channelFeeds[0] = channelFeed;
                    processChannelFeedList(channelFeeds, true);
                    return getChannel(channelFeed);
                }
            } else {
                ChannelFeed channelFeed = channelClientService.getChannelInfo(channelInfo.getClientGroupId());
                if (channelFeed != null) {
                    ChannelFeed[] channelFeeds = new ChannelFeed[1];
                    channelFeeds[0] = channelFeed;
                    processChannelFeedList(channelFeeds, false);
                    return getChannel(channelFeed);
                }
            }
        }
    }
    return null;
}
Also used : Channel(com.applozic.mobicommons.people.channel.Channel) SyncChannelFeed(com.applozic.mobicomkit.sync.SyncChannelFeed) ChannelFeed(com.applozic.mobicomkit.feed.ChannelFeed) ChannelFeedApiResponse(com.applozic.mobicomkit.feed.ChannelFeedApiResponse)

Aggregations

ChannelFeed (com.applozic.mobicomkit.feed.ChannelFeed)18 SyncChannelFeed (com.applozic.mobicomkit.sync.SyncChannelFeed)14 ChannelFeedApiResponse (com.applozic.mobicomkit.feed.ChannelFeedApiResponse)7 Channel (com.applozic.mobicommons.people.channel.Channel)7 MultipleChannelFeedApiResponse (com.applozic.mobicomkit.MultipleChannelFeedApiResponse)5 HashSet (java.util.HashSet)3 ChannelFeedListResponse (com.applozic.mobicomkit.feed.ChannelFeedListResponse)2 ChannelUsersFeed (com.applozic.mobicomkit.feed.ChannelUsersFeed)2 ChannelUserMapper (com.applozic.mobicommons.people.channel.ChannelUserMapper)2 Intent (android.content.Intent)1 MobiComUserPreference (com.applozic.mobicomkit.api.account.user.MobiComUserPreference)1 UserDetail (com.applozic.mobicomkit.api.account.user.UserDetail)1 FileClientService (com.applozic.mobicomkit.api.attachment.FileClientService)1 ChannelInfo (com.applozic.mobicomkit.api.people.ChannelInfo)1 ApplozicException (com.applozic.mobicomkit.exception.ApplozicException)1 ErrorResponseFeed (com.applozic.mobicomkit.feed.ErrorResponseFeed)1 AnnotationExclusionStrategy (com.applozic.mobicommons.json.AnnotationExclusionStrategy)1 ArrayAdapterFactory (com.applozic.mobicommons.json.ArrayAdapterFactory)1 Conversation (com.applozic.mobicommons.people.channel.Conversation)1 Contact (com.applozic.mobicommons.people.contact.Contact)1