Class DefaultBookmarkAdapter
-
- All Implemented Interfaces:
-
androidx.lifecycle.DefaultLifecycleObserver
,androidx.lifecycle.LifecycleObserver
,com.pspdfkit.bookmarks.BookmarkProvider.BookmarkListener
,com.pspdfkit.listeners.DocumentListener
,com.pspdfkit.ui.outline.BookmarkViewAdapter
public class DefaultBookmarkAdapter implements BookmarkViewAdapter, DocumentListener, BookmarkProvider.BookmarkListener, DefaultLifecycleObserver
Default implementation of BookmarkViewAdapter which handles bookmark behaviour for the default BookmarkListView.
-
-
Constructor Summary
Constructors Constructor Description DefaultBookmarkAdapter(PdfFragment fragment)
Creates a new adapter bound to the passed fragment.
-
Method Summary
Modifier and Type Method Description void
onStop(@NonNull() LifecycleOwner owner)
void
onStart(@NonNull() LifecycleOwner owner)
void
onDestroy(@NonNull() LifecycleOwner owner)
List<Bookmark>
getBookmarks()
Called to retrieve the list of bookmarks to display. void
onBookmarkAdd()
Called when add button has been clicked in this view. void
onBookmarkPositionSet(@NonNull() Bookmark bookmark, int position)
Called when bookmark has been reordered in this view. void
onBookmarkNameSet(@NonNull() Bookmark bookmark, @Nullable() String name)
Called when bookmark should be renamed. void
onBookmarkClicked(@NonNull() Bookmark bookmark)
Called when user taps on a bookmark outside editing mode. boolean
onBookmarkRemove(@NonNull() Bookmark bookmark)
Called when user deleted the bookmark from list. boolean
isBookmarkAddButtonEnabled()
Called to determine bookmark add button enabled state. void
addBookmarkListener(@NonNull() BookmarkProvider.BookmarkListener listener)
Adds this view to bookmark change events via BookmarkListener interface. void
removeBookmarkListener(@NonNull() BookmarkProvider.BookmarkListener listener)
Removes this view from bookmark change events via BookmarkListener interface. void
onBookmarksChanged(@NonNull() List<Bookmark> bookmarks)
Called when bookmark list has been changed in some way. void
onBookmarkAdded(@NonNull() Bookmark bookmark)
Called when a new bookmark was added. void
onDocumentLoaded(@NonNull() PdfDocument document)
Called when document is successfully loaded and the document view has been laid out. -
-
Constructor Detail
-
DefaultBookmarkAdapter
DefaultBookmarkAdapter(PdfFragment fragment)
Creates a new adapter bound to the passed fragment.- Parameters:
fragment
- Fragment with which to interact.
-
-
Method Detail
-
onStop
void onStop(@NonNull() LifecycleOwner owner)
-
onStart
void onStart(@NonNull() LifecycleOwner owner)
-
onDestroy
void onDestroy(@NonNull() LifecycleOwner owner)
-
getBookmarks
List<Bookmark> getBookmarks()
Called to retrieve the list of bookmarks to display.
- Returns:
List of bookmarks to be shown in this view.
-
onBookmarkAdd
void onBookmarkAdd()
Called when add button has been clicked in this view.
-
onBookmarkPositionSet
void onBookmarkPositionSet(@NonNull() Bookmark bookmark, int position)
Called when bookmark has been reordered in this view.
- Parameters:
bookmark
- Bookmark that has been reordered.position
- New bookmark position.
-
onBookmarkNameSet
void onBookmarkNameSet(@NonNull() Bookmark bookmark, @Nullable() String name)
Called when bookmark should be renamed.
- Parameters:
bookmark
- Bookmark that has been selected for rename.name
- New bookmark name.
-
onBookmarkClicked
void onBookmarkClicked(@NonNull() Bookmark bookmark)
Called when user taps on a bookmark outside editing mode.
- Parameters:
bookmark
- Bookmark that was tapped.
-
onBookmarkRemove
boolean onBookmarkRemove(@NonNull() 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.
-
isBookmarkAddButtonEnabled
boolean isBookmarkAddButtonEnabled()
Called to determine bookmark add button enabled state.
- Returns:
true
if add button should be enabled,false
if it should be disabled.
-
addBookmarkListener
void addBookmarkListener(@NonNull() BookmarkProvider.BookmarkListener listener)
Adds this view to bookmark change events via BookmarkListener interface. Should be passed through to a BookmarkProvider. Passing
null
is not allowed, and will result in an exception.- Parameters:
listener
- BookmarkListener that should be notified.
-
removeBookmarkListener
void removeBookmarkListener(@NonNull() BookmarkProvider.BookmarkListener listener)
Removes this view from bookmark change events via 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. Addingnull
is not allowed,and will result in an exception.- Parameters:
listener
- BookmarkListener that should be removed.
-
onBookmarksChanged
void onBookmarksChanged(@NonNull() 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.
-
onBookmarkAdded
void onBookmarkAdded(@NonNull() Bookmark bookmark)
Called when a new bookmark was added. Called on the UI thread.
- Parameters:
bookmark
- The recently added bookmark.
-
onDocumentLoaded
@UiThread() void onDocumentLoaded(@NonNull() 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.
-
-
-
-