Search in sources :

Example 1 with Builder

use of com.afollestad.materialdialogs.MaterialDialog.Builder in project material-dialogs by afollestad.

the class MaterialEditTextPreference method showDialog.

@Override
protected void showDialog(Bundle state) {
    Builder mBuilder = new MaterialDialog.Builder(getContext()).title(getDialogTitle()).icon(getDialogIcon()).positiveText(getPositiveButtonText()).negativeText(getNegativeButtonText()).dismissListener(this).onAny(new MaterialDialog.SingleButtonCallback() {

        @Override
        public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
            switch(which) {
                default:
                    MaterialEditTextPreference.this.onClick(dialog, DialogInterface.BUTTON_POSITIVE);
                    break;
                case NEUTRAL:
                    MaterialEditTextPreference.this.onClick(dialog, DialogInterface.BUTTON_NEUTRAL);
                    break;
                case NEGATIVE:
                    MaterialEditTextPreference.this.onClick(dialog, DialogInterface.BUTTON_NEGATIVE);
                    break;
            }
        }
    }).dismissListener(this);
    @SuppressLint("InflateParams") View layout = LayoutInflater.from(getContext()).inflate(R.layout.md_stub_inputpref, null);
    onBindDialogView(layout);
    MDTintHelper.setTint(editText, color);
    TextView message = (TextView) layout.findViewById(android.R.id.message);
    if (getDialogMessage() != null && getDialogMessage().toString().length() > 0) {
        message.setVisibility(View.VISIBLE);
        message.setText(getDialogMessage());
    } else {
        message.setVisibility(View.GONE);
    }
    mBuilder.customView(layout, false);
    PrefUtil.registerOnActivityDestroyListener(this, this);
    dialog = mBuilder.build();
    if (state != null) {
        dialog.onRestoreInstanceState(state);
    }
    requestInputMethod(dialog);
    dialog.show();
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Builder(com.afollestad.materialdialogs.MaterialDialog.Builder) DialogAction(com.afollestad.materialdialogs.DialogAction) Builder(com.afollestad.materialdialogs.MaterialDialog.Builder) NonNull(android.support.annotation.NonNull) SuppressLint(android.annotation.SuppressLint) TextView(android.widget.TextView) View(android.view.View) TextView(android.widget.TextView)

Aggregations

SuppressLint (android.annotation.SuppressLint)1 NonNull (android.support.annotation.NonNull)1 View (android.view.View)1 TextView (android.widget.TextView)1 DialogAction (com.afollestad.materialdialogs.DialogAction)1 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)1 Builder (com.afollestad.materialdialogs.MaterialDialog.Builder)1