Search in sources :

Example 1 with CloseSessionDialog

use of cl.smartcities.isci.transportinspector.dialogs.CloseSessionDialog in project androidApp by InspectorIncognito.

the class UserFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.activity_account_user_fragment, container, false);
    progressImage = view.findViewById(R.id.activity_account_user_fragment_level_progress_image);
    userName = view.findViewById(R.id.activity_account_user_fragment_user_name);
    score = view.findViewById(R.id.activity_account_user_fragment_user_score);
    level = view.findViewById(R.id.activity_account_user_fragment_user_level);
    userBusAvatarTitle = view.findViewById(R.id.user_bus_avatar_title);
    levelBackground = view.findViewById(R.id.level_background);
    levelName = view.findViewById(R.id.level_name);
    rankingFrame = view.findViewById(R.id.ranking_frame);
    rankingPosition = view.findViewById(R.id.ranking_position);
    rankingButton = view.findViewById(R.id.ranking_layout);
    rankingProgressBar = view.findViewById(R.id.ranking_progress_bar);
    rankingProgressBar.getIndeterminateDrawable().setColorFilter(ContextCompat.getColor(getContext(), R.color.green_button), android.graphics.PorterDuff.Mode.SRC_IN);
    View busPickerButton = view.findViewById(R.id.bus_layout);
    userBusAvatarView = view.findViewById(R.id.user_bus_avatar);
    View closeSessionButton = view.findViewById(R.id.close_session_button);
    closeSessionButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            CloseSessionDialog dialog = new CloseSessionDialog();
            dialog.setListener(new CloseSessionDialog.OnButtonClickListener() {

                @Override
                public void onPositiveButtonClick() {
                    TranSappAccountManager.logOut(new AccountLogOutListener() {

                        @Override
                        public void onLoggedOut() {
                            callback.onLogout();
                        }

                        @Override
                        public void onError(ServerStatusCode error) {
                            // TODO(aantoine): show error message
                            callback.onLogout();
                        }
                    });
                }

                @Override
                public void onNegativeButtonClick() {
                }
            });
            dialog.show(getFragmentManager(), dialog.getClass().getSimpleName());
        }
    });
    View editButton = view.findViewById(R.id.edit_button);
    editButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            startActivityForResult(new Intent(getActivity(), AccountSettingsActivity.class), USER_SETTINGS_CODE);
        }
    });
    busPickerButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            startActivityForResult(new Intent(getActivity(), AccountBusPickerActivity.class), USER_BUS_PICKER_CODE);
        }
    });
    updateUI();
    return view;
}
Also used : AccountLogOutListener(cl.smartcities.isci.transportinspector.gamification.ui.listener.AccountLogOutListener) CloseSessionDialog(cl.smartcities.isci.transportinspector.dialogs.CloseSessionDialog) ServerStatusCode(cl.smartcities.isci.transportinspector.serverConnection.ServerStatusCode) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) ActiveBusView(cl.smartcities.isci.transportinspector.drawables.ActiveBusView) TextView(android.widget.TextView)

Example 2 with CloseSessionDialog

use of cl.smartcities.isci.transportinspector.dialogs.CloseSessionDialog in project androidApp by InspectorIncognito.

the class UserFragment method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (super.onOptionsItemSelected(item)) {
        return true;
    }
    switch(item.getItemId()) {
        case R.id.action_settings:
            startActivity(new Intent(this.getActivity(), AccountSettingsActivity.class));
            return true;
        case R.id.action_close_session:
            CloseSessionDialog dialog = new CloseSessionDialog();
            dialog.setListener(new CloseSessionDialog.OnButtonClickListener() {

                @Override
                public void onPositiveButtonClick() {
                    TranSappAccountManager.logOut(new AccountLogOutListener() {

                        @Override
                        public void onLoggedOut() {
                            callback.onLogout();
                        }

                        @Override
                        public void onError(ServerStatusCode error) {
                            // TODO(aantoine): show error message
                            callback.onLogout();
                        }
                    });
                }

                @Override
                public void onNegativeButtonClick() {
                }
            });
            dialog.show(getFragmentManager(), dialog.getClass().getSimpleName());
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
Also used : AccountLogOutListener(cl.smartcities.isci.transportinspector.gamification.ui.listener.AccountLogOutListener) CloseSessionDialog(cl.smartcities.isci.transportinspector.dialogs.CloseSessionDialog) ServerStatusCode(cl.smartcities.isci.transportinspector.serverConnection.ServerStatusCode) Intent(android.content.Intent) AccountSettingsActivity(cl.smartcities.isci.transportinspector.gamification.ui.settings.AccountSettingsActivity)

Aggregations

Intent (android.content.Intent)2 CloseSessionDialog (cl.smartcities.isci.transportinspector.dialogs.CloseSessionDialog)2 AccountLogOutListener (cl.smartcities.isci.transportinspector.gamification.ui.listener.AccountLogOutListener)2 ServerStatusCode (cl.smartcities.isci.transportinspector.serverConnection.ServerStatusCode)2 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 ActiveBusView (cl.smartcities.isci.transportinspector.drawables.ActiveBusView)1 AccountSettingsActivity (cl.smartcities.isci.transportinspector.gamification.ui.settings.AccountSettingsActivity)1