use of com.applozic.mobicomkit.feed.ErrorResponseFeed 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;
}
use of com.applozic.mobicomkit.feed.ErrorResponseFeed 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