]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/dialogs/EditBookmarkDialog.java
Add a requests activity. https://redmine.stoutner.com/issues/170
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / dialogs / EditBookmarkDialog.java
index 492c113ad710786239584b1ffc35b262be03d790..27be599c6ba783deaafef311183d0f1bad8b6720 100644 (file)
@@ -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.