- createBookmarkNameEditText.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` `Create`.
- if ((keyCode == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN)) {
- // Trigger `createBookmarkListener` and return the `DialogFragment` to the parent activity.
- createBookmarkListener.onCreateBookmark(CreateBookmarkDialog.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;
- }
+ createBookmarkNameEditText.setOnKeyListener((View view, int keyCode, KeyEvent event) -> {
+ // If the event is a key-down on the `enter` key, select the `PositiveButton` `Create`.
+ if ((keyCode == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN)) {
+ // Trigger `createBookmarkListener` and return the `DialogFragment` to the parent activity.
+ createBookmarkListener.onCreateBookmark(CreateBookmarkDialog.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;