- // Listen for clicks on entries in `listView`.
- listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- // Convert the `long` `id` to an `int`.
- int itemId = (int) id;
-
- // Only consume the click if it is not on the `currentPageId`.
- if (itemId != currentPageId) {
- // Go forward or back to `itemId`.
- urlHistoryListener.onUrlHistoryEntrySelected(currentPageId - itemId);
-
- // Dismiss the `Dialog`.
- alertDialog.dismiss();
- }
+ // Listen for clicks on entries in the list view.
+ listView.setOnItemClickListener((AdapterView<?> parent, View view, int position, long id) -> {
+ // Convert the long ID to an int.
+ int itemId = (int) id;
+
+ // Only consume the click if it is not on the `currentPageId`.
+ if (itemId != currentPageId) {
+ // Reset the current domain name so that navigation works if third-party requests are blocked.
+ nestedScrollWebView.resetCurrentDomainName();
+
+ // Set navigating history so that the domain settings are applied when the new URL is loaded.
+ nestedScrollWebView.setNavigatingHistory(true);
+
+ // Load the history entry.
+ nestedScrollWebView.goBackOrForward(currentPageId - itemId);
+
+ // Dismiss the alert dialog.
+ alertDialog.dismiss();