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();
}
Aggregations