Class OverlayViewProvider
-
- All Implemented Interfaces:
-
com.pspdfkit.ui.PageObjectProvider
public abstract class OverlayViewProvider implements PageObjectProvider
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interface
OverlayViewProvider.OverlayViewProviderObserver
An observer interested in changes to the underlying set of views.
-
Method Summary
Modifier and Type Method Description 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(@NonNull() Context context, @NonNull() PdfDocument document, @IntRange(from = 0) int pageIndex)
Returns all views for the given document
andpageIndex
.void
onViewsRecycled(@IntRange(from = 0) int pageIndex, @NonNull() List<View> views)
Called when views that have been previously returned by getViewsForPage have been recycled because their hosting page was recycled. void
onViewsShown(@IntRange(from = 0) int pageIndex, @NonNull() List<View> views)
Called when views that have been previously returned by getViewsForPage have become visible because the hosting page has become visible. void
onViewsHidden(@IntRange(from = 0) int pageIndex, @NonNull() List<View> views)
Called when views that have been previously returned by getViewsForPage have become hidden because the hosting page has become hidden. void
addOverlayViewProviderObserver(@NonNull() OverlayViewProvider.OverlayViewProviderObserver overlayViewProviderObserver)
Register a OverlayViewProviderObserver to be notified of changes of provided views. void
removeOverlayViewProviderObserver(@NonNull() OverlayViewProvider.OverlayViewProviderObserver overlayViewProviderObserver)
Unregister a previously registered OverlayViewProviderObserver so it won't receive any future changes of provided views. void
notifyOverlayViewsChanged()
Notifies all registered OverlayViewProviderObserver instances that the views have changed and need to be removed and added again. void
notifyOverlayViewsChanged(@IntRange(from = 0) int pageIndex)
Notifies all registered OverlayViewProviderObserver instances that the views for the given pageIndex
have changed and need to be removed and added again.-
-
Method Detail
-
getFilteredPages
@Nullable() final Set<Integer> getFilteredPages()
By overriding this method subclasses can define a set of page numbers for which drawables are available.
-
getPagesWithViews
@Nullable() 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.
-
getViewsForPage
@Nullable() abstract List<View> getViewsForPage(@NonNull() Context context, @NonNull() PdfDocument document, @IntRange(from = 0) int pageIndex)
Returns all views for the given
document
andpageIndex
. 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.
-
onViewsRecycled
void onViewsRecycled(@IntRange(from = 0) int pageIndex, @NonNull() List<View> views)
Called when views that have been previously returned by getViewsForPage 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.
-
onViewsShown
void onViewsShown(@IntRange(from = 0) int pageIndex, @NonNull() List<View> views)
Called when views that have been previously returned by getViewsForPage 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.
-
onViewsHidden
void onViewsHidden(@IntRange(from = 0) int pageIndex, @NonNull() List<View> views)
Called when views that have been previously returned by getViewsForPage 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.
-
addOverlayViewProviderObserver
void addOverlayViewProviderObserver(@NonNull() OverlayViewProvider.OverlayViewProviderObserver overlayViewProviderObserver)
Register a 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.
-
removeOverlayViewProviderObserver
void removeOverlayViewProviderObserver(@NonNull() OverlayViewProvider.OverlayViewProviderObserver overlayViewProviderObserver)
Unregister a previously registered OverlayViewProviderObserver so it won't receive any future changes of provided views.
- Parameters:
overlayViewProviderObserver
- An observer to unregister from change notifications.
-
notifyOverlayViewsChanged
void notifyOverlayViewsChanged()
Notifies all registered 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 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.
-
notifyOverlayViewsChanged
void notifyOverlayViewsChanged(@IntRange(from = 0) int pageIndex)
Notifies all registered 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.
-
-
-
-