Class NavigationHistory

java.lang.Object
nl.siegmann.epublib.browsersupport.NavigationHistory
All Implemented Interfaces:
NavigationEventListener

public class NavigationHistory extends Object implements NavigationEventListener
A history of the user's locations with the epub.
  • Field Details

    • DEFAULT_MAX_HISTORY_SIZE

      public static final int DEFAULT_MAX_HISTORY_SIZE
      See Also:
    • DEFAULT_HISTORY_WAIT_TIME

      private static final long DEFAULT_HISTORY_WAIT_TIME
      See Also:
    • lastUpdateTime

      private long lastUpdateTime
    • locations

      private List<NavigationHistory.Location> locations
    • currentPos

      private int currentPos
    • currentSize

      private int currentSize
    • maxHistorySize

      private int maxHistorySize
    • historyWaitTime

      private long historyWaitTime
  • Constructor Details

    • NavigationHistory

      public NavigationHistory(Navigator navigator)
  • Method Details

    • getCurrentPos

      public int getCurrentPos()
    • getCurrentSize

      public int getCurrentSize()
    • initBook

      public void initBook(Book book)
    • getHistoryWaitTime

      public long getHistoryWaitTime()
      If the time between a navigation event is less than the historyWaitTime then the new location is not added to the history. When a user is rapidly viewing many pages using the slider we do not want all of them to be added to the history.
      Returns:
      the time we wait before adding the page to the history
    • setHistoryWaitTime

      public void setHistoryWaitTime(long historyWaitTime)
    • addLocation

      public void addLocation(Resource resource)
    • addLocation

      public void addLocation(NavigationHistory.Location location)
      Adds the location after the current position. If the currentposition is not the end of the list then the elements between the current element and the end of the list will be discarded. Does nothing if the new location matches the current location.
      If this nr of locations becomes larger then the historySize then the first item(s) will be removed.
      Parameters:
      location -
    • checkHistorySize

      private void checkHistorySize()
      Removes all elements that are too much for the maxHistorySize out of the history.
    • addLocation

      public void addLocation(String href)
    • getLocationHref

      private String getLocationHref(int pos)
    • move

      public boolean move(int delta)
      Moves the current positions delta positions. move(-1) to go one position back in history.
      move(1) to go one position forward.
      Parameters:
      delta -
      Returns:
      Whether we actually moved. If the requested value is illegal it will return false, true otherwise.
    • getCurrentHref

      public String getCurrentHref()
    • setMaxHistorySize

      public void setMaxHistorySize(int maxHistorySize)
    • getMaxHistorySize

      public int getMaxHistorySize()