Class NavigationHistory
java.lang.Object
nl.siegmann.epublib.browsersupport.NavigationHistory
- All Implemented Interfaces:
NavigationEventListener
A history of the user's locations with the epub.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate intprivate static final longstatic final intprivate longprivate longprivate List<NavigationHistory.Location> private intprivate Navigator -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLocation(String href) voidaddLocation(NavigationHistory.Location location) Adds the location after the current position.voidaddLocation(Resource resource) private voidRemoves all elements that are too much for the maxHistorySize out of the history.intintlongIf the time between a navigation event is less than the historyWaitTime then the new location is not added to the history.private StringgetLocationHref(int pos) intvoidbooleanmove(int delta) Moves the current positions delta positions.voidnavigationPerformed(NavigationEvent navigationEvent) If this is not the source of the navigationEvent then the addLocation will be called with the href of the currentResource in the navigationEvent.voidsetHistoryWaitTime(long historyWaitTime) voidsetMaxHistorySize(int maxHistorySize)
-
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
-
currentPos
private int currentPos -
currentSize
private int currentSize -
maxHistorySize
private int maxHistorySize -
historyWaitTime
private long historyWaitTime
-
-
Constructor Details
-
Method Details
-
getCurrentPos
public int getCurrentPos() -
getCurrentSize
public int getCurrentSize() -
initBook
-
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
-
checkHistorySize
private void checkHistorySize()Removes all elements that are too much for the maxHistorySize out of the history. -
addLocation
-
getLocationHref
-
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
-
setMaxHistorySize
public void setMaxHistorySize(int maxHistorySize) -
getMaxHistorySize
public int getMaxHistorySize()
-