Search in sources :

Example 1 with DatePickerDialog

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

the class RideOfferFrag method date_et.

@OnClick(R.id.date_et)
public void date_et() {
    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 2 with DatePickerDialog

use of com.rey.material.app.DatePickerDialog 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 3 with DatePickerDialog

use of com.rey.material.app.DatePickerDialog 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)

Aggregations

DatePickerDialog (com.rey.material.app.DatePickerDialog)3 Dialog (com.rey.material.app.Dialog)3 DialogFragment (com.rey.material.app.DialogFragment)3 SimpleDialog (com.rey.material.app.SimpleDialog)3 TimePickerDialog (com.rey.material.app.TimePickerDialog)3 ProgressDialog (android.app.ProgressDialog)2 AlertDialog (android.support.v7.app.AlertDialog)2 OnClick (butterknife.OnClick)2 SimpleDateFormat (java.text.SimpleDateFormat)2 BottomSheetDialog (com.rey.material.app.BottomSheetDialog)1 EditText (com.rey.material.widget.EditText)1