Class PdfDrawableProvider
-
- All Implemented Interfaces:
-
com.pspdfkit.ui.PageObjectProvider
public abstract class PdfDrawableProvider implements PageObjectProvider
Interface for a class that can return a list of PdfDrawable instances that should be drawn on top of the document.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interface
PdfDrawableProvider.DrawableProviderObserver
An observer interested in changes to the underlying set of drawables.
-
Field Summary
Fields Modifier and Type Field Description public final static Set<Integer>
NO_FILTERED_PAGES
-
Constructor Summary
Constructors Constructor Description PdfDrawableProvider()
-
Method Summary
Modifier and Type Method Description Set<Integer>
getFilteredPages()
By overriding this method subclasses can define a set of page numbers for which drawables are available. abstract List<out PdfDrawable>
getDrawablesForPage(@NonNull() Context context, @NonNull() PdfDocument document, @IntRange(from = 0) int pageIndex)
Returns all drawables for the given document
andpageIndex
.Observable<out PdfDrawable>
getDrawablesForPageAsync(@NonNull() Context context, @NonNull() PdfDocument document, @IntRange(from = 0) int pageIndex)
Returns an observable for fetching all page drawables in an asynchronous manner. void
registerDrawableProviderObserver(@NonNull() PdfDrawableProvider.DrawableProviderObserver drawableProviderObserver)
Register a DrawableProviderObserver to be notified of changes of provided drawables. void
unregisterDrawableProviderObserver(@NonNull() PdfDrawableProvider.DrawableProviderObserver drawableProviderObserver)
Unregister a previously registered DrawableProviderObserver so it won't receive any future changes of provided drawables. void
notifyDrawablesChanged()
Notifies all registered DrawableProviderObserver instances that the drawables have changed and need to be reloaded and redrawn. void
notifyDrawablesChanged(@IntRange(from = 0) int pageIndex)
Notifies all registered DrawableProviderObserver instances that the drawables for the given pageIndex
have changed and need to be reloaded and redrawn.-
-
Method Detail
-
getFilteredPages
@Nullable() 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.
-
getDrawablesForPage
@Nullable() abstract List<out PdfDrawable> getDrawablesForPage(@NonNull() Context context, @NonNull() PdfDocument document, @IntRange(from = 0) int pageIndex)
Returns all drawables for the given
document
andpageIndex
. 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.
-
getDrawablesForPageAsync
Observable<out PdfDrawable> getDrawablesForPageAsync(@NonNull() Context context, @NonNull() PdfDocument document, @IntRange(from = 0) int pageIndex)
Returns an observable for fetching all page drawables in an asynchronous manner. The default implementation uses the getDrawablesForPage 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.
-
registerDrawableProviderObserver
void registerDrawableProviderObserver(@NonNull() PdfDrawableProvider.DrawableProviderObserver drawableProviderObserver)
Register a 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.
-
unregisterDrawableProviderObserver
void unregisterDrawableProviderObserver(@NonNull() PdfDrawableProvider.DrawableProviderObserver drawableProviderObserver)
Unregister a previously registered DrawableProviderObserver so it won't receive any future changes of provided drawables.
- Parameters:
drawableProviderObserver
- An observer to unregister from change notifications.
-
notifyDrawablesChanged
void notifyDrawablesChanged()
Notifies all registered 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 instead.
-
notifyDrawablesChanged
void notifyDrawablesChanged(@IntRange(from = 0) int pageIndex)
Notifies all registered 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.
-
-
-
-