Search in sources :

Example 1 with EditText

use of com.rey.material.widget.EditText 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 2 with EditText

use of com.rey.material.widget.EditText in project material by rey5137.

the class TextfieldFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_textfield, container, false);
    final EditText et_helper = (EditText) v.findViewById(R.id.textfield_et_helper);
    et_helper.setOnKeyListener(new View.OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_UP)
                et_helper.setError("Password is incorrect.");
            return false;
        }
    });
    et_helper.setOnFocusChangeListener(new View.OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus)
                et_helper.setError(null);
        }
    });
    final EditText et_helper_error = (EditText) v.findViewById(R.id.textfield_et_helper_error);
    et_helper_error.setOnKeyListener(new View.OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_UP)
                et_helper_error.setError("Password is incorrect.");
            return false;
        }
    });
    et_helper_error.setOnFocusChangeListener(new View.OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus)
                et_helper_error.setError(null);
        }
    });
    ContactEditText a = (ContactEditText) v.findViewById(R.id.textfield_tv);
    return v;
}
Also used : EditText(com.rey.material.widget.EditText) ContactEditText(com.rey.material.app.ContactEditText) KeyEvent(android.view.KeyEvent) ContactEditText(com.rey.material.app.ContactEditText) View(android.view.View) TextView(android.widget.TextView)

Aggregations

EditText (com.rey.material.widget.EditText)2 KeyEvent (android.view.KeyEvent)1 View (android.view.View)1 TextView (android.widget.TextView)1 BottomSheetDialog (com.rey.material.app.BottomSheetDialog)1 ContactEditText (com.rey.material.app.ContactEditText)1 DatePickerDialog (com.rey.material.app.DatePickerDialog)1 Dialog (com.rey.material.app.Dialog)1 DialogFragment (com.rey.material.app.DialogFragment)1 SimpleDialog (com.rey.material.app.SimpleDialog)1 TimePickerDialog (com.rey.material.app.TimePickerDialog)1