I have alert dialog with an edit text added to it. It has positive and negative buttons. Whenever I click positive/ok button the dialog exits even if the edittext is empty.
I want to gain control over this behaviour. viz; I want the alertdialog to exit only if the edittext is not empty.
Note : strAuthorDesc is a String variable.
Here is the code that executes on click of a button.
                AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
                builder.setTitle("Author Desc.");
                final EditText descInput = new EditText(mActivity);
                descInput.setInputType(InputType.TYPE_CLASS_TEXT);
                descInput.setTextColor(ContextCompat.getColor(mActivity, R.color.black));
                descInput.setLines(5);
//                    descInput.setMaxLines(5);
                descInput.setGravity(Gravity.LEFT | Gravity.TOP);
                descInput.setSingleLine(false);
                descInput.setHorizontalScrollBarEnabled(false);
                builder.setView(descInput);
                builder.setPositiveButton("SAVE", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        strAuthorDesc = descInput.getText().toString();
                        if(strAuthorDesc != null && !strAuthorDesc.equals("")){
                            dialog.dismiss();
                            Const.showToast("Description added", mActivity);
                            setAuthorDesc();
                        }else{
                            Const.showToast("Desc. cannot be empty!", mActivity);
                        }
                    }
                });
                builder.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                });
            alertDialog = builder.create();
            alertDialog.setCancelable(false);
            alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
            alertDialog.show();
 
     
     
    