public abstract class

OverlayViewProvider

extends Object
implements PageObjectProvider
java.lang.Object
   ↳ com.pspdfkit.ui.overlay.OverlayViewProvider

Class Overview

Base class for classes that can return a list of views that should be drawn on top of the document.

Using this API requires the current license to contain the annotations component.

This class is still in experimental state meaning that it is tested and contains no known bugs, but the API might be changed or removed with any minor release.

Summary

Nested Classes
interface OverlayViewProvider.OverlayViewProviderObserver An observer interested in changes to the underlying set of views. 
Fields
public static final Set<Integer> ALL_PAGES If returned inside getPagesWithViews() ()} the overlay view provider won't be limited to certain pages.
Public Constructors
OverlayViewProvider()
Creates a new OverlayViewProvider.
Public Methods
void addOverlayViewProviderObserver(OverlayViewProvider.OverlayViewProviderObserver overlayViewProviderObserver)
Register a OverlayViewProvider.OverlayViewProviderObserver to be notified of changes of provided views.
final Set<Integer> getFilteredPages()
By overriding this method subclasses can define a set of page numbers for which drawables are available.
Set<Integer> getPagesWithViews()
By overriding this method subclasses can define a set of page numbers for which views are available.
abstract List<View> getViewsForPage(Context context, PdfDocument document, int pageIndex)
Returns all views for the given document and pageIndex.
void notifyOverlayViewsChanged(int pageIndex)
Notifies all registered OverlayViewProvider.OverlayViewProviderObserver instances that the views for the given pageIndex have changed and need to be removed and added again.
void notifyOverlayViewsChanged()
Notifies all registered OverlayViewProvider.OverlayViewProviderObserver instances that the views have changed and need to be removed and added again.
void onViewsHidden(int pageIndex, List<View> views)
Called when views that have been previously returned by getViewsForPage(Context, PdfDocument, int) have become hidden because the hosting page has become hidden.
void onViewsRecycled(int pageIndex, List<View> views)
Called when views that have been previously returned by getViewsForPage(Context, PdfDocument, int) have been recycled because their hosting page was recycled.
void onViewsShown(int pageIndex, List<View> views)
Called when views that have been previously returned by getViewsForPage(Context, PdfDocument, int) have become visible because the hosting page has become visible.
void removeOverlayViewProviderObserver(OverlayViewProvider.OverlayViewProviderObserver overlayViewProviderObserver)
Unregister a previously registered OverlayViewProvider.OverlayViewProviderObserver so it won't receive any future changes of provided views.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.pspdfkit.ui.PageObjectProvider

Fields

public static final Set<Integer> ALL_PAGES

If returned inside getPagesWithViews() ()} the overlay view provider won't be limited to certain pages.

Public Constructors

public OverlayViewProvider ()

Creates a new OverlayViewProvider.

Throws
InvalidPSPDFKitLicenseException If the current license doesn't contain the annotations component.

Public Methods

public void addOverlayViewProviderObserver (OverlayViewProvider.OverlayViewProviderObserver overlayViewProviderObserver)

Register a OverlayViewProvider.OverlayViewProviderObserver to be notified of changes of provided views. This observer is notified whenever notifyOverlayViewsChanged() is called. If the observer has been registered previously, a call to this method is a no-op.

Parameters
overlayViewProviderObserver An observer to be notified of changes whe notifyOverlayViewsChanged() is called.

public final Set<Integer> getFilteredPages ()

By overriding this method subclasses can define a set of page numbers for which drawables are available.

public Set<Integer> getPagesWithViews ()

By overriding this method subclasses can define a set of page numbers for which views are available. The default implementation returns ALL_PAGES which will cause PSPDFKit to ask the provider every time page views are required, independent of the page number. Consider overriding this method if the loaded document has many pages, but only a few of them contain views.

public abstract List<View> getViewsForPage (Context context, PdfDocument document, int pageIndex)

Returns all views for the given document and pageIndex. The framework will only call this from the main thread.

Parameters
context The current activity hosting the document the view will be overlaid on.
document The currently loaded PdfDocument.
pageIndex Number of the page for which the views should be returned.
Returns
  • A list of all views for the given document and page. These views will automatically be attached using the layout parameters set on them. or null if no views should be added.
Throws
IllegalArgumentException If the views to be attached have no layout parameters or layout parameters that aren't of type OverlayLayoutParams.

public void notifyOverlayViewsChanged (int pageIndex)

Notifies all registered OverlayViewProvider.OverlayViewProviderObserver instances that the views for the given pageIndex have changed and need to be removed and added again.

Call this when the set of views has changed, if you only want to change the positioning of the the views simply update their OverlayLayoutParams.

Parameters
pageIndex Number of the page on which views have changed.

public void notifyOverlayViewsChanged ()

Notifies all registered OverlayViewProvider.OverlayViewProviderObserver instances that the views have changed and need to be removed and added again. If only views for a single page have changed, consider calling notifyOverlayViewsChanged(int) instead.

Call this when the set of views has changed, if you only want to change the positioning of the the views simply update their OverlayLayoutParams.

public void onViewsHidden (int pageIndex, List<View> views)

Called when views that have been previously returned by getViewsForPage(Context, PdfDocument, int) have become hidden because the hosting page has become hidden.

Parameters
pageIndex The page for which the views became hidden.
views The views that have become hidden.

public void onViewsRecycled (int pageIndex, List<View> views)

Called when views that have been previously returned by getViewsForPage(Context, PdfDocument, int) have been recycled because their hosting page was recycled.

Parameters
pageIndex The page for which the views were recycled.
views The views that were recycled. These views are no longer part of the view hierarchy and can be reused again.

public void onViewsShown (int pageIndex, List<View> views)

Called when views that have been previously returned by getViewsForPage(Context, PdfDocument, int) have become visible because the hosting page has become visible.

Parameters
pageIndex The page for which the views became visible.
views The views that have become visible.

public void removeOverlayViewProviderObserver (OverlayViewProvider.OverlayViewProviderObserver overlayViewProviderObserver)

Unregister a previously registered OverlayViewProvider.OverlayViewProviderObserver so it won't receive any future changes of provided views.

Parameters
overlayViewProviderObserver An observer to unregister from change notifications.