@Override
  public void onOptionsItemClicked(IConversation conversation, User user, OptionsMenuItem item) {
    switch (item) {
      case BLOCK:
        showBlockUserConfirmation(user);
        break;
      case UNBLOCK:
        user.unblock();
        break;
      case ARCHIVE:
        getStoreFactory().getConversationStore().archive(conversation, true);
        getControllerFactory()
            .getTrackingController()
            .tagEvent(new ArchivedConversationEvent(conversation.getType().toString()));
        break;
      case UNARCHIVE:
        getStoreFactory().getConversationStore().archive(conversation, false);
        getControllerFactory()
            .getTrackingController()
            .tagEvent(new UnarchivedConversationEvent(conversation.getType().toString()));
        break;
      case SILENCE:
        conversation.setMuted(true);
        break;
      case UNSILENCE:
        conversation.setMuted(false);
        break;
    }

    optionsMenuControl.close();
  }
 private boolean isPendingIncomingConnectRequest(IConversation conversation) {
   if (conversation.isMe() || conversation.getType() == IConversation.Type.GROUP) {
     return false;
   }
   if (conversation.getType() == IConversation.Type.INCOMING_CONNECTION) {
     return true;
   }
   return false;
 }
  private void identifyCurrentConversation(IConversation previousSelectedConversation) {
    if (selectedConversation == null) {
      if (previousSelectedConversation != null
          && previousSelectedConversation.getType() == IConversation.Type.INCOMING_CONNECTION) {
        // Switch to another incoming connect request.
        // Previous (ignored) conversation might still be included in list of incoming
        // conversations, find another one
        for (int i = 0; i < inboxList.size(); i++) {
          IConversation incomingConnectRequest = inboxList.get(i);
          if (!incomingConnectRequest.getId().equals(previousSelectedConversation.getId())) {
            setCurrentConversation(incomingConnectRequest, ConversationChangeRequester.FIRST_LOAD);
            return;
          }
        }
      }

      // TODO: AN-2974
      if (conversationsList.size() > 0) {
        setCurrentConversation(conversationsList.get(0), ConversationChangeRequester.FIRST_LOAD);
        return;
      }
    }

    setCurrentConversation(selectedConversation, ConversationChangeRequester.FIRST_LOAD);
  }
 @Override
 public void onConversationLoaded(IConversation conversation) {
   IConversation.Type newIncomingMessageConversationType = conversation.getType();
   if (currentNextMessageConversationType != IConversation.Type.ONE_TO_ONE
       || newIncomingMessageConversationType != IConversation.Type.GROUP) {
     currentNextMessage = newIncomingMessage;
   }
 }
 @Override
 public void onConversationLoaded(IConversation conversation) {
   currentNextMessageConversationType = conversation.getType();
   getStoreFactory()
       .getConversationStore()
       .loadConversation(
           newIncomingMessage.getConversation().getId(), newMessageConversationListener);
 }
 @Override
 public void onConversationUpdated(IConversation conversation) {
   if (conversation != null && conversation.getType() == IConversation.Type.ONE_TO_ONE) {
     getContainer().onAcceptedPendingOutgoingConnectRequest(conversation);
   }
 }