use of com.applozic.mobicomkit.api.people.ChannelInfo in project Applozic-Android-SDK by AppLozic.
the class ChannelClientService method createMultipleChannels.
public List<ChannelFeed> createMultipleChannels(List<ChannelInfo> channels) {
List<ChannelFeed> channelFeeds = null;
try {
String jsonFromObject = GsonUtils.getJsonFromObject(channels, new TypeToken<List<ChannelInfo>>() {
}.getType());
String createChannelResponse = httpRequestUtils.postData(getCreateMultipleChannelUrl(), "application/json", "application/json", jsonFromObject);
Utils.printLog(context, TAG, "Create Multiple channel Response :" + createChannelResponse);
MultipleChannelFeedApiResponse channelFeedApiResponse = (MultipleChannelFeedApiResponse) GsonUtils.getObjectFromJson(createChannelResponse, MultipleChannelFeedApiResponse.class);
if (channelFeedApiResponse != null && channelFeedApiResponse.isSuccess()) {
channelFeeds = channelFeedApiResponse.getResponse();
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
return channelFeeds;
}
use of com.applozic.mobicomkit.api.people.ChannelInfo in project Applozic-Android-SDK by AppLozic.
the class ApplozicChannelCreateTask method doInBackground.
@Override
protected Boolean doInBackground(Void... params) {
try {
if (!TextUtils.isEmpty(groupName) && groupName.trim().length() != 0 && groupMemberList != null && groupMemberList.size() > 0) {
channelInfo = new ChannelInfo(groupName.trim(), groupMemberList, groupImageLink);
if (!TextUtils.isEmpty(clientGroupId)) {
channelInfo.setClientGroupId(clientGroupId);
}
channelInfo.setType(type);
channel = channelService.createChannel(channelInfo);
return channel != null;
}
return false;
} catch (Exception e) {
e.printStackTrace();
exception = e;
return false;
}
}
use of com.applozic.mobicomkit.api.people.ChannelInfo 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);
}
AlChannelCreateAsyncTask alChannelCreateAsyncTask = new AlChannelCreateAsyncTask(getActivity(), channelInfo, taskListenerInterface);
alChannelCreateAsyncTask.execute((Void) null);
}
}
return true;
}
return false;
}
Aggregations