X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fdialogs%2FEditBookmarkDialog.java;h=27be599c6ba783deaafef311183d0f1bad8b6720;hp=492c113ad710786239584b1ffc35b262be03d790;hb=012e5595c82d6e8d0b8a46f1ef18a02a56341182;hpb=80187b7215a5effdbe97ac48e8af34824a05c287 diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/EditBookmarkDialog.java b/app/src/main/java/com/stoutner/privacybrowser/dialogs/EditBookmarkDialog.java index 492c113a..27be599c 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/EditBookmarkDialog.java +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/EditBookmarkDialog.java @@ -49,7 +49,6 @@ import com.stoutner.privacybrowser.helpers.BookmarksDatabaseHelper; public class EditBookmarkDialog extends AppCompatDialogFragment { // Instantiate the class variables. private EditBookmarkListener editBookmarkListener; - private int selectedBookmarkDatabaseId; private EditText nameEditText; private EditText urlEditText; private RadioButton newIconRadioButton; @@ -66,12 +65,8 @@ public class EditBookmarkDialog extends AppCompatDialogFragment { // Run the default commands. super.onAttach(context); - // Get a handle for `EditBookmarkListener` from `context`. - try { - editBookmarkListener = (EditBookmarkListener) context; - } catch(ClassCastException exception) { - throw new ClassCastException(context.toString() + " must implement EditBookmarkListener."); - } + // Get a handle for `EditBookmarkListener` from the launching context. + editBookmarkListener = (EditBookmarkListener) context; } // Store the database ID in the arguments bundle. @@ -90,24 +85,18 @@ public class EditBookmarkDialog extends AppCompatDialogFragment { return editBookmarkDialog; } + // `@SuppressLing("InflateParams")` removes the warning about using `null` as the parent view group when inflating the `AlertDialog`. + @SuppressLint("InflateParams") @Override - public void onCreate(Bundle savedInstanceState) { - // Run the default commands. - super.onCreate(savedInstanceState); - + @NonNull + public Dialog onCreateDialog(Bundle savedInstanceState) { // Remove the incorrect lint warning that `getInt()` might be null. assert getArguments() != null; // Store the bookmark database ID in the class variable. - selectedBookmarkDatabaseId = getArguments().getInt("Database ID"); - } + int selectedBookmarkDatabaseId = getArguments().getInt("Database ID"); - // `@SuppressLing("InflateParams")` removes the warning about using `null` as the parent view group when inflating the `AlertDialog`. - @SuppressLint("InflateParams") - @Override - @NonNull - public Dialog onCreateDialog(Bundle savedInstanceState) { - // Initialize the database helper. The two `nulls` do not specify the database name or a `CursorFactory`. The `0` specifies a database version, but that is ignored and set instead using a constant in `BookmarksDatabaseHelper`. + // Initialize the database helper. The `0` specifies a database version, but that is ignored and set instead using a constant in `BookmarksDatabaseHelper`. BookmarksDatabaseHelper bookmarksDatabaseHelper = new BookmarksDatabaseHelper(getContext(), null, null, 0); // Get a `Cursor` with the selected bookmark and move it to the first position. @@ -130,7 +119,7 @@ public class EditBookmarkDialog extends AppCompatDialogFragment { // Remove the incorrect lint warning that `getActivity()` might be null. assert getActivity() != null; - // Set the view. The parent view is `null` because it will be assigned by `AlertDialog`. + // Set the view. The parent view is null because it will be assigned by the alert dialog. dialogBuilder.setView(getActivity().getLayoutInflater().inflate(R.layout.edit_bookmark_dialog, null)); // Set the listener for the negative button.