X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;ds=sidebyside;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fdialogs%2FUrlHistoryDialog.java;h=87902b973a0b7d0aa13b0ccfb05b44e77ee88cf8;hb=54c70ca476ba2f53ae274df1ac725be3919e8f56;hp=0fe8afaa94e2e5d4078b1fae54e79d4896903204;hpb=ba40295dffd761ccdc95d3b46ca7acbad1f00d5e;p=PrivacyBrowserAndroid.git diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/UrlHistoryDialog.java b/app/src/main/java/com/stoutner/privacybrowser/dialogs/UrlHistoryDialog.java index 0fe8afaa..87902b97 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/UrlHistoryDialog.java +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/UrlHistoryDialog.java @@ -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 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`.