Search in sources :

Example 6 with DialogFragment

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

the class RideSearchFrag 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();
            location_et.setText(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_rideSearch_pickZones)).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)

Example 7 with DialogFragment

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

the class RideSearchFrag method timeEt.

@OnClick(R.id.time_et)
public void timeEt() {
    Dialog.Builder builder = new TimePickerDialog.Builder(R.style.Material_App_Dialog_TimePicker_Light, 24, 0) {

        @Override
        public void onPositiveActionClicked(DialogFragment fragment) {
            TimePickerDialog dialog = (TimePickerDialog) fragment.getDialog();
            time_et.setText(dialog.getFormattedTime(new SimpleDateFormat("HH:mm", Locale.US)));
            super.onPositiveActionClicked(fragment);
        }

        @Override
        public void onNegativeActionClicked(DialogFragment fragment) {
            super.onNegativeActionClicked(fragment);
        }
    };
    builder.positiveAction(getContext().getString(R.string.ok)).negativeAction(getContext().getString(R.string.cancel));
    DialogFragment fragment = DialogFragment.newInstance(builder);
    fragment.show(getFragmentManager(), null);
}
Also used : TimePickerDialog(com.rey.material.app.TimePickerDialog) ProgressDialog(android.app.ProgressDialog) AlertDialog(android.support.v7.app.AlertDialog) DatePickerDialog(com.rey.material.app.DatePickerDialog) SimpleDialog(com.rey.material.app.SimpleDialog) Dialog(com.rey.material.app.Dialog) DialogFragment(com.rey.material.app.DialogFragment) TimePickerDialog(com.rey.material.app.TimePickerDialog) SimpleDateFormat(java.text.SimpleDateFormat) OnClick(butterknife.OnClick)

Example 8 with DialogFragment

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

the class RideSearchFrag method dateEt.

@OnClick(R.id.date_et)
public void dateEt() {
    Dialog.Builder builder = new DatePickerDialog.Builder(R.style.Material_App_Dialog_DatePicker_Light) {

        @Override
        public void onPositiveActionClicked(DialogFragment fragment) {
            DatePickerDialog dialog = (DatePickerDialog) fragment.getDialog();
            date_et.setText(dialog.getFormattedDate(new SimpleDateFormat("dd/MM/yyyy", Locale.US)));
            super.onPositiveActionClicked(fragment);
        }

        @Override
        public void onNegativeActionClicked(DialogFragment fragment) {
            super.onNegativeActionClicked(fragment);
        }
    };
    builder.positiveAction(getContext().getString(R.string.ok)).negativeAction(getContext().getString(R.string.cancel));
    DialogFragment fragment = DialogFragment.newInstance(builder);
    fragment.show(getFragmentManager(), null);
}
Also used : DatePickerDialog(com.rey.material.app.DatePickerDialog) TimePickerDialog(com.rey.material.app.TimePickerDialog) ProgressDialog(android.app.ProgressDialog) AlertDialog(android.support.v7.app.AlertDialog) DatePickerDialog(com.rey.material.app.DatePickerDialog) SimpleDialog(com.rey.material.app.SimpleDialog) Dialog(com.rey.material.app.Dialog) DialogFragment(com.rey.material.app.DialogFragment) SimpleDateFormat(java.text.SimpleDateFormat) OnClick(butterknife.OnClick)

Example 9 with DialogFragment

use of com.rey.material.app.DialogFragment in project material by rey5137.

the class DialogsFragment method onClick.

@Override
public void onClick(View v) {
    Dialog.Builder builder = null;
    boolean isLightTheme = ThemeManager.getInstance().getCurrentTheme() == 0;
    switch(v.getId()) {
        case R.id.dialog_bt_title_only:
            builder = new SimpleDialog.Builder(isLightTheme ? R.style.SimpleDialogLight : R.style.SimpleDialog) {

                @Override
                public void onPositiveActionClicked(DialogFragment fragment) {
                    Toast.makeText(mActivity, "Discarded", Toast.LENGTH_SHORT).show();
                    super.onPositiveActionClicked(fragment);
                }

                @Override
                public void onNegativeActionClicked(DialogFragment fragment) {
                    Toast.makeText(mActivity, "Canceled", Toast.LENGTH_SHORT).show();
                    super.onNegativeActionClicked(fragment);
                }
            };
            builder.title("Discard draft?").positiveAction("DISCARD").negativeAction("CANCEL");
            break;
        case R.id.dialog_bt_msg_only:
            builder = new SimpleDialog.Builder(isLightTheme ? R.style.SimpleDialogLight : R.style.SimpleDialog) {

                @Override
                public void onPositiveActionClicked(DialogFragment fragment) {
                    Toast.makeText(mActivity, "Deleted", Toast.LENGTH_SHORT).show();
                    super.onPositiveActionClicked(fragment);
                }

                @Override
                public void onNegativeActionClicked(DialogFragment fragment) {
                    Toast.makeText(mActivity, "Cancelled", Toast.LENGTH_SHORT).show();
                    super.onNegativeActionClicked(fragment);
                }
            };
            ((SimpleDialog.Builder) builder).message("Delete this conversation?").positiveAction("DELETE").negativeAction("CANCEL");
            break;
        case R.id.dialog_bt_title_msg:
            builder = new SimpleDialog.Builder(isLightTheme ? R.style.SimpleDialogLight : R.style.SimpleDialog) {

                @Override
                public void onPositiveActionClicked(DialogFragment fragment) {
                    Toast.makeText(mActivity, "Agreed", Toast.LENGTH_SHORT).show();
                    super.onPositiveActionClicked(fragment);
                }

                @Override
                public void onNegativeActionClicked(DialogFragment fragment) {
                    Toast.makeText(mActivity, "Disagreed", Toast.LENGTH_SHORT).show();
                    super.onNegativeActionClicked(fragment);
                }
            };
            ((SimpleDialog.Builder) builder).message("Let Google help apps determine location. This means sending anonymous location data to Google, even when no apps are running.").title("Use Google's location service?").positiveAction("AGREE").negativeAction("DISAGREE");
            break;
        case R.id.dialog_bt_custom:
            builder = new SimpleDialog.Builder(isLightTheme ? R.style.SimpleDialogLight : R.style.SimpleDialog) {

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

                @Override
                public void onPositiveActionClicked(DialogFragment fragment) {
                    EditText et_pass = (EditText) fragment.getDialog().findViewById(R.id.custom_et_password);
                    Toast.makeText(mActivity, "Connected. pass=" + et_pass.getText().toString(), Toast.LENGTH_SHORT).show();
                    super.onPositiveActionClicked(fragment);
                }

                @Override
                public void onNegativeActionClicked(DialogFragment fragment) {
                    Toast.makeText(mActivity, "Cancelled", Toast.LENGTH_SHORT).show();
                    super.onNegativeActionClicked(fragment);
                }
            };
            builder.title("Google Wi-Fi").positiveAction("CONNECT").negativeAction("CANCEL").contentView(R.layout.layout_dialog_custom);
            break;
        case R.id.dialog_bt_choice:
            builder = new SimpleDialog.Builder(isLightTheme ? R.style.SimpleDialogLight : R.style.SimpleDialog) {

                @Override
                public void onPositiveActionClicked(DialogFragment fragment) {
                    Toast.makeText(mActivity, "You have selected " + getSelectedValue() + " as phone ringtone.", Toast.LENGTH_SHORT).show();
                    super.onPositiveActionClicked(fragment);
                }

                @Override
                public void onNegativeActionClicked(DialogFragment fragment) {
                    Toast.makeText(mActivity, "Cancelled", Toast.LENGTH_SHORT).show();
                    super.onNegativeActionClicked(fragment);
                }
            };
            ((SimpleDialog.Builder) builder).items(new String[] { "None", "Callisto", "Dione", "Ganymede", "Hangouts Call", "Luna", "Oberon", "Phobos" }, 0).title("Phone Ringtone").positiveAction("OK").negativeAction("CANCEL");
            break;
        case R.id.dialog_bt_multi_choice:
            builder = new SimpleDialog.Builder(isLightTheme ? R.style.SimpleDialogLight : R.style.SimpleDialog) {

                @Override
                public void onPositiveActionClicked(DialogFragment fragment) {
                    CharSequence[] values = getSelectedValues();
                    if (values == null)
                        Toast.makeText(mActivity, "You have selected nothing.", Toast.LENGTH_SHORT).show();
                    else {
                        StringBuffer sb = new StringBuffer();
                        sb.append("You have selected ");
                        for (int i = 0; i < values.length; i++) sb.append(values[i]).append(i == values.length - 1 ? "." : ", ");
                        Toast.makeText(mActivity, sb.toString(), Toast.LENGTH_SHORT).show();
                    }
                    super.onPositiveActionClicked(fragment);
                }

                @Override
                public void onNegativeActionClicked(DialogFragment fragment) {
                    Toast.makeText(mActivity, "Cancelled", Toast.LENGTH_SHORT).show();
                    super.onNegativeActionClicked(fragment);
                }
            };
            ((SimpleDialog.Builder) builder).multiChoiceItems(new String[] { "Soup", "Pizza", "Hotdogs", "Hamburguer", "Coffee", "Juice", "Milk", "Water" }, 2, 5).title("Food Order").positiveAction("OK").negativeAction("CANCEL");
            break;
        case R.id.dialog_bt_time:
            builder = new TimePickerDialog.Builder(isLightTheme ? R.style.Material_App_Dialog_TimePicker_Light : R.style.Material_App_Dialog_TimePicker, 24, 00) {

                @Override
                public void onPositiveActionClicked(DialogFragment fragment) {
                    TimePickerDialog dialog = (TimePickerDialog) fragment.getDialog();
                    Toast.makeText(mActivity, "Time is " + dialog.getFormattedTime(SimpleDateFormat.getTimeInstance()), Toast.LENGTH_SHORT).show();
                    super.onPositiveActionClicked(fragment);
                }

                @Override
                public void onNegativeActionClicked(DialogFragment fragment) {
                    Toast.makeText(mActivity, "Cancelled", Toast.LENGTH_SHORT).show();
                    super.onNegativeActionClicked(fragment);
                }
            };
            builder.positiveAction("OK").negativeAction("CANCEL");
            break;
        case R.id.dialog_bt_date:
            builder = new DatePickerDialog.Builder(isLightTheme ? R.style.Material_App_Dialog_DatePicker_Light : R.style.Material_App_Dialog_DatePicker) {

                @Override
                public void onPositiveActionClicked(DialogFragment fragment) {
                    DatePickerDialog dialog = (DatePickerDialog) fragment.getDialog();
                    String date = dialog.getFormattedDate(SimpleDateFormat.getDateInstance());
                    Toast.makeText(mActivity, "Date is " + date, Toast.LENGTH_SHORT).show();
                    super.onPositiveActionClicked(fragment);
                }

                @Override
                public void onNegativeActionClicked(DialogFragment fragment) {
                    Toast.makeText(mActivity, "Cancelled", Toast.LENGTH_SHORT).show();
                    super.onNegativeActionClicked(fragment);
                }
            };
            builder.positiveAction("OK").negativeAction("CANCEL");
            break;
    }
    DialogFragment fragment = DialogFragment.newInstance(builder);
    fragment.show(getFragmentManager(), null);
}
Also used : EditText(com.rey.material.widget.EditText) DatePickerDialog(com.rey.material.app.DatePickerDialog) DialogFragment(com.rey.material.app.DialogFragment) TimePickerDialog(com.rey.material.app.TimePickerDialog) SimpleDialog(com.rey.material.app.SimpleDialog) TimePickerDialog(com.rey.material.app.TimePickerDialog) DatePickerDialog(com.rey.material.app.DatePickerDialog) SimpleDialog(com.rey.material.app.SimpleDialog) BottomSheetDialog(com.rey.material.app.BottomSheetDialog) Dialog(com.rey.material.app.Dialog)

Example 10 with DialogFragment

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

the class MyProfileFrag method locationEt2.

public void locationEt2(String zone) {
    SimpleDialog.Builder builder = new SimpleDialog.Builder(R.style.SimpleDialogLight) {

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

        @Override
        public void onNegativeActionClicked(DialogFragment fragment) {
            super.onNegativeActionClicked(fragment);
        }
    };
    builder.items(Util.getNeighborhoods(zone), 0).title("Escolha seu bairro").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)

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