@Override public void bindConversationViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof ConversationViewHolder) { Message message = mItems.get(position); messageProperties.setMessage(message); ConversationViewHolder mHolder = (ConversationViewHolder) holder; mHolder.receiverName.setText(messageProperties.getReceiver()); mHolder.createdAtTime.setText(messageProperties.getCreatedAtTime()); messageProperties.setMessageAndAttchmentIcon(mHolder.messageTv, mHolder.attachmentIcon); messageProperties.setUnreadCount(mHolder.unreadCount); messageProperties.loadProfileImage(mHolder.profileImage, mHolder.alphabeticImage); } }
@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); } }