Search in sources :

Example 1 with InboxLinkConversation

use of com.waz.zclient.core.stores.connect.InboxLinkConversation in project wire-android by wireapp.

the class SecondPageFragment method onCurrentConversationHasChanged.

@Override
public void onCurrentConversationHasChanged(IConversation fromConversation, final IConversation toConversation, final ConversationChangeRequester conversationChangerSender) {
    if (selectedConversation != null) {
        selectedConversation.removeUpdateListener(this);
    }
    selectedConversation = null;
    if (toConversation == null) {
        return;
    }
    if (fromConversation != null && fromConversation.getId().equals(toConversation.getId())) {
        return;
    }
    selectedConversation = toConversation;
    selectedConversation.addUpdateListener(this);
    selectedConversationType = toConversation.getType();
    Timber.i("Conversation: %s type: %s requester: %s", toConversation, toConversation.getType(), conversationChangerSender);
    // either starting from beginning or switching fragment
    final boolean switchingToPendingConnectRequest = (toConversation.getType() == IConversation.Type.WAIT_FOR_CONNECTION);
    final boolean switchingToConnectRequestInbox = (toConversation instanceof InboxLinkConversation || toConversation.getId().equals(InboxLinkConversation.TAG) || toConversation.getType() == IConversation.Type.INCOMING_CONNECTION);
    // This must be posted because onCurrentConversationHasChanged()
    // might still be running and iterating over the observers -
    // while the posted call triggers things to register/unregister
    // from the list of observers, causing ConcurrentModificationException
    new Handler().post(new Runnable() {

        @Override
        public void run() {
            if (switchingToConnectRequestInbox) {
                Bundle arguments = new Bundle();
                arguments.putString(ARGUMENT_CONVERSATION_ID, toConversation.getId());
                openPage(Page.CONNECT_REQUEST_INBOX, arguments, conversationChangerSender);
            } else if (switchingToPendingConnectRequest) {
                Bundle arguments = new Bundle();
                arguments.putString(ARGUMENT_CONVERSATION_ID, toConversation.getId());
                openPage(Page.CONNECT_REQUEST_PENDING, arguments, conversationChangerSender);
            } else {
                openPage(Page.MESSAGE_STREAM, new Bundle(), conversationChangerSender);
            }
        }
    });
}
Also used : Bundle(android.os.Bundle) Handler(android.os.Handler) InboxLinkConversation(com.waz.zclient.core.stores.connect.InboxLinkConversation)

Example 2 with InboxLinkConversation

use of com.waz.zclient.core.stores.connect.InboxLinkConversation in project wire-android by wireapp.

the class ScalaConversationStore method setCurrentConversation.

@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);
    }
}
Also used : IConversation(com.waz.api.IConversation) InboxLinkConversation(com.waz.zclient.core.stores.connect.InboxLinkConversation)

Aggregations

InboxLinkConversation (com.waz.zclient.core.stores.connect.InboxLinkConversation)2 Bundle (android.os.Bundle)1 Handler (android.os.Handler)1 IConversation (com.waz.api.IConversation)1