- addDomainEditText.setOnKeyListener(new View.OnKeyListener() {
- public boolean onKey(View view, int keyCode, KeyEvent event) {
- // If the event is a key-down on the `enter` key, select the `PositiveButton` `Add`.
- if ((keyCode == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN)) {
- // Trigger `addDomainListener` and return the `DialogFragment` to the parent activity.
- addDomainListener.onAddDomain(AddDomainDialog.this);
- // Manually dismiss the `AlertDialog`.
- alertDialog.dismiss();
- // Consume the event.
- return true;
- } else { // If any other key was pressed, do not consume the event.
- return false;
- }
+ addDomainEditText.setOnKeyListener((View view, int keyCode, KeyEvent event) -> {
+ // If the event is a key-down on the `enter` key, select the `PositiveButton` `Add`.
+ if ((keyCode == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN)) {
+ // Trigger `addDomainListener` and return the `DialogFragment` to the parent activity.
+ addDomainListener.onAddDomain(AddDomainDialog.this);
+ // Manually dismiss the `AlertDialog`.
+ alertDialog.dismiss();
+ // Consume the event.
+ return true;
+ } else { // If any other key was pressed, do not consume the event.
+ return false;