- ImageView newFavoriteIconImageView = (ImageView) alertDialog.findViewById(R.id.edit_bookmark_web_page_favorite_icon);
- newFavoriteIconImageView.setImageBitmap(MainWebViewActivity.favoriteIcon);
+ newFavoriteIconImageView.setImageBitmap(MainWebViewActivity.favoriteIconBitmap);
+
+ // Store the current bookmark name and URL.
+ currentName = bookmarkCursor.getString(bookmarkCursor.getColumnIndex(BookmarksDatabaseHelper.BOOKMARK_NAME));
+ currentUrl = bookmarkCursor.getString(bookmarkCursor.getColumnIndex(BookmarksDatabaseHelper.BOOKMARK_URL));
+
+ // Populate the `EditTexts`.
+ 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(new RadioGroup.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(RadioGroup group, @IdRes 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.
+ }