]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/EditBookmark.java
Switch to AppCompatDialogFragment for dialogs that return values due to crashes in...
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / EditBookmark.java
index e42fc0e38ec88986f26a6b7cd03833a9546a853b..3ce8204dbf5d53118c0c3795cb1165d9ae493b38 100644 (file)
@@ -21,7 +21,6 @@ package com.stoutner.privacybrowser;
 
 import android.annotation.SuppressLint;
 import android.app.Dialog;
-import android.app.DialogFragment;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.database.Cursor;
@@ -29,17 +28,20 @@ import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 import android.os.Bundle;
 // If we don't use `android.support.v7.app.AlertDialog` instead of `android.app.AlertDialog` then the dialog will be covered by the keyboard.
+import android.support.annotation.NonNull;
 import android.support.v7.app.AlertDialog;
+// We have to use `AppCompatDialogFragment` instead of `DialogFragment` or an error is produced on API <=22.
+import android.support.v7.app.AppCompatDialogFragment;
 import android.view.KeyEvent;
 import android.view.View;
 import android.view.WindowManager;
 import android.widget.EditText;
 import android.widget.ImageView;
 
-public class EditBookmark extends DialogFragment {
+public class EditBookmark extends AppCompatDialogFragment {
     // The public interface is used to send information back to the parent activity.
     public interface EditBookmarkListener {
-        void onSaveEditBookmark(DialogFragment dialogFragment);
+        void onSaveEditBookmark(AppCompatDialogFragment dialogFragment);
     }
 
     // `editBookmarkListener` is used in `onAttach()` and `onCreateDialog()`
@@ -59,6 +61,7 @@ public class EditBookmark extends DialogFragment {
     // `@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) {
         // Get a long array with the the databaseId of the selected bookmark and convert it to an `int`.
         long[] selectedBookmarkLongArray = BookmarksActivity.checkedItemIds;