use of com.applozic.mobicomkit.feed.ChannelFeedApiResponse in project Applozic-Android-SDK by AppLozic.
the class ConversationClientService method createConversation.
// Cleanup: default
public ChannelFeed createConversation(Conversation conversation) {
ChannelFeed channelFeed = null;
try {
String jsonFromObject = GsonUtils.getJsonFromObject(conversation, conversation.getClass());
String createChannelResponse = httpRequestUtils.postData(getCreateConversationUrl(), "application/json", "application/json", jsonFromObject);
Utils.printLog(context, TAG, "Create Conversation reponse:" + createChannelResponse);
ChannelFeedApiResponse channelFeedApiResponse = (ChannelFeedApiResponse) GsonUtils.getObjectFromJson(createChannelResponse, ChannelFeedApiResponse.class);
if (channelFeedApiResponse != null && channelFeedApiResponse.isSuccess()) {
channelFeed = channelFeedApiResponse.getResponse();
}
} catch (Exception e) {
e.printStackTrace();
}
return channelFeed;
}
use of com.applozic.mobicomkit.feed.ChannelFeedApiResponse in project Applozic-Android-SDK by AppLozic.
the class ContactSelectionFragment method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.Done) {
if (userIdList != null && userIdList.size() == 0) {
Toast.makeText(getActivity(), R.string.select_at_least, Toast.LENGTH_SHORT).show();
} else {
final ProgressDialog progressDialog = ProgressDialog.show(getActivity(), "", getActivity().getString(TextUtils.isEmpty(channelName) ? R.string.broadcast_creating_info : R.string.group_creating_info), true);
AlChannelCreateAsyncTask.TaskListenerInterface taskListenerInterface = new AlChannelCreateAsyncTask.TaskListenerInterface() {
@Override
public void onSuccess(Channel channel, Context context) {
if (progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
}
if (channel != null) {
Intent intent = new Intent(getActivity(), ConversationActivity.class);
if (ApplozicClient.getInstance(getActivity().getApplicationContext()).isContextBasedChat()) {
intent.putExtra(ConversationUIService.CONTEXT_BASED_CHAT, true);
}
intent.putExtra(ConversationUIService.GROUP_ID, channel.getKey());
intent.putExtra(ConversationUIService.GROUP_NAME, channel.getName());
getActivity().startActivity(intent);
}
if (bundle != null && bundle.getString(CHANNEL) != null) {
getActivity().sendBroadcast(new Intent(ChannelCreateActivity.ACTION_FINISH_CHANNEL_CREATE));
}
if (getActivity() != null) {
getActivity().finish();
}
}
@Override
public void onFailure(ChannelFeedApiResponse channelFeedApiResponse, Context context) {
if (progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
}
if (channelFeedApiResponse != null) {
List<ErrorResponseFeed> error = channelFeedApiResponse.getErrorResponse();
if (error != null && error.size() > 0) {
ErrorResponseFeed errorResponseFeed = error.get(0);
String errorDescription = errorResponseFeed.getDescription();
if (!TextUtils.isEmpty(errorDescription)) {
if (MobiComKitConstants.GROUP_USER_LIMIT_EXCEED.equalsIgnoreCase(errorDescription)) {
Toast.makeText(context, R.string.group_members_limit_exceeds, Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(context, R.string.applozic_server_error, Toast.LENGTH_SHORT).show();
}
}
}
} else {
Toast.makeText(context, Utils.isInternetAvailable(context) ? R.string.applozic_server_error : R.string.you_dont_have_any_network_access_info, Toast.LENGTH_SHORT).show();
}
}
};
if (userIdList != null && userIdList.size() > 0) {
if (TextUtils.isEmpty(channelName)) {
StringBuffer stringBuffer = new StringBuffer();
int i = 0;
for (String userId : userIdList) {
i++;
if (i > 10)
break;
Contact contactDisplayName = appContactService.getContactById(userId);
stringBuffer.append(contactDisplayName.getDisplayName()).append(",");
}
int lastIndex = stringBuffer.lastIndexOf(",");
channelName = stringBuffer.replace(lastIndex, lastIndex + 1, "").toString();
}
ChannelInfo channelInfo = new ChannelInfo(channelName, userIdList);
if (!TextUtils.isEmpty(imageUrl)) {
channelInfo.setImageUrl(imageUrl);
}
if (groupType == Channel.GroupType.BROADCAST.getValue()) {
channelInfo.setType(groupType);
} else if (alCustomizationSettings != null) {
channelInfo.setType(alCustomizationSettings.getDefaultGroupType());
} else {
channelInfo.setType(groupType);
}
if (MobiComUserPreference.getInstance(getActivity()).getParentGroupKey() != null && MobiComUserPreference.getInstance(getActivity()).getParentGroupKey() != 0) {
channelInfo.setParentKey(MobiComUserPreference.getInstance(getActivity()).getParentGroupKey());
}
AlChannelCreateAsyncTask alChannelCreateAsyncTask = new AlChannelCreateAsyncTask(getActivity(), channelInfo, taskListenerInterface);
AlTask.execute(alChannelCreateAsyncTask);
}
}
return true;
}
return false;
}
use of com.applozic.mobicomkit.feed.ChannelFeedApiResponse in project Applozic-Android-SDK by AppLozic.
the class ChannelClientService method getMembersFromContactGroupOfType.
/**
* Sends a request to get the contacts for a group, identified by it's contactGroupId and groupType.
*
* <p>Contacts for a user can be grouped together. Such a group is called a contact group.</p>
*
* @param contactGroupId the contact group id
* @param groupType the group type
* @return {@link ChannelFeed}. User {@link ChannelFeed#getGroupUsers()} to get the contacts.
*/
@Nullable
public ChannelFeed getMembersFromContactGroupOfType(@Nullable String contactGroupId, @Nullable 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;
}
use of com.applozic.mobicomkit.feed.ChannelFeedApiResponse in project Applozic-Android-SDK by AppLozic.
the class ChannelClientService method createChannel.
// Cleanup: default
@Deprecated
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;
}
use of com.applozic.mobicomkit.feed.ChannelFeedApiResponse in project Applozic-Android-SDK by AppLozic.
the class ChannelService method createGroupOfTwo.
/**
* @deprecated Use {@link #createGroupOfTwoWithResponse(ChannelInfo)} instead.
*/
@Deprecated
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;
}
Aggregations