Search in sources :

Example 1 with ChannelInfo

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;
}
Also used : TypeToken(com.google.gson.reflect.TypeToken) ChannelInfo(com.applozic.mobicomkit.api.people.ChannelInfo) SyncChannelFeed(com.applozic.mobicomkit.sync.SyncChannelFeed) ChannelFeed(com.applozic.mobicomkit.feed.ChannelFeed) MultipleChannelFeedApiResponse(com.applozic.mobicomkit.MultipleChannelFeedApiResponse)

Example 2 with ChannelInfo

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;
    }
}
Also used : ChannelInfo(com.applozic.mobicomkit.api.people.ChannelInfo)

Example 3 with ChannelInfo

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;
}
Also used : Context(android.content.Context) ErrorResponseFeed(com.applozic.mobicomkit.feed.ErrorResponseFeed) Channel(com.applozic.mobicommons.people.channel.Channel) Intent(android.content.Intent) ChannelInfo(com.applozic.mobicomkit.api.people.ChannelInfo) SpannableString(android.text.SpannableString) ProgressDialog(android.app.ProgressDialog) SuppressLint(android.annotation.SuppressLint) ChannelFeedApiResponse(com.applozic.mobicomkit.feed.ChannelFeedApiResponse) Contact(com.applozic.mobicommons.people.contact.Contact) AlChannelCreateAsyncTask(com.applozic.mobicomkit.uiwidgets.async.AlChannelCreateAsyncTask)

Aggregations

ChannelInfo (com.applozic.mobicomkit.api.people.ChannelInfo)3 SuppressLint (android.annotation.SuppressLint)1 ProgressDialog (android.app.ProgressDialog)1 Context (android.content.Context)1 Intent (android.content.Intent)1 SpannableString (android.text.SpannableString)1 MultipleChannelFeedApiResponse (com.applozic.mobicomkit.MultipleChannelFeedApiResponse)1 ChannelFeed (com.applozic.mobicomkit.feed.ChannelFeed)1 ChannelFeedApiResponse (com.applozic.mobicomkit.feed.ChannelFeedApiResponse)1 ErrorResponseFeed (com.applozic.mobicomkit.feed.ErrorResponseFeed)1 SyncChannelFeed (com.applozic.mobicomkit.sync.SyncChannelFeed)1 AlChannelCreateAsyncTask (com.applozic.mobicomkit.uiwidgets.async.AlChannelCreateAsyncTask)1 Channel (com.applozic.mobicommons.people.channel.Channel)1 Contact (com.applozic.mobicommons.people.contact.Contact)1 TypeToken (com.google.gson.reflect.TypeToken)1