public abstract class

PdfDrawableProvider

extends Object
java.lang.Object
   ↳ com.pspdfkit.ui.drawable.PdfDrawableProvider
Known Direct Subclasses

Class Overview

Interface for a class that can return a list of PdfDrawable instances that should be drawn on top of the document.

Summary

Nested Classes
interface PdfDrawableProvider.DrawableProviderObserver An observer interested in changes to the underlying set of drawables. 
Fields
public static final Set<Integer> NO_FILTERED_PAGES If returned inside getFilteredPages() the drawable provider won't be limited to a certain set of pages.
Public Constructors
PdfDrawableProvider()
Public Methods
abstract List<? extends PdfDrawable> getDrawablesForPage(Context context, PdfDocument document, int pageIndex)
Returns all drawables for the given document and pageIndex.
Observable<? extends PdfDrawable> getDrawablesForPageAsync(Context context, PdfDocument document, int pageIndex)
Returns an observable for fetching all page drawables in an asynchronous manner.
Set<Integer> getFilteredPages()
By overriding this method subclasses can define a set of page numbers for which drawables are available.
void notifyDrawablesChanged()
Notifies all registered PdfDrawableProvider.DrawableProviderObserver instances that the drawables have changed and need to be reloaded and redrawn.
void notifyDrawablesChanged(int pageIndex)
Notifies all registered PdfDrawableProvider.DrawableProviderObserver instances that the drawables for the given pageIndex have changed and need to be reloaded and redrawn.
void registerDrawableProviderObserver(PdfDrawableProvider.DrawableProviderObserver drawableProviderObserver)
Register a PdfDrawableProvider.DrawableProviderObserver to be notified of changes of provided drawables.
void unregisterDrawableProviderObserver(PdfDrawableProvider.DrawableProviderObserver drawableProviderObserver)
Unregister a previously registered PdfDrawableProvider.DrawableProviderObserver so it won't receive any future changes of provided drawables.
[Expand]
Inherited Methods
From class java.lang.Object

Fields

public static final Set<Integer> NO_FILTERED_PAGES

If returned inside getFilteredPages() the drawable provider won't be limited to a certain set of pages.

Public Constructors

public PdfDrawableProvider ()

Public Methods

public abstract List<? extends PdfDrawable> getDrawablesForPage (Context context, PdfDocument document, int pageIndex)

Returns all drawables for the given document and pageIndex. The framework may call this method on any thread.

Parameters
context Context for resource resolution.
document The currently loaded PdfDocument.
pageIndex Number of the page for which the drawables should be returned.
Returns
  • A list of all drawables for the given document and page.

public Observable<? extends PdfDrawable> getDrawablesForPageAsync (Context context, PdfDocument document, int pageIndex)

Returns an observable for fetching all page drawables in an asynchronous manner. The default implementation uses the getDrawablesForPage(Context, PdfDocument, int) method to retrieve the drawables. Subclasses may override this method to alter its behavior.

Parameters
context Context for resource resolution.
document The currently loaded PdfDocument.
pageIndex Number of the page for which the drawables should be returned.
Returns
  • An Observable emitting all drawables for the given document and page.

public Set<Integer> getFilteredPages ()

By overriding this method subclasses can define a set of page numbers for which drawables are available. The default implementation returns NO_FILTERED_PAGES which will cause PSPDFKit to ask the provider every time page drawables 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 drawables.

public void notifyDrawablesChanged ()

Notifies all registered PdfDrawableProvider.DrawableProviderObserver instances that the drawables have changed and need to be reloaded and redrawn. If only drawables for a single page have changed, consider calling notifyDrawablesChanged(int) instead.

public void notifyDrawablesChanged (int pageIndex)

Notifies all registered PdfDrawableProvider.DrawableProviderObserver instances that the drawables for the given pageIndex have changed and need to be reloaded and redrawn.

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

public void registerDrawableProviderObserver (PdfDrawableProvider.DrawableProviderObserver drawableProviderObserver)

Register a PdfDrawableProvider.DrawableProviderObserver to be notified of changes of provided drawables. If the observer has been registered previously, a call to this method is a no-op.

Parameters
drawableProviderObserver An observer to be notified of changes.

public void unregisterDrawableProviderObserver (PdfDrawableProvider.DrawableProviderObserver drawableProviderObserver)

Unregister a previously registered PdfDrawableProvider.DrawableProviderObserver so it won't receive any future changes of provided drawables.

Parameters
drawableProviderObserver An observer to unregister from change notifications.