Search in sources :

Example 6 with NetworkAction

use of com.waz.zclient.core.stores.network.NetworkAction in project wire-android by wireapp.

the class ParticipantBodyFragment method conversationUpdated.

@Override
public void conversationUpdated(final IConversation conversation) {
    footerMenu.setVisibility(View.VISIBLE);
    if (conversation.getType() == IConversation.Type.ONE_TO_ONE) {
        footerMenu.setLeftActionText(getString(R.string.glyph__plus));
        topBorder.setVisibility(View.INVISIBLE);
        footerMenu.setRightActionText(getString(R.string.glyph__more));
        getStoreFactory().getSingleParticipantStore().setUser(conversation.getOtherParticipant());
    } else {
        imageAssetImageView.setVisibility(View.GONE);
        // Check if self user is member for group conversation
        if (conversation.isMemberOfConversation()) {
            footerMenu.setLeftActionText(getString(R.string.glyph__add_people));
            footerMenu.setRightActionText(getString(R.string.glyph__more));
            footerMenu.setLeftActionLabelText(getString(R.string.conversation__action__add_people));
        } else {
            footerMenu.setLeftActionText("");
            footerMenu.setRightActionText("");
            footerMenu.setLeftActionLabelText("");
        }
        if (lastParticipantAboveFooter()) {
            topBorder.setVisibility(View.INVISIBLE);
        } else {
            topBorder.setVisibility(View.VISIBLE);
        }
    }
    footerMenu.setCallback(new FooterMenuCallback() {

        @Override
        public void onLeftActionClicked() {
            if (userRequester == IConnectStore.UserRequester.POPOVER) {
                final User user = getStoreFactory().getSingleParticipantStore().getUser();
                if (user.isMe()) {
                    getControllerFactory().getConversationScreenController().hideParticipants(true, false);
                    // Go to conversation with this user
                    getControllerFactory().getPickUserController().hidePickUserWithoutAnimations(getContainer().getCurrentPickerDestination());
                    getStoreFactory().getConversationStore().setCurrentConversation(user.getConversation(), ConversationChangeRequester.START_CONVERSATION);
                    return;
                }
            }
            if (!conversation.isMemberOfConversation()) {
                return;
            }
            ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new OpenedGroupActionEvent());
            getControllerFactory().getConversationScreenController().addPeopleToConversation();
        }

        @Override
        public void onRightActionClicked() {
            getStoreFactory().getNetworkStore().doIfHasInternetOrNotifyUser(new NetworkAction() {

                @Override
                public void execute(NetworkMode networkMode) {
                    if (!conversation.isMemberOfConversation()) {
                        return;
                    }
                    if (userRequester == IConnectStore.UserRequester.POPOVER) {
                        User otherUser = conversation.getOtherParticipant();
                        getContainer().toggleBlockUser(otherUser, otherUser.getConnectionStatus() != User.ConnectionStatus.BLOCKED);
                    } else {
                        getControllerFactory().getConversationScreenController().showConversationMenu(IConversationScreenController.CONVERSATION_DETAILS, conversation, null);
                    }
                }

                @Override
                public void onNoNetwork() {
                    ViewUtils.showAlertDialog(getActivity(), R.string.alert_dialog__no_network__header, R.string.leave_conversation_failed__message, R.string.alert_dialog__confirmation, null, true);
                }
            });
        }
    });
}
Also used : User(com.waz.api.User) BaseScalaActivity(com.waz.zclient.BaseScalaActivity) OpenedGroupActionEvent(com.waz.zclient.controllers.tracking.events.group.OpenedGroupActionEvent) FooterMenuCallback(com.waz.zclient.views.menus.FooterMenuCallback) NetworkMode(com.waz.api.NetworkMode) NetworkAction(com.waz.zclient.core.stores.network.NetworkAction)

Aggregations

NetworkAction (com.waz.zclient.core.stores.network.NetworkAction)6 NetworkMode (com.waz.api.NetworkMode)5 FooterMenuCallback (com.waz.zclient.views.menus.FooterMenuCallback)3 BaseScalaActivity (com.waz.zclient.BaseScalaActivity)2 OpenedGroupActionEvent (com.waz.zclient.controllers.tracking.events.group.OpenedGroupActionEvent)2 Preference (android.support.v7.preference.Preference)1 PreferenceScreen (android.support.v7.preference.PreferenceScreen)1 Fingerprint (com.waz.api.Fingerprint)1 IConversation (com.waz.api.IConversation)1 Subscriber (com.waz.api.Subscriber)1 UpdateListener (com.waz.api.UpdateListener)1 User (com.waz.api.User)1 ChangedProfilePictureEvent (com.waz.zclient.core.controllers.tracking.events.settings.ChangedProfilePictureEvent)1 INetworkStore (com.waz.zclient.core.stores.network.INetworkStore)1 IParticipantsStore (com.waz.zclient.core.stores.participants.IParticipantsStore)1 ParticipantsStoreObserver (com.waz.zclient.core.stores.participants.ParticipantsStoreObserver)1 PreferenceCategory (net.xpece.android.support.preference.PreferenceCategory)1 SwitchPreference (net.xpece.android.support.preference.SwitchPreference)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1