private void finalizeButtonCommons(final AlertDialog dialog, final int which, final TextParam buttonText, final Func1<Integer, Boolean> specialButtonListener) {
        if (buttonText != null) {
            dialog.getButton(which).setOnClickListener(v -> {
                boolean handled = specialButtonListener != null && specialButtonListener.call(which);
                if (!handled && which == DialogInterface.BUTTON_NEUTRAL && neutralAction != null) {
                    neutralAction.run();
                    //this does not change the "handled" flag
                }
                if (!handled && this.buttonClickAction != null) {
                    handled = this.buttonClickAction.call(which);
                }
                if (!handled) {
                    //default action for all buttons
                    dialog.dismiss();
                }
            });
        }
    }
Sets an action to execute when neutral button is clicked
main/src/main/java/cgeo/geocaching/ui/dialog/SimpleDialog.java