]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/dialogs/UrlHistoryDialog.java
Add a context menu entry to Open in New Tab.
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / dialogs / UrlHistoryDialog.java
index 0fe8afaa94e2e5d4078b1fae54e79d4896903204..87902b973a0b7d0aa13b0ccfb05b44e77ee88cf8 100644 (file)
@@ -50,11 +50,36 @@ import java.io.ByteArrayOutputStream;
 import java.util.ArrayList;
 
 public class UrlHistoryDialog extends DialogFragment{
-
-    // `historyArrayList`  and `currentPageId` pass information from `onCreate()` to `onCreateDialog()`.
+    // Declare the class variables.
     private final ArrayList<History> historyArrayList = new ArrayList<>();
     private int currentPageId;
 
+    // Create a URL history listener.
+    private UrlHistoryListener urlHistoryListener;
+
+
+    // The public interface is used to send information back to the parent activity.
+    public interface UrlHistoryListener {
+        // Send back the number of steps to move forward or back.
+        void onUrlHistoryEntrySelected(int moveBackOrForwardSteps);
+
+        // Clear the history.
+        void onClearHistory();
+    }
+
+    @Override
+    public void onAttach(Context context) {
+        super.onAttach(context);
+
+        // Check to make sure tha the parent activity implements the listener.
+        try {
+            urlHistoryListener = (UrlHistoryListener) context;
+        } catch (ClassCastException exception) {
+            throw new ClassCastException(context.toString() + " must implement UrlHistoryListener.");
+        }
+    }
+
+
     public static UrlHistoryDialog loadBackForwardList(Context context, WebBackForwardList webBackForwardList) {
         // Create an arguments bundle.
         Bundle argumentsBundle = new Bundle();
@@ -161,30 +186,6 @@ public class UrlHistoryDialog extends DialogFragment{
         currentPageId = urlStringArrayList.size() - 1 - originalCurrentPageId;
     }
 
-    // The public interface is used to send information back to the parent activity.
-    public interface UrlHistoryListener {
-        // Send back the number of steps to move forward or back.
-        void onUrlHistoryEntrySelected(int moveBackOrForwardSteps);
-
-        // Clear the history.
-        void onClearHistory();
-    }
-
-    // `urlHistoryListener` is used in `onAttach()` and `onCreateDialog()`.
-    private UrlHistoryListener urlHistoryListener;
-
-    @Override
-    public void onAttach(Context context) {
-        super.onAttach(context);
-
-        // Check to make sure tha the parent activity implements the listener.
-        try {
-            urlHistoryListener = (UrlHistoryListener) context;
-        } catch (ClassCastException exception) {
-            throw new ClassCastException(context.toString() + " must implement UrlHistoryListener.");
-        }
-    }
-
     @Override
     @NonNull
     // `@SuppressLing("InflateParams")` removes the warning about using `null` as the parent view group when inflating the `AlertDialog`.