@Override public void archive(IConversation conversation, boolean archive) { if (conversation.isSelected()) { final IConversation nextConversation = getNextConversation(); if (nextConversation != null) { // don't want to change selected item immediately new Handler() .postDelayed( new Runnable() { @Override public void run() { if (conversationsList != null) { setCurrentConversation( nextConversation, ConversationChangeRequester.ARCHIVED_RESULT); } } }, ARCHIVE_DELAY); } } conversation.setArchived(archive); // Set current conversation to unarchived if (!archive) { setCurrentConversation( conversation, ConversationChangeRequester.CONVERSATION_LIST_UNARCHIVED_CONVERSATION); } }
@Override public void setCurrentConversation( IConversation conversation, ConversationChangeRequester conversationChangerSender) { if (conversation instanceof InboxLinkConversation) { conversation = inboxList.get(0); } if (conversation != null) { conversation.setArchived(false); } if (conversation != null) { Timber.i( "Set current conversation to %s, requester %s", conversation.getName(), conversationChangerSender); } else { Timber.i("Set current conversation to null, requester %s", conversationChangerSender); } this.conversationChangeRequester = conversationChangerSender; IConversation oldConversation = conversationChangerSender == ConversationChangeRequester.FIRST_LOAD ? null : selectedConversation; conversationsList.setSelectedConversation(conversation); if (oldConversation == null || (oldConversation != null && conversation != null && oldConversation.getId().equals(conversation.getId()))) { // Notify explicitly if the conversation doesn't change, the UiSginal notifies only when the // conversation changes notifyCurrentConversationHasChanged(oldConversation, conversation, conversationChangerSender); } }