Search in sources :

Example 11 with DialogFragment

use of com.rey.material.app.DialogFragment in project caronae-android by caronae.

the class MyProfileFrag method locationEt.

@OnClick(R.id.location_et)
public void locationEt() {
    SimpleDialog.Builder builder = new SimpleDialog.Builder(R.style.SimpleDialogLight) {

        @Override
        public void onPositiveActionClicked(DialogFragment fragment) {
            String selectedZone = getSelectedValue().toString();
            if (selectedZone.equals("Outros")) {
                showOtherNeighborhoodDialog();
            } else {
                locationEt2(selectedZone);
            }
            super.onPositiveActionClicked(fragment);
        }

        @Override
        public void onNegativeActionClicked(DialogFragment fragment) {
            super.onNegativeActionClicked(fragment);
        }
    };
    builder.items(Util.getZones(), 0).title("Escolha sua zona").positiveAction(getString(R.string.ok)).negativeAction(getString(R.string.cancel));
    DialogFragment fragment = DialogFragment.newInstance(builder);
    fragment.show(getFragmentManager(), null);
}
Also used : SimpleDialog(com.rey.material.app.SimpleDialog) DialogFragment(com.rey.material.app.DialogFragment) CaretString(com.redmadrobot.inputmask.model.CaretString) OnClick(butterknife.OnClick)

Example 12 with DialogFragment

use of com.rey.material.app.DialogFragment in project caronae-android by caronae.

the class RideFilterFrag method centerEt.

@OnClick(R.id.center_et)
public void centerEt() {
    final ArrayList<String> selectedItems = new ArrayList<>();
    String[] selectedCenters = center_et.getText().toString().split(", ");
    boolean[] ifCentersAreSelected = new boolean[Util.getFundaoCenters().length];
    for (int centers = 0; centers < Util.getFundaoCenters().length; centers++) {
        ifCentersAreSelected[centers] = false;
        for (int selecteds = 0; selecteds < selectedCenters.length; selecteds++) {
            if (Util.getFundaoCenters()[centers].equals(selectedCenters[selecteds])) {
                ifCentersAreSelected[centers] = true;
                selectedItems.add(Util.getFundaoCenters()[centers]);
            }
        }
    }
    final AlertDialog builder = new AlertDialog.Builder(getContext()).setTitle(getContext().getString(R.string.frag_rideSearch_hintPickCenter)).setMultiChoiceItems(Util.getFundaoCenters(), ifCentersAreSelected, new DialogInterface.OnMultiChoiceClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which, boolean isChecked) {
            if (isChecked) {
                // If the user checked the item, add it to the selected items
                selectedItems.add(Util.getFundaoCenters()[which]);
            } else if (selectedItems.contains(Util.getFundaoCenters()[which])) {
                // Else, if the item is already in the array, remove it
                for (int item = 0; item < selectedItems.size(); item++) {
                    if (Util.getFundaoCenters()[which].equals(selectedItems.get(item)))
                        selectedItems.remove(item);
                }
            }
        }
    }).setPositiveButton(getContext().getString(R.string.ok), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            String centers = "";
            for (int selectedValues = 0; selectedValues < selectedItems.size(); selectedValues++) {
                if (selectedItems.get(selectedValues).equals(Util.getFundaoCenters()[0]) || selectedItems.size() == Util.getFundaoCenters().length - 1) {
                    selectedItems.clear();
                    // selectedItems.add(Util.getFundaoCenters()[0]);
                    selectedItems.add("Cidade Universitária");
                    campi = "Cidade Universitária";
                    centers = selectedItems.get(0) + ", ";
                    break;
                }
                centers = centers + selectedItems.get(selectedValues) + ", ";
            }
            if (!centers.equals("")) {
                centers = centers.substring(0, centers.length() - 2);
            }
            center_et.setText(centers);
            center = centers;
        }
    }).setNegativeButton(getContext().getString(R.string.cancel), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
        }
    }).create();
    SimpleDialog.Builder campiBuilder = new SimpleDialog.Builder(R.style.SimpleDialogLight) {

        @Override
        public void onPositiveActionClicked(DialogFragment fragment) {
            if (getSelectedValue().toString().equals("Praia Vermelha")) {
                center_et.setText(getSelectedValue());
                campi = getSelectedValue().toString();
            } else {
                // centerBuilder.items(Util.getCentersByCampi(getSelectedValue().toString()), 0)
                // .title(getContext().getString(R.string.frag_rideOffer_pickCenter))
                // .positiveAction(getContext().getString(R.string.ok))
                // .negativeAction(getContext().getString(R.string.cancel));
                // DialogFragment centerFragment = DialogFragment.newInstance(centerBuilder);
                // centerFragment.show(getFragmentManager(), null);
                builder.show();
            }
            super.onPositiveActionClicked(fragment);
        }

        @Override
        public void onNegativeActionClicked(DialogFragment fragment) {
            super.onNegativeActionClicked(fragment);
        }
    };
    campiBuilder.items(Util.getCampiWithoutAllCampi(), 0).title(getContext().getString(R.string.frag_rideOffer_pickCenter)).positiveAction(getContext().getString(R.string.ok)).negativeAction(getContext().getString(R.string.cancel));
    DialogFragment fragment = DialogFragment.newInstance(campiBuilder);
    fragment.show(getFragmentManager(), null);
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) DialogFragment(com.rey.material.app.DialogFragment) SimpleDialog(com.rey.material.app.SimpleDialog) OnClick(butterknife.OnClick)

Example 13 with DialogFragment

use of com.rey.material.app.DialogFragment in project caronae-android by caronae.

the class RideFilterFrag method showOtherNeighborhoodDialog.

public void showOtherNeighborhoodDialog() {
    Dialog.Builder builder = new SimpleDialog.Builder(R.style.SimpleDialogLight) {

        @Override
        protected void onBuildDone(Dialog dialog) {
            dialog.layoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        }

        @Override
        public void onPositiveActionClicked(DialogFragment fragment) {
            EditText neighborhood_et = (EditText) fragment.getDialog().findViewById(R.id.neighborhood_et);
            String neighborhood = neighborhood_et.getText().toString();
            if (!neighborhood.isEmpty()) {
                location_et.setText(neighborhood);
                location = neighborhood;
                resumeLocation = neighborhood;
            }
            super.onPositiveActionClicked(fragment);
        }

        @Override
        public void onNegativeActionClicked(DialogFragment fragment) {
            super.onNegativeActionClicked(fragment);
        }
    };
    builder.title(getActivity().getString(R.string.frag_ridesearch_typeNeighborhood)).positiveAction(getString(R.string.ok)).negativeAction(getString(R.string.cancel)).contentView(R.layout.other_neighborhood);
    DialogFragment fragment2 = DialogFragment.newInstance(builder);
    fragment2.show(getActivity().getSupportFragmentManager(), null);
}
Also used : EditText(android.widget.EditText) AlertDialog(android.support.v7.app.AlertDialog) SimpleDialog(com.rey.material.app.SimpleDialog) Dialog(com.rey.material.app.Dialog) DialogFragment(com.rey.material.app.DialogFragment)

Example 14 with DialogFragment

use of com.rey.material.app.DialogFragment in project caronae-android by caronae.

the class RideOfferFrag method showCenterListDialog.

public void showCenterListDialog(String campus) {
    SimpleDialog.Builder builder = new SimpleDialog.Builder(R.style.SimpleDialogLight) {

        @Override
        public void onPositiveActionClicked(DialogFragment fragment) {
            center_et.setText(getSelectedValue());
            super.onPositiveActionClicked(fragment);
        }

        @Override
        public void onNegativeActionClicked(DialogFragment fragment) {
            super.onNegativeActionClicked(fragment);
        }
    };
    if (going) {
        builder.items(Util.getCentersWithoutAllCenters(), 0).title(getContext().getString(R.string.frag_rideOffer_pickCenter)).positiveAction(getContext().getString(R.string.ok)).negativeAction(getContext().getString(R.string.cancel));
        DialogFragment fragment = DialogFragment.newInstance(builder);
        fragment.show(getFragmentManager(), null);
    } else {
        builder.items(Util.getHubsByCampi(campus), 0).title(getContext().getString(R.string.frag_rideOffer_pickHub)).positiveAction(getContext().getString(R.string.ok)).negativeAction(getContext().getString(R.string.cancel));
        DialogFragment fragment = DialogFragment.newInstance(builder);
        fragment.show(getFragmentManager(), null);
    // if (campi_et.getText().toString().equals("")){
    // campi_et.setError("Escolher o campus");
    // } else {
    // if (campi_et.getText().toString().equals(Util.getCampus()[1])) {
    // builder.items(Util.getFundaoHubs(), 0);
    // }
    // if (campi_et.getText().toString().equals(Util.getCampus()[2])) {
    // builder.items(Util.getPraiaVermelhaHubs(), 0);
    // }
    // DialogFragment fragment = DialogFragment.newInstance(builder);
    // fragment.show(getFragmentManager(), null);
    // }
    }
}
Also used : SimpleDialog(com.rey.material.app.SimpleDialog) DialogFragment(com.rey.material.app.DialogFragment)

Example 15 with DialogFragment

use of com.rey.material.app.DialogFragment in project caronae-android by caronae.

the class RideOfferFrag method neighborhoodEt.

@OnClick(R.id.neighborhood_et)
public void neighborhoodEt() {
    SimpleDialog.Builder builder = new SimpleDialog.Builder(R.style.SimpleDialogLight) {

        @Override
        public void onPositiveActionClicked(DialogFragment fragment) {
            String selectedZone = getSelectedValue().toString();
            zone = selectedZone;
            if (selectedZone.equals("Outros")) {
                showOtherNeighborhoodDialog();
            } else {
                locationEt2(selectedZone);
            }
            super.onPositiveActionClicked(fragment);
        }

        @Override
        public void onNegativeActionClicked(DialogFragment fragment) {
            super.onNegativeActionClicked(fragment);
        }
    };
    builder.items(Util.getZones(), 0).title(getContext().getString(R.string.frag_rideOffer_pickZone)).positiveAction(getContext().getString(R.string.ok)).negativeAction(getContext().getString(R.string.cancel));
    DialogFragment fragment = DialogFragment.newInstance(builder);
    fragment.show(getFragmentManager(), null);
}
Also used : SimpleDialog(com.rey.material.app.SimpleDialog) DialogFragment(com.rey.material.app.DialogFragment) OnClick(butterknife.OnClick)

Aggregations

DialogFragment (com.rey.material.app.DialogFragment)27 SimpleDialog (com.rey.material.app.SimpleDialog)27 OnClick (butterknife.OnClick)13 Dialog (com.rey.material.app.Dialog)12 AlertDialog (android.support.v7.app.AlertDialog)11 ProgressDialog (android.app.ProgressDialog)9 DatePickerDialog (com.rey.material.app.DatePickerDialog)7 TimePickerDialog (com.rey.material.app.TimePickerDialog)7 EditText (android.widget.EditText)4 ArrayList (java.util.ArrayList)4 User (br.ufrj.caronae.models.User)3 CaretString (com.redmadrobot.inputmask.model.CaretString)3 SimpleDateFormat (java.text.SimpleDateFormat)3 Intent (android.content.Intent)2 RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 RoundedTransformation (br.ufrj.caronae.RoundedTransformation)2 Ride (br.ufrj.caronae.models.Ride)2