Class Session

  • All Implemented Interfaces:

    
    public final class Session
    
                        

    This class is primarily responsible for managing an instance of an Android WebView that will be shared between destinations.

    • Method Detail

      • isReady

         final Boolean isReady()

        Provides the status of whether WebNavigation is initialized and ready for use.

      • isRenderProcessGone

         final Boolean isRenderProcessGone()

        Specifies whether the render process is gone for the WebView instance. If the render process is gone, this Session and its WebView cannot be reused and must be recreated.

      • preCacheLocation

         final Unit preCacheLocation(String location)

        Fetches a given location and returns the response to the OfflineRequestHandler Allows an offline cache to contain specific items instead of solely relying on visited items.

        Parameters:
        location - Location to cache.
      • reset

         final Unit reset()

        Resets this session to a cold boot state. The first subsequent visit after resetting will execute a full cold boot (reloading of all resources).

      • restoreCurrentVisit

         final Boolean restoreCurrentVisit(SessionCallback callback)

        Synthetically restore the WebView's current visit without using a cached snapshot or a visit request. This is used when restoring a destination from the backstack, but the WebView's current location hasn't changed from the destination's location.

      • visitProposedToLocation

         final Unit visitProposedToLocation(String location, String optionsJson)

        Called by WebNavigation bridge when a new visit is proposed.

        Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.

        Parameters:
        location - The location to visit.
        optionsJson - A JSON block to be serialized into VisitOptions.
      • visitProposalRefreshingPage

         final Unit visitProposalRefreshingPage(String location, String optionsJson)

        Called by WebNavigation bridge when a new visit proposal will refresh the current page.

        Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.

        Parameters:
        location - The location to visit.
        optionsJson - A JSON block to be serialized into VisitOptions.
      • visitProposalScrollingToAnchor

         final Unit visitProposalScrollingToAnchor(String location, String optionsJson)

        Called by WebNavigation bridge when a new visit proposal will scroll to an anchor on the same page.

        Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.

        Parameters:
        location - The location to visit.
        optionsJson - A JSON block to be serialized into VisitOptions.
      • visitStarted

         final Unit visitStarted(String visitIdentifier, Boolean visitHasCachedSnapshot, Boolean visitIsPageRefresh, String location)

        Called by WebNavigation bridge when a new visit has just started.

        Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.

        Parameters:
        visitIdentifier - A unique identifier for the visit.
        visitHasCachedSnapshot - Whether the visit has a cached snapshot available.
        location - The location being visited.
      • visitRequestStarted

         final Unit visitRequestStarted(String visitIdentifier)

        Called by WebNavigation bridge when the HTTP request has started.

        Parameters:
        visitIdentifier - A unique identifier for the visit.
      • visitRequestCompleted

         final Unit visitRequestCompleted(String visitIdentifier)

        Called by WebNavigation bridge when the HTTP request has been completed.

        Parameters:
        visitIdentifier - A unique identifier for the visit.
      • visitRequestFailedWithStatusCode

         final Unit visitRequestFailedWithStatusCode(String location, String visitIdentifier, Boolean visitHasCachedSnapshot, Integer statusCode)

        Called by WebNavigation bridge when the HTTP request has failed.

        Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.

        Parameters:
        location - The location of the failed visit.
        visitIdentifier - A unique identifier for the visit.
        visitHasCachedSnapshot - Whether the visit has a cached snapshot available.
        statusCode - The HTTP status code that caused the failure.
      • visitRequestFailedWithNonHttpStatusCode

         final Unit visitRequestFailedWithNonHttpStatusCode(String location, String visitIdentifier, Boolean visitHasCachedSnapshot)

        Called by WebNavigation bridge when a visit request fails with a non-HTTP status code, suggesting it may be the result of a cross-origin redirect visit. Determining a cross-origin redirect is not possible in javascript with the Fetch API due to CORS restrictions, so verify on the native side. Propose a cross-origin redirect visit if a redirect is found, otherwise fail the visit.

        Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.

        Parameters:
        location - The original visit location requested.
        visitIdentifier - A unique identifier for the visit.
        visitHasCachedSnapshot - Whether the visit has a cached snapshot available.
      • visitRequestFinished

         final Unit visitRequestFinished(String visitIdentifier)

        Called by WebNavigation bridge when the HTTP request has been completed.

        Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.

        Parameters:
        visitIdentifier - A unique identifier for the visit.
      • pageLoaded

         final Unit pageLoaded(String restorationIdentifier)

        Called by WebNavigation bridge once the page has been fully loaded by the WebView.

        Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.

        Parameters:
        restorationIdentifier - A unique identifier for restoring the page and scroll position from cache.
      • visitRendered

         final Unit visitRendered(String visitIdentifier)

        Called by WebNavigation bridge once the page has been fully rendered in the webView.

        Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.

        Parameters:
        visitIdentifier - A unique identifier for the visit.
      • visitCompleted

         final Unit visitCompleted(String visitIdentifier, String restorationIdentifier)

        Called by WebNavigation bridge when the visit is fully completed (request successful and page rendered).

        Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.

        Parameters:
        visitIdentifier - A unique identifier for the visit.
        restorationIdentifier - A unique identifier for restoring the page and scroll position from cache.
      • formSubmissionStarted

         final Unit formSubmissionStarted(String location)

        Called by WebNavigation bridge when a form submission has started.

        Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.

        Parameters:
        location - The location of the form submission.
      • formSubmissionFinished

         final Unit formSubmissionFinished(String location)

        Called by WebNavigation bridge when a form submission has finished.

        Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.

        Parameters:
        location - The location of the form submission.
      • pageInvalidated

         final Unit pageInvalidated()

        Called when WebNavigation bridge detects that the page being visited has been invalidated, typically by new resources in the the page HEAD.

        Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.

      • webNavigationIsReady

         final Unit webNavigationIsReady(Boolean isReady)

        Sets internal flags that indicate whether WebNavigation in the WebView is ready for use.

        Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.

      • webNavigationFailedToLoad

         final Unit webNavigationFailedToLoad()

        Sets internal flags indicating that WebNavigation did not properly initialize.

        Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.

      • setWebNavigationEnabled

         final Unit setWebNavigationEnabled(Boolean isWebNavigationEnabled)

        Sets whether this session should use WebNavigation/LegacyNavigation navigation.

        Some pages intentionally omit AngularNative, and still need full page navigation with native shell handoff.

        Parameters:
        isWebNavigationEnabled - true when a WebNavigation bridge is present.
      • elementTouchStarted

         final Unit elementTouchStarted(Boolean preventsPullsToRefresh)

        Called when a touched element event has started.

        Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.

      • elementTouchEnded

         final Unit elementTouchEnded()

        Called when a touched element event has ended.

        Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.