public class

DefaultBookmarkAdapter

extends Object
implements BookmarkProvider.BookmarkListener DocumentListener BookmarkViewAdapter
java.lang.Object
   ↳ com.pspdfkit.ui.outline.DefaultBookmarkAdapter

Class Overview

Default implementation of BookmarkViewAdapter which handles bookmark behaviour for the default BookmarkListView.

Summary

Public Constructors
DefaultBookmarkAdapter(PdfFragment fragment)
Creates a new adapter bound to the passed fragment.
Public Methods
void addBookmarkListener(BookmarkProvider.BookmarkListener listener)
Adds this view to bookmark change events via BookmarkProvider.BookmarkListener interface.
List<Bookmark> getBookmarks()
Called to retrieve the list of bookmarks to display.
boolean isBookmarkAddButtonEnabled()
Called to determine bookmark add button enabled state.
void onBookmarkAdd()
Called when add button has been clicked in this view.
void onBookmarkAdded(Bookmark bookmark)
Called when a new bookmark was added.
void onBookmarkClicked(Bookmark bookmark)
Called when user taps on a bookmark outside editing mode.
void onBookmarkNameSet(Bookmark bookmark, String name)
Called when bookmark should be renamed.
void onBookmarkPositionSet(Bookmark bookmark, int position)
Called when bookmark has been reordered in this view.
boolean onBookmarkRemove(Bookmark bookmark)
Called when user deleted the bookmark from list.
void onBookmarksChanged(List<Bookmark> bookmarks)
Called when bookmark list has been changed in some way.
boolean onDocumentClick()
Called when the user taps / clicks on the document, not the page itself but on the side (if visible).
void onDocumentLoadFailed(Throwable exception)
Called if document loading has failed.
void onDocumentLoaded(PdfDocument document)
Called when document is successfully loaded and the document view has been laid out.
boolean onDocumentSave(PdfDocument document, DocumentSaveOptions saveOptions)
Called before document will be saved.
void onDocumentSaveCancelled(PdfDocument document)
Called if document saving has been cancelled.
void onDocumentSaveFailed(PdfDocument document, Throwable exception)
Called if document saving has failed.
void onDocumentSaved(PdfDocument document)
Called after the document has been saved.
void onDocumentZoomed(PdfDocument document, int pageIndex, float scaleFactor)
Called when a user zooms a document.
void onPageChanged(PdfDocument document, int pageIndex)
Called when user scrolled to a new page.
boolean onPageClick(PdfDocument document, int pageIndex, MotionEvent event, PointF pagePosition, Annotation clickedAnnotation)
Called when user taps / clicks on the page.
void onPageUpdated(PdfDocument document, int pageIndex)
Called when content of page with pageIndex has changed (for example due to annotation or form field being updated).
void removeBookmarkListener(BookmarkProvider.BookmarkListener listener)
Removes this view from bookmark change events via BookmarkProvider.BookmarkListener interface.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.pspdfkit.bookmarks.BookmarkProvider.BookmarkListener
From interface com.pspdfkit.listeners.DocumentListener
From interface com.pspdfkit.ui.outline.BookmarkViewAdapter

Public Constructors

public DefaultBookmarkAdapter (PdfFragment fragment)

Creates a new adapter bound to the passed fragment.

Parameters
fragment Fragment with which to interact.

Public Methods

public void addBookmarkListener (BookmarkProvider.BookmarkListener listener)

Adds this view to bookmark change events via BookmarkProvider.BookmarkListener interface. Should be passed through to a BookmarkProvider. Passing null is not allowed, and will result in an exception.

Parameters
listener BookmarkProvider.BookmarkListener that should be notified. Must be non-null.

public List<Bookmark> getBookmarks ()

Called to retrieve the list of bookmarks to display.

Returns
  • List of bookmarks to be shown in this view.

public boolean isBookmarkAddButtonEnabled ()

Called to determine bookmark add button enabled state.

Returns
  • true if add button should be enabled, false if it should be disabled.

public void onBookmarkAdd ()

Called when add button has been clicked in this view.

public void onBookmarkAdded (Bookmark bookmark)

Called when a new bookmark was added. Called on the UI thread.

Parameters
bookmark The recently added bookmark.

public void onBookmarkClicked (Bookmark bookmark)

Called when user taps on a bookmark outside editing mode.

Parameters
bookmark Bookmark that was tapped.

public void onBookmarkNameSet (Bookmark bookmark, String name)

Called when bookmark should be renamed.

Parameters
bookmark Bookmark that has been selected for rename.
name New bookmark name.

public void onBookmarkPositionSet (Bookmark bookmark, int position)

Called when bookmark has been reordered in this view.

Parameters
bookmark Bookmark that has been reordered.
position New bookmark position.

public boolean onBookmarkRemove (Bookmark bookmark)

Called when user deleted the bookmark from list.

Parameters
bookmark Bookmark that was deleted.
Returns
  • true if the bookmark should be actually deleted, false if it should be left on the list.

public void onBookmarksChanged (List<Bookmark> bookmarks)

Called when bookmark list has been changed in some way. Called on the UI thread. It is also called if any property of any bookmark in the list changes.

Parameters
bookmarks List of bookmarks after change. The list is sorted.

public boolean onDocumentClick ()

Called when the user taps / clicks on the document, not the page itself but on the side (if visible).

Returns
  • true if tap is handled or false if PSPDFKit should execute it's default action.

public void onDocumentLoadFailed (Throwable exception)

Called if document loading has failed.

Parameters
exception Cause of the loading failure.

public void onDocumentLoaded (PdfDocument document)

Called when document is successfully loaded and the document view has been laid out. This has to be called on the main thread.

Parameters
document Loaded document instance.

public boolean onDocumentSave (PdfDocument document, DocumentSaveOptions saveOptions)

Called before document will be saved. This callback allows cancellation of the save process.

Parameters
document Instance of document to be saved.
saveOptions Save options to be applied to the document. You may change parameters on this object to control how document is saved.
Returns
  • true if the document should be saved, false if saving should be cancelled.

public void onDocumentSaveCancelled (PdfDocument document)

Called if document saving has been cancelled.

Parameters
document Instance of document that was saved.

public void onDocumentSaveFailed (PdfDocument document, Throwable exception)

Called if document saving has failed.

Parameters
exception Cause of the saving failure if applicable.

public void onDocumentSaved (PdfDocument document)

Called after the document has been saved.

Parameters
document Instance of document that was saved.

public void onDocumentZoomed (PdfDocument document, int pageIndex, float scaleFactor)

Called when a user zooms a document.

Parameters
document Current document.
pageIndex The number of the page that the was zoomed.
scaleFactor The current scale factor.

public void onPageChanged (PdfDocument document, int pageIndex)

Called when user scrolled to a new page.

Parameters
document Currently opened document.
pageIndex Page number of new page.

public boolean onPageClick (PdfDocument document, int pageIndex, MotionEvent event, PointF pagePosition, Annotation clickedAnnotation)

Called when user taps / clicks on the page.

Parameters
document Currently opened document.
pageIndex Page number of the page being tapped.
event MotionEvent that triggered this page click. May be null if this page click was triggered from keyboard or accessibility event.
pagePosition Tapped page position (in PDF page coordinates with origin on bottom left). Coordinates passed here may exceed the page size (which is returned by getPageSize(int)) and can also be negative. If the click was triggered by the keyboard, pagePosition will be null.
clickedAnnotation Annotation that was tapped, or null if no annotation was tapped.
Returns
  • true if tap was handled by this DocumentListener and should not be handled by PSPDFKit anymore. If returning false PSPDFKit will continue executing it's default action.

public void onPageUpdated (PdfDocument document, int pageIndex)

Called when content of page with pageIndex has changed (for example due to annotation or form field being updated). All views displaying this page need to refresh.

Parameters
pageIndex Page index of the updated page. Page index is 0-based.

public void removeBookmarkListener (BookmarkProvider.BookmarkListener listener)

Removes this view from bookmark change events via BookmarkProvider.BookmarkListener interface. Should be passed through to a BookmarkProvider. Upon calling this method the listener will no longer be notified of any changes. If the listener has not been added, this method will be a no-op. Adding null is not allowed,and will result in an exception.

Parameters
listener BookmarkProvider.BookmarkListener that should be removed. Must be non-null.