use of com.applozic.mobicomkit.feed.ChannelFeedApiResponse in project Applozic-Android-SDK by AppLozic.
the class ChannelService method createGroupOfTwoWithResponse.
/**
* Internal. Group-of-two channels are implemented in the UI. You will not need them.
*
* <p>Create a {@link Channel.GroupType#GROUPOFTWO} channel.</p>
*
* <p>A group-of-two type channel is implemented in the UI to look like a 1-to-1 chat.
* It is meant to have two members only.</p>
*
* @param channelInfo the channel info that will be used to create the channel
* @return the {@link AlResponse} from the server
*/
public AlResponse createGroupOfTwoWithResponse(ChannelInfo channelInfo) {
if (channelInfo == null) {
return null;
}
AlResponse alResponse = new AlResponse();
if (!TextUtils.isEmpty(channelInfo.getClientGroupId())) {
Channel channel = channelDatabaseService.getChannelByClientGroupId(channelInfo.getClientGroupId());
if (channel != null) {
alResponse.setStatus(AlResponse.SUCCESS);
alResponse.setResponse(channel);
} else {
ChannelFeedApiResponse channelFeedApiResponse = channelClientService.createChannelWithResponse(channelInfo);
if (channelFeedApiResponse == null) {
alResponse.setStatus(AlResponse.ERROR);
} else {
if (channelFeedApiResponse.isSuccess()) {
ChannelFeed channelFeed = channelFeedApiResponse.getResponse();
if (channelFeed != null) {
ChannelFeed[] channelFeeds = new ChannelFeed[1];
channelFeeds[0] = channelFeed;
processChannelFeedList(channelFeeds, true);
alResponse.setStatus(AlResponse.SUCCESS);
alResponse.setResponse(getChannel(channelFeed));
}
} else {
ChannelFeed channelFeed = channelClientService.getChannelInfo(channelInfo.getClientGroupId());
if (channelFeed != null) {
ChannelFeed[] channelFeeds = new ChannelFeed[1];
channelFeeds[0] = channelFeed;
processChannelFeedList(channelFeeds, false);
alResponse.setStatus(AlResponse.SUCCESS);
alResponse.setResponse(getChannel(channelFeed));
}
}
}
}
}
return alResponse;
}
use of com.applozic.mobicomkit.feed.ChannelFeedApiResponse in project Applozic-Android-SDK by AppLozic.
the class ChannelService method createChannelWithResponse.
/**
* Creates a new {@link Channel}.
*
* <p>This method will block the main thread. Run it asynchronously.</p>
*
* @param channelInfo contains the parameters/details for the creating the channel
* @return The response object. Pass {@link ChannelFeedApiResponse#getResponse()} to {@link ChannelService#getChannel(ChannelFeed)} to get your newly created <i>channel</i> object.
*/
@Nullable
public ChannelFeedApiResponse createChannelWithResponse(@NonNull ChannelInfo channelInfo) {
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 channelFeedApiResponse;
}
use of com.applozic.mobicomkit.feed.ChannelFeedApiResponse in project Applozic-Android-SDK by AppLozic.
the class ChannelService method createChannel.
/**
* @deprecated {@link AlResponse} is not longer used. It will be replaced by {@link ApiResponse}.
*
* Use {@link ChannelService#createChannelWithResponse(ChannelInfo)} instead.
*/
@Deprecated
public synchronized AlResponse createChannel(final ChannelInfo channelInfo) {
if (channelInfo == null) {
return null;
}
AlResponse alResponse = new AlResponse();
ChannelFeedApiResponse channelFeedResponse = null;
try {
channelFeedResponse = channelClientService.createChannelWithResponse(channelInfo);
if (channelFeedResponse == null) {
return null;
}
if (channelFeedResponse.isSuccess()) {
alResponse.setStatus(AlResponse.SUCCESS);
ChannelFeed channelFeed = channelFeedResponse.getResponse();
if (channelFeed != null) {
ChannelFeed[] channelFeeds = new ChannelFeed[1];
channelFeeds[0] = channelFeed;
processChannelFeedList(channelFeeds, true);
alResponse.setResponse(getChannel(channelFeed));
}
} else {
alResponse.setStatus(AlResponse.ERROR);
alResponse.setResponse(channelFeedResponse.getErrorResponse());
}
} catch (Exception e) {
alResponse.setStatus(AlResponse.ERROR);
alResponse.setException(e);
}
return alResponse;
}
Aggregations