Search in sources :

Example 1 with ChannelFeedListResponse

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

the class ChannelClientService method getGroupInfoFromGroupIds.

public ChannelFeedListResponse getGroupInfoFromGroupIds(List<String> groupIds, List<String> clientGroupIds) {
    ChannelFeedListResponse apiResponse = null;
    try {
        StringBuilder parameters = new StringBuilder("?");
        if (groupIds != null) {
            for (String groupId : groupIds) {
                if (!TextUtils.isEmpty(groupId)) {
                    parameters.append(GROUPIDS + "=" + groupId + "&");
                }
            }
        }
        if (clientGroupIds != null) {
            for (String clientGroupId : clientGroupIds) {
                if (!TextUtils.isEmpty(clientGroupId)) {
                    if (groupIds != null && groupIds.contains(clientGroupId)) {
                        continue;
                    } else {
                        parameters.append(CLIENT_GROUPIDs + "=" + clientGroupId + "&");
                    }
                }
            }
        }
        String url = getGroupInfoFromGroupIdsUrl() + parameters;
        String response = httpRequestUtils.getResponse(url, "application/json", "application/json");
        apiResponse = (ChannelFeedListResponse) GsonUtils.getObjectFromJson(response, ChannelFeedListResponse.class);
        if (apiResponse != null) {
            Utils.printLog(context, TAG, "Group Info from groupIds/clientGroupIds response : " + apiResponse.getStatus());
        }
    } catch (Exception e) {
        Utils.printLog(context, TAG, e.getMessage());
    }
    return apiResponse;
}
Also used : ChannelFeedListResponse(com.applozic.mobicomkit.feed.ChannelFeedListResponse)

Example 2 with ChannelFeedListResponse

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

the class ChannelService method getMembersFromContactGroupList.

public ChannelFeed[] getMembersFromContactGroupList(List<String> groupIdList, List<String> groupNames, String groupType) {
    List<ChannelFeed> channelFeedList;
    ChannelFeedListResponse channelFeedListResponse = channelClientService.getMemebersFromContactGroupIds(groupIdList, groupNames, groupType);
    if (channelFeedListResponse != null && channelFeedListResponse.getStatus().equals(ChannelFeedListResponse.SUCCESS)) {
        channelFeedList = channelFeedListResponse.getResponse();
        processChannelFeedList(channelFeedList.toArray(new ChannelFeed[channelFeedList.size()]), false);
        return channelFeedList.toArray(new ChannelFeed[channelFeedList.size()]);
    }
    return null;
}
Also used : ChannelFeedListResponse(com.applozic.mobicomkit.feed.ChannelFeedListResponse) SyncChannelFeed(com.applozic.mobicomkit.sync.SyncChannelFeed) ChannelFeed(com.applozic.mobicomkit.feed.ChannelFeed)

Example 3 with ChannelFeedListResponse

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

the class AlGetMembersFromContactGroupListTask method doInBackground.

@Override
protected AlGetMembersModel doInBackground(Void... voids) {
    AlGetMembersModel model = new AlGetMembersModel();
    try {
        ChannelFeedListResponse response = ChannelClientService.getInstance(context.get()).getMemebersFromContactGroupIds(groupIds, groupNames, groupType);
        if (response != null) {
            if (ChannelFeedListResponse.SUCCESS.equals(response.getStatus())) {
                Set<String> contactIds = new HashSet<String>();
                if (!response.getResponse().isEmpty()) {
                    ChannelService.getInstance(context.get()).processChannelFeedList(response.getResponse().toArray(new ChannelFeed[response.getResponse().size()]), false);
                    for (ChannelFeed feed : response.getResponse()) {
                        contactIds.addAll(feed.getContactGroupMembersId());
                    }
                    model.setMembers(contactIds.toArray(new String[contactIds.size()]));
                    UserService.getInstance(context.get()).processUserDetailsByUserIds(contactIds);
                    model.setResponse("Successfully fetched");
                }
            } else if (response.getErrorResponse() != null) {
                model.setResponse(GsonUtils.getJsonFromObject(response.getErrorResponse(), ErrorResponseFeed[].class));
            }
        } else {
            model.setResponse("Some Error occurred");
        }
    } catch (Exception e) {
        e.printStackTrace();
        model.setException(e);
    }
    return model;
}
Also used : ErrorResponseFeed(com.applozic.mobicomkit.feed.ErrorResponseFeed) ChannelFeedListResponse(com.applozic.mobicomkit.feed.ChannelFeedListResponse) ChannelFeed(com.applozic.mobicomkit.feed.ChannelFeed) HashSet(java.util.HashSet)

Example 4 with ChannelFeedListResponse

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

the class ChannelClientService method getMemebersFromContactGroupIds.

public ChannelFeedListResponse getMemebersFromContactGroupIds(List<String> groupIds, List<String> groupNames, String groupType) {
    ChannelFeedListResponse channelFeedListResponse = null;
    try {
        StringBuilder parameters = new StringBuilder("?");
        if (!TextUtils.isEmpty(groupType)) {
            parameters.append(GROUPTYPE + "=" + groupType + "&");
        }
        if (groupIds != null) {
            for (String groupId : groupIds) {
                if (!TextUtils.isEmpty(groupId)) {
                    parameters.append(GROUP_ID + "=" + groupId + "&");
                }
            }
        }
        if (groupNames != null) {
            for (String groupName : groupNames) {
                if (!TextUtils.isEmpty(groupName)) {
                    parameters.append(GROUP_NAME + "=" + groupName + "&");
                }
            }
        }
        String url = getMembersFromContactGroupListUrl() + parameters;
        String response = httpRequestUtils.getResponse(url, "application/json", "application/json");
        channelFeedListResponse = (ChannelFeedListResponse) GsonUtils.getObjectFromJson(response, ChannelFeedListResponse.class);
        if (channelFeedListResponse != null) {
            Utils.printLog(context, TAG, "Get Memebers from Contact Group List of Type Response : " + channelFeedListResponse.getStatus());
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return channelFeedListResponse;
}
Also used : ChannelFeedListResponse(com.applozic.mobicomkit.feed.ChannelFeedListResponse)

Aggregations

ChannelFeedListResponse (com.applozic.mobicomkit.feed.ChannelFeedListResponse)4 ChannelFeed (com.applozic.mobicomkit.feed.ChannelFeed)2 ErrorResponseFeed (com.applozic.mobicomkit.feed.ErrorResponseFeed)1 SyncChannelFeed (com.applozic.mobicomkit.sync.SyncChannelFeed)1 HashSet (java.util.HashSet)1