public void updateChat() { ContactTitleInflater.updateTitle(contactTitleView, getActivity(), abstractContact); toolbar.setBackgroundColor(accountPainter.getAccountMainColor(account)); int itemCountBeforeUpdate = chatMessageAdapter.getItemCount(); chatMessageAdapter.onChange(); scrollChat(itemCountBeforeUpdate); setUpOptionsMenu(toolbar.getMenu()); updateSecurityButton(); }
@Override public void onMessageClick(View caller, int position) { int itemViewType = chatMessageAdapter.getItemViewType(position); if (itemViewType == ChatMessageAdapter.VIEW_TYPE_INCOMING_MESSAGE || itemViewType == ChatMessageAdapter.VIEW_TYPE_OUTGOING_MESSAGE) { clickedMessageItem = chatMessageAdapter.getMessageItem(position); PopupMenu popup = new PopupMenu(getActivity(), caller); popup.inflate(R.menu.chat_context_menu); popup.setOnMenuItemClickListener(this); final Menu menu = popup.getMenu(); if (clickedMessageItem.isError()) { menu.findItem(R.id.action_message_repeat).setVisible(true); } if (clickedMessageItem.isUploadFileMessage()) { menu.findItem(R.id.action_message_copy).setVisible(false); menu.findItem(R.id.action_message_quote).setVisible(false); menu.findItem(R.id.action_message_remove).setVisible(false); } final File file = clickedMessageItem.getFile(); if (file != null && file.exists()) { menu.findItem(R.id.action_message_open_file).setVisible(true); menu.findItem(R.id.action_message_save_file).setVisible(true); } if (clickedMessageItem.isIncoming() && MUCManager.getInstance().hasRoom(account, user)) { menu.findItem(R.id.action_message_open_muc_private_chat).setVisible(true); } popup.show(); } }
private void scrollDown() { recyclerView.scrollToPosition(chatMessageAdapter.getItemCount() - 1); }