public Channel getChannel(Cursor cursor) { Channel channel = new Channel(); channel.setKey(cursor.getInt(cursor.getColumnIndex(MobiComDatabaseHelper.CHANNEL_KEY))); channel.setParentClientGroupId(cursor.getString(cursor.getColumnIndex(MobiComDatabaseHelper.PARENT_CLIENT_GROUP_ID))); channel.setClientGroupId(cursor.getString(cursor.getColumnIndex(MobiComDatabaseHelper.CLIENT_GROUP_ID))); channel.setName(cursor.getString(cursor.getColumnIndex(MobiComDatabaseHelper.CHANNEL_DISPLAY_NAME))); channel.setAdminKey(cursor.getString(cursor.getColumnIndex(MobiComDatabaseHelper.ADMIN_ID))); channel.setType(cursor.getShort(cursor.getColumnIndex(MobiComDatabaseHelper.TYPE))); channel.setImageUrl(cursor.getString(cursor.getColumnIndex(MobiComDatabaseHelper.CHANNEL_IMAGE_URL))); channel.setLocalImageUri(cursor.getString(cursor.getColumnIndex(MobiComDatabaseHelper.CHANNEL_IMAGE_LOCAL_URI))); int count = cursor.getInt(cursor.getColumnIndex(MobiComDatabaseHelper.UNREAD_COUNT)); channel.setNotificationAfterTime(cursor.getLong(cursor.getColumnIndex(MobiComDatabaseHelper.NOTIFICATION_AFTER_TIME))); channel.setDeletedAtTime(cursor.getLong(cursor.getColumnIndex(MobiComDatabaseHelper.DELETED_AT))); channel.setParentKey(cursor.getInt(cursor.getColumnIndex(MobiComDatabaseHelper.PARENT_GROUP_KEY))); String metadata = cursor.getString(cursor.getColumnIndex(MobiComDatabaseHelper.CHANNEL_META_DATA)); channel.setMetadata(((Map<String, String>) GsonUtils.getObjectFromJson(metadata, Map.class))); if (count > 0) { channel.setUnreadCount(count); } return channel; }
public ContentValues prepareChannelValues(Channel channel) { ContentValues contentValues = new ContentValues(); contentValues.put(MobiComDatabaseHelper.CHANNEL_DISPLAY_NAME, channel.getName()); contentValues.put(MobiComDatabaseHelper.CHANNEL_KEY, channel.getKey()); contentValues.put(MobiComDatabaseHelper.CLIENT_GROUP_ID, channel.getClientGroupId()); contentValues.put(MobiComDatabaseHelper.TYPE, channel.getType()); contentValues.put(MobiComDatabaseHelper.NOTIFICATION_AFTER_TIME, channel.getNotificationAfterTime()); contentValues.put(MobiComDatabaseHelper.DELETED_AT, channel.getDeletedAtTime()); contentValues.put(MobiComDatabaseHelper.ADMIN_ID, channel.getAdminKey()); Channel oldChannel = null; if (!TextUtils.isEmpty(channel.getImageUrl())) { contentValues.put(MobiComDatabaseHelper.CHANNEL_IMAGE_URL, channel.getImageUrl()); oldChannel = ChannelDatabaseService.getInstance(context).getChannelByChannelKey(channel.getKey()); if (oldChannel != null && !TextUtils.isEmpty(channel.getImageUrl()) && !TextUtils.isEmpty(oldChannel.getImageUrl()) && !channel.getImageUrl().equals(oldChannel.getImageUrl())) { updateChannelLocalImageURI(channel.getKey(), null); if (!TextUtils.isEmpty(channel.getLocalImageUri())) { contentValues.put(MobiComDatabaseHelper.CHANNEL_IMAGE_LOCAL_URI, channel.getLocalImageUri()); if (channel.getUserCount() != 0) { contentValues.put(MobiComDatabaseHelper.USER_COUNT, channel.getUserCount()); if (channel.getUnreadCount() != 0) { contentValues.put(MobiComDatabaseHelper.UNREAD_COUNT, channel.getUnreadCount()); if (channel.getMetadata() != null) { contentValues.put(MobiComDatabaseHelper.CHANNEL_META_DATA, GsonUtils.getJsonFromObject(channel.getMetadata(), Map.class)); if(channel.getMetadata().containsKey(Channel.AL_CATEGORY)){ contentValues.put(MobiComDatabaseHelper.AL_CATEGORY, channel.getMetadata().get(Channel.AL_CATEGORY));
public GroupInfoUpdate(Channel channel) { this.newName = channel.getName(); this.groupId = channel.getKey(); this.clientGroupId = channel.getClientGroupId(); this.imageUrl = channel.getImageUrl(); this.localImagePath = channel.getLocalImageUri(); }
public static String getChannelTitleName(Channel channel, String loggedInUserId) { if (!TextUtils.isEmpty(loggedInUserId)) { if (Channel.GroupType.SELLER.getValue().equals(channel.getType())) { String[] userIdSplit = new String[1]; if (!TextUtils.isEmpty(channel.getName())) { userIdSplit = channel.getName().split(":"); } if (loggedInUserId.equals(channel.getAdminKey())) { return channel.getName(); } else { return userIdSplit[0]; } } else { return channel.getName(); } } return ""; }
String name = ""; if (channel != null) { if (Channel.GroupType.GROUPOFTWO.getValue().equals(channel.getType())) { String userId = ChannelService.getInstance(context).getGroupOfTwoReceiverUserId(channel.getKey()); if (!TextUtils.isEmpty(userId)) { Contact withUserContact = contactService.getContactById(userId);
public void deleteChannel(final Channel channel) { AlertDialog.Builder alertDialog = new AlertDialog.Builder(this). setPositiveButton(R.string.channel_deleting, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { new ChannelMemberAdd(channel, ChannelInfoActivity.this).execute(); } }); alertDialog.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }); if (channel.getType() != null) { alertDialog.setMessage(getString(R.string.delete_channel_messages_and_channel_info).replace(getString(R.string.group_name_info), channel.getName()).replace(getString(R.string.groupType_info), Channel.GroupType.BROADCAST.getValue().equals(channel.getType()) ? getString(R.string.broadcast_string) : getString(R.string.group_string))); } alertDialog.setCancelable(true); alertDialog.create().show(); }
public Channel getChannel(ChannelFeed channelFeed) { Channel channel = new Channel(channelFeed.getId(), channelFeed.getName(), channelFeed .getAdminName(), channelFeed.getType(), channelFeed.getUnreadCount(), channelFeed .getImageUrl()); channel.setClientGroupId(channelFeed.getClientGroupId()); channel.setNotificationAfterTime(channelFeed.getNotificationAfterTime()); channel.setDeletedAtTime(channelFeed.getDeletedAtTime()); channel.setMetadata(channelFeed.getMetadata()); channel.setParentKey(channelFeed.getParentKey()); channel.setParentClientGroupId(channelFeed.getParentClientGroupId()); return channel; }
public void updateChannelTitle() { if (!Channel.GroupType.GROUPOFTWO.getValue().equals(channel.getType())) { Channel newChannel = ChannelService.getInstance(getActivity()).getChannelByChannelKey(channel.getKey()); if (newChannel != null && !TextUtils.isEmpty(channel.getName()) && !channel.getName().equals(newChannel.getName())) { title = ChannelUtils.getChannelTitleName(newChannel, MobiComUserPreference.getInstance(getActivity()).getUserId()); channel = newChannel; if (getActivity() != null) { setToolbarTitle(title); } } } }
public void updateChannelTitleAndSubTitle() { if (channel != null) { Channel channelInfo = ChannelService.getInstance(getActivity()).getChannelInfo(channel.getKey()); if (channelInfo.isDeleted()) { channel.setDeletedAtTime(channelInfo.getDeletedAtTime()); individualMessageSendLayout.setVisibility(View.GONE); userNotAbleToChatLayout.setVisibility(VISIBLE); userNotAbleToChatTextView.setText(R.string.group_has_been_deleted_text); if (channel != null && !ChannelService.getInstance(getContext()).isUserAlreadyPresentInChannel(channel.getKey(), MobiComUserPreference.getInstance(getContext()).getUserId()) && messageTemplate != null && messageTemplate.isEnabled() && templateAdapter != null) { templateAdapter.removeTemplates(); if ((!ChannelService.getInstance(getActivity()).processIsUserPresentInChannel(channel.getKey()) && userNotAbleToChatLayout != null && !Channel.GroupType.OPEN.getValue().equals(channel.getType()))) { templateAdapter.removeTemplates(); } else if (ChannelService.getInstance(getActivity()).processIsUserPresentInChannel(channel.getKey()) && userNotAbleToChatLayout != null && !Channel.GroupType.OPEN.getValue().equals(channel.getType())) { individualMessageSendLayout.setVisibility(View.VISIBLE); userNotAbleToChatLayout.setVisibility(View.GONE);
public void leaveChannel(final Channel channel) { AlertDialog.Builder alertDialog = new AlertDialog.Builder(this). setPositiveButton(R.string.channel_exit, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { new ChannelAsync(channel, ChannelInfoActivity.this).execute(); } }); alertDialog.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }); if (channel.getType() != null) { alertDialog.setMessage(getString(R.string.leave_channel).replace(getString(R.string.groupType_info), Channel.GroupType.BROADCAST.getValue().equals(channel.getType()) ? getString(R.string.broadcast_string) : getString(R.string.group_string))); } alertDialog.setCancelable(true); alertDialog.create().show(); }
public boolean getCurrentChannelKey(Integer channelKey) { return channel != null && channel.getKey().equals(channelKey); }
public void updateContextBasedGroup() { if (channel != null) { Channel channelInfo = ChannelService.getInstance(getActivity()).getChannelInfo(channel.getKey()); if ((Channel.GroupType.GROUPOFTWO.getValue().equals(channelInfo.getType())) && channel.isContextBasedChat()) { Conversation conversation = new Conversation(); TopicDetail topic = new TopicDetail(); topic.setTitle(channelInfo.getMetadata().get(Channel.GroupMetaDataType.TITLE.getValue())); topic.setSubtitle(channelInfo.getMetadata().get(Channel.GroupMetaDataType.PRICE.getValue())); topic.setLink(channelInfo.getMetadata().get(Channel.GroupMetaDataType.LINK.getValue())); conversation.setTopicDetail(topic.getJson()); conversationList.get(0).setTopicDetail(topic.getJson()); applozicContextSpinnerAdapter.notifyDataSetChanged(); } } }
@Override public Bitmap downloadGroupImage(Context context, Channel channel) { if (channel != null && TextUtils.isEmpty(channel.getImageUrl())) { return null; } Bitmap attachedImage = ImageUtils.getBitMapFromLocalPath(channel.getLocalImageUri()); if (attachedImage != null) { return attachedImage; } Bitmap bitmap = fileClientService.downloadBitmap(null, channel); if (bitmap != null) { File file = FileClientService.getFilePath(String.valueOf(channel.getKey()), context.getApplicationContext(), "image", true); String imageLocalPath = ImageUtils.saveImageToInternalStorage(file, bitmap); channel.setLocalImageUri(imageLocalPath); } if (!TextUtils.isEmpty(channel.getLocalImageUri())) { ChannelService.getInstance(context).updateChannelLocalImageURI(channel.getKey(), channel.getLocalImageUri()); } return bitmap; }
if (channel != null) { String title = ChannelUtils.getChannelTitleName(channel, userPreference.getUserId()); if (!TextUtils.isEmpty(channel.getAdminKey())) { contact = baseContactService.getContactById(channel.getAdminKey()); mActionBar.setTitle(title); if (userPreference.getUserId().equals(contact.getUserId())) { if (channel != null && channel.getType() != null) { if (Channel.GroupType.BROADCAST.getValue().equals(channel.getType())) { deleteChannelButton.setText(R.string.broadcast_delete_button); exitChannelButton.setText(R.string.broadcast_exit_button); channelImageLoader.setImageFadeIn(false); if (channelImage != null && !channel.isBroadcastMessage()) { channelImageLoader.loadImage(channel, channelImage); } else { channelUserMapperList = ChannelService.getInstance(this).getListOfUsersFromChannelUserMapper(channel.getKey());
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { int position = this.getLayoutPosition(); if (mItems.size() <= position) { return; } Message message = mItems.get(position); menu.setHeaderTitle(R.string.conversation_options); String[] menuItems = context.getResources().getStringArray(R.array.conversation_options_menu); properties.setMessage(message); boolean isChannelDeleted = properties.getChannel() != null && properties.getChannel().isDeleted(); boolean isUserPresentInGroup = properties.getChannel() != null && ChannelService.getInstance(context).processIsUserPresentInChannel(properties.getChannel().getKey()); for (int i = 0; i < menuItems.length; i++) { if ((message.getGroupId() == null || (properties.getChannel() != null && (Channel.GroupType.GROUPOFTWO.getValue().equals(properties.getChannel().getType()) || Channel.GroupType.SUPPORT_GROUP.getValue().equals(properties.getChannel().getType())))) && (menuItems[i].equals(context.getResources().getString(R.string.delete_group)) || menuItems[i].equals(context.getResources().getString(R.string.exit_group)))) { continue; } if (menuItems[i].equals(context.getResources().getString(R.string.exit_group)) && (isChannelDeleted || !isUserPresentInGroup)) { continue; } if (menuItems[i].equals(context.getResources().getString(R.string.delete_group)) && (isUserPresentInGroup || !isChannelDeleted)) { continue; } if (menuItems[i].equals(context.getResources().getString(R.string.delete_conversation))) { continue; } MenuItem item = menu.add(Menu.NONE, i, i, menuItems[i]); item.setOnMenuItemClickListener(onEditMenu); } }
processContactImage(contactReceiver, myholder.onlineTextView, myholder.alphabeticTextView, myholder.contactImage); } else if (message.getGroupId() != null) { if (channel != null && Channel.GroupType.GROUPOFTWO.getValue().equals(channel.getType())) { contactImageLoader.setLoadingImage(R.drawable.applozic_ic_contact_picture_holo_light); if (Channel.GroupType.GROUPOFTWO.getValue().equals(channel.getType())) { Contact withUserContact = contactService.getContactById(ChannelService.getInstance(context).getGroupOfTwoReceiverUserId(channel.getKey())); if (withUserContact != null) { myholder.smReceivers.setText(withUserContact.getDisplayName()); if (channel != null && Channel.GroupType.SUPPORT_GROUP.getValue().equals(channel.getType())) { channelImageLoader.setLoadingImage(R.drawable.applozic_ic_contact_picture_holo_light); myholder.contactImage.setImageResource(R.drawable.applozic_ic_contact_picture_holo_light); myholder.contactImage.setVisibility(View.VISIBLE); if (channel != null && !TextUtils.isEmpty(channel.getImageUrl())) { channelImageLoader.loadImage(channel, myholder.contactImage); } else if (channel != null && channel.isBroadcastMessage()) { myholder.contactImage.setImageResource(R.drawable.applozic_ic_applozic_broadcast); } else if (channel != null && Channel.GroupType.SUPPORT_GROUP.getValue().equals(channel.getType())) { channelImageLoader.setLoadingImage(R.drawable.applozic_ic_contact_picture_holo_light); } else { messageUnReadCount = messageDatabaseService.getUnreadMessageCountForContact(contactReceiver.getContactIds()); } else if (channel != null && channel.getKey() != null && channel.getKey() != 0) { messageUnReadCount = messageDatabaseService.getUnreadMessageCountForChannel(channel.getKey());
messageToSend.setGroupId(channel.getKey()); if (!TextUtils.isEmpty(channel.getClientGroupId())) { messageToSend.setClientGroupId(channel.getClientGroupId()); if (channel != null && channel.getType() != null && Channel.GroupType.BROADCAST_ONE_BY_ONE.getValue().equals(channel.getType())) { sendBroadcastMessage(message, filePath);
if (channel != null && !TextUtils.isEmpty(channelName) && TextUtils.isEmpty(channel.getName())) { channel.setName(channelName); ChannelService.getInstance(fragmentActivity).updateChannel(channel); if (message.getGroupId() != null) { channel = ChannelService.getInstance(fragmentActivity).getChannelByChannelKey(message.getGroupId()); if (channel.getParentKey() != null && channel.getParentKey() != 0) { BroadcastService.parentGroupKey = channel.getParentKey(); MobiComUserPreference.getInstance(fragmentActivity).setParentGroupKey(channel.getParentKey());
public static String getWithUserId(Channel channel, String loggedInUserId) { try { if (Channel.GroupType.GROUPOFTWO.getValue().equals(channel.getType())) { String[] userIdSplit = new String[2]; if (!TextUtils.isEmpty(channel.getClientGroupId())) { userIdSplit = channel.getClientGroupId().split(":"); String userId1 = userIdSplit[1]; String userId2 = userIdSplit[2]; if (!loggedInUserId.equals(userId2)) { return userId2; } else if (!loggedInUserId.equals(userId1)) { return userId1; } } } } catch (Exception e) { Log.i("ChannelUtils", "Got exception in Group of two"); } return ""; }