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.

    • Constructor Detail

    • 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 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.

      • 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.
      • 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.