- // Load the text for `edit_bookmark_name_edittext`.
- EditText bookmarkNameEditText = (EditText) alertDialog.findViewById(R.id.edit_bookmark_name_edittext);
- bookmarkNameEditText.setText(bookmarkCursor.getString(bookmarkCursor.getColumnIndex(BookmarksDatabaseHelper.BOOKMARK_NAME)));
+ // Populate the edit texts.
+ nameEditText.setText(currentName);
+ urlEditText.setText(currentUrl);
+
+ // Initially disable the edit button.
+ editButton.setEnabled(false);
+
+ // Update the edit button if the icon selection changes.
+ iconRadioGroup.setOnCheckedChangeListener((RadioGroup group, int checkedId) -> {
+ // Update the edit button.
+ updateEditButton();
+ });
+
+ // Update the edit button if the bookmark name changes.
+ nameEditText.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ // Do nothing.
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ // Do nothing.
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ // Update the edit button.
+ updateEditButton();
+ }
+ });
+
+ // Update the edit button if the URL changes.
+ urlEditText.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ // Do nothing.
+ }