public class

PdfThumbnailGrid

extends RelativeLayout
implements OnFileWriteCompleteListener DocumentListener PSPDFKitViews.PSPDFView PdfDrawableManager
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.RelativeLayout
         ↳ com.pspdfkit.ui.PdfThumbnailGrid

Class Overview

Scrollable grid view of document pages.

Summary

Nested Classes
interface PdfThumbnailGrid.OnDocumentSavedListener Listener for document saving inside PdfThumbnailGrid
interface PdfThumbnailGrid.OnPageClickListener Listener for observing a PdfThumbnailGrid page click. 
[Expand]
Inherited Constants
From class android.widget.RelativeLayout
From class android.view.ViewGroup
From class android.view.View
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
PdfThumbnailGrid(Context context)
PdfThumbnailGrid(Context context, AttributeSet attrs)
PdfThumbnailGrid(Context context, AttributeSet attrs, int defStyleAttr)
PdfThumbnailGrid(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
Public Methods
void addDrawableProvider(PdfDrawableProvider drawableProvider)
Adds a PdfDrawableProvider to be managed by this object.
void addOnDocumentSavedListener(PdfThumbnailGrid.OnDocumentSavedListener onDocumentSavedListener)
Adds a listener that will be notified about document saves inside the thumbnail grid.
void addOnPageClickListener(PdfThumbnailGrid.OnPageClickListener onPageClickListener)
Adds a listener that will be notified when a page on the ThumbnailGrid was clicked.
void addOnVisibilityChangedListener(OnVisibilityChangedListener listener)
Register a listener that would like to receive visibility change events.
void clearDocument()
Called by the activity when the view should unbind the previously set document.
void enterDocumentEditingMode()
Enters document editing mode.
void exitDocumentEditingMode()
Exits document editing mode.
View focusSearch(View focused, int direction)
int getBackgroundColor()
Returns the background color of the thumbnail grid.
NewPageDialog.Callback getDefaultNewPageDialogCallback()
Returns The default NewPageDialog.Callback that is used by default by the PdfThumbnailGrid.
PdfDocumentEditor getDocumentEditor()
Returns document editor to perform operations such as page manipulation, reordering and importing documents.
FilePicker getFilePicker()
Returns a file picker to use during a saving process.
int getItemLabelBackground()
Returns the thumbnail grid background label background.
int getItemLabelTextStyle()
Returns the thumbnail grid item's label text style.
PSPDFKitViews.Type getPSPDFViewType()
Returns the current type of this view.
Set<Integer> getSelectedPages()
Retrieves the currently selected pages of the thumbnail grid.
void hide()
Called by the activity when the view should hide itself.
boolean isDisplayed()
Called when the activity needs to know the visibility of this view.
boolean isDocumentEditorEnabled()
boolean isRedactionAnnotationPreviewEnabled()
Returns redaction annotation preview mode, false by default.
boolean isShowPageLabels()
Returns true if page labels are shown, false otherwise.
boolean onDocumentClick()
Called when the user taps / clicks on the document, not the page itself but on the side (if visible).
void onDocumentExported(Uri destinationUri)
void onDocumentLoadFailed(Throwable exception)
Called if document loading has failed.
void onDocumentLoaded(PdfDocument document)
Called when document is successfully loaded and the document view has been laid out.
boolean onDocumentSave(PdfDocument document, DocumentSaveOptions saveOptions)
Called before document will be saved.
void onDocumentSaveCancelled(PdfDocument document)
Called if document saving has been cancelled.
void onDocumentSaveFailed(PdfDocument document, Throwable exception)
Called if document saving has failed.
void onDocumentSaved()
void onDocumentSaved(PdfDocument document)
Called after the document has been saved.
void onDocumentZoomed(PdfDocument document, int pageIndex, float scaleFactor)
Called when a user zooms a document.
void onPageChanged(PdfDocument document, int pageIndex)
Called when user scrolled to a new page.
boolean onPageClick(PdfDocument document, int pageIndex, MotionEvent event, PointF pagePosition, Annotation clickedAnnotation)
Called when user taps / clicks on the page.
void onPageUpdated(PdfDocument document, int pageIndex)
Called when content of page with pageIndex has changed (for example due to annotation or form field being updated).
void removeDrawableProvider(PdfDrawableProvider drawableProvider)
Removes a previously added PdfDrawableProvider.
boolean removeOnDocumentSavedListener(PdfThumbnailGrid.OnDocumentSavedListener onDocumentSavedListener)
Removes a listener from the list of registered onDocumentSaved listeners
boolean removeOnDocumentSavedListener(PdfThumbnailGrid.OnPageClickListener onPageClickListener)
Removes a listener from the list of registered onPageClick listeners
void removeOnVisibilityChangedListener(OnVisibilityChangedListener listener)
Unregister a previously registered listener that no longer wants to receive visibility change events.
void setBackgroundColor(int backgroundColor)
Sets the background color of the thumbnail grid.
void setDocument(PdfDocument document, PdfConfiguration configuration)
Called when the document has been loaded and is going to be displayed.
void setDocumentEditorEnabled(boolean documentEditorEnabled)
Enables/Disables document editor.
void setDocumentEditorExportEnabled(boolean exportEnabled)
Enables/Disables document editor "Export pages" option in action bar.
void setDocumentEditorSaveAsEnabled(boolean saveAsEnabled)
Enables/Disables document editor "Save As" option in action bar.
void setFilePicker(FilePicker filePicker)
Sets a file picker to use during a saving process.
void setItemLabelBackground(int itemLabelBackgroundDrawableRes)
Sets the thumbnail grid background label background.
void setItemLabelTextStyle(int itemLabelTextStyle)
Sets the thumbnail grid item's label text style.
final void setNewPageFactory(NewPageFactory newPageFactory)
Sets a NewPageFactory that will be used by the document editor.
void setOnPageClickListener(PdfThumbnailGrid.OnPageClickListener onPageClickListener)
Sets the PdfThumbnailGrid.OnPageClickListener, replacing any previously set listener.
void setRedactionAnnotationPreviewEnabled(boolean enable)
Sets redaction annotations preview as redacted.
void setShowPageLabels(boolean showPageLabels)
Sets whether the page labels will be shown or just the page number.
void show()
Called by the activity when the view should make itself visible.
Protected Methods
boolean fitSystemWindows(Rect insets)
void onDetachedFromWindow()
Parcelable onSaveInstanceState()
[Expand]
Inherited Methods
From class android.widget.RelativeLayout
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.ViewManager
From interface android.view.ViewParent
From interface android.view.accessibility.AccessibilityEventSource
From interface com.pspdfkit.internal.document.editor.OnFileWriteCompleteListener
From interface com.pspdfkit.listeners.DocumentListener
From interface com.pspdfkit.ui.PSPDFKitViews.PSPDFView
From interface com.pspdfkit.ui.drawable.PdfDrawableManager

Public Constructors

public PdfThumbnailGrid (Context context)

public PdfThumbnailGrid (Context context, AttributeSet attrs)

public PdfThumbnailGrid (Context context, AttributeSet attrs, int defStyleAttr)

public PdfThumbnailGrid (Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)

Public Methods

public void addDrawableProvider (PdfDrawableProvider drawableProvider)

Adds a PdfDrawableProvider to be managed by this object. If the provider has been added previously, this method will be a no-op. Adding null is not allowed, and will result in an exception.

Parameters
drawableProvider PdfDrawableProvider whose drawable instances should be managed (e.g. rendered on screen).

public void addOnDocumentSavedListener (PdfThumbnailGrid.OnDocumentSavedListener onDocumentSavedListener)

Adds a listener that will be notified about document saves inside the thumbnail grid.

Parameters
onDocumentSavedListener Listener for document saves after clicking on the "Save" and "Save As" button in the document editing toolbar.

public void addOnPageClickListener (PdfThumbnailGrid.OnPageClickListener onPageClickListener)

Adds a listener that will be notified when a page on the ThumbnailGrid was clicked.

Parameters
onPageClickListener Listener to add.

public void addOnVisibilityChangedListener (OnVisibilityChangedListener listener)

Register a listener that would like to receive visibility change events. Whenever the visibility of a managed PSPDFKitViews.PSPDFView changes, all registered listeners will be notified.

Parameters
listener Listener to be added.

public void clearDocument ()

Called by the activity when the view should unbind the previously set document. This may be called in low-memory situations or prior to re-binding another document.

public void enterDocumentEditingMode ()

Enters document editing mode.

public void exitDocumentEditingMode ()

Exits document editing mode.

public View focusSearch (View focused, int direction)

public int getBackgroundColor ()

Returns the background color of the thumbnail grid.

Returns
  • Thumbnail grid background color.

public NewPageDialog.Callback getDefaultNewPageDialogCallback ()

Returns The default NewPageDialog.Callback that is used by default by the PdfThumbnailGrid. Can be used to manually restore the NewPageDialog when using a custom DialogNewPageFactory.

public PdfDocumentEditor getDocumentEditor ()

Returns document editor to perform operations such as page manipulation, reordering and importing documents.

Returns
  • document editor to perform operations on the current PDF document.

public FilePicker getFilePicker ()

Returns a file picker to use during a saving process. If not provided, a default implementation relying on Android Storage Access Framework will be returned. For more info about Android Storage Access Framework see Open files using storage access framework.

Returns
  • File picker to use during a saving process.

public int getItemLabelBackground ()

Returns the thumbnail grid background label background.

Returns
  • Thumbnail grid background label background resource drawable.

public int getItemLabelTextStyle ()

Returns the thumbnail grid item's label text style.

Returns
  • Style resource for the item label.

public PSPDFKitViews.Type getPSPDFViewType ()

Returns the current type of this view.

Returns

public Set<Integer> getSelectedPages ()

Retrieves the currently selected pages of the thumbnail grid.

Returns
  • A set containing the indices of the selected pages or an empty set otherwise

public void hide ()

Called by the activity when the view should hide itself.

public boolean isDisplayed ()

Called when the activity needs to know the visibility of this view. Returns true if this view is visible, otherwise returns false.

public boolean isDocumentEditorEnabled ()

public boolean isRedactionAnnotationPreviewEnabled ()

Returns redaction annotation preview mode, false by default.

Returns
  • true if redaction annotation preview mode is enabled, false otherwise.

public boolean isShowPageLabels ()

Returns true if page labels are shown, false otherwise.

Returns
  • true if page labels are shown, false otherwise.

public boolean onDocumentClick ()

Called when the user taps / clicks on the document, not the page itself but on the side (if visible).

Returns
  • true if tap is handled or false if PSPDFKit should execute it's default action.

public void onDocumentExported (Uri destinationUri)

public void onDocumentLoadFailed (Throwable exception)

Called if document loading has failed.

Parameters
exception Cause of the loading failure.

public void onDocumentLoaded (PdfDocument document)

Called when document is successfully loaded and the document view has been laid out. This has to be called on the main thread.

Parameters
document Loaded document instance.

public boolean onDocumentSave (PdfDocument document, DocumentSaveOptions saveOptions)

Called before document will be saved. This callback allows cancellation of the save process.

Parameters
document Instance of document to be saved.
saveOptions Save options to be applied to the document. You may change parameters on this object to control how document is saved.
Returns
  • true if the document should be saved, false if saving should be cancelled.

public void onDocumentSaveCancelled (PdfDocument document)

Called if document saving has been cancelled.

Parameters
document Instance of document that was saved.

public void onDocumentSaveFailed (PdfDocument document, Throwable exception)

Called if document saving has failed.

Parameters
exception Cause of the saving failure if applicable.

public void onDocumentSaved ()

public void onDocumentSaved (PdfDocument document)

Called after the document has been saved.

Parameters
document Instance of document that was saved.

public void onDocumentZoomed (PdfDocument document, int pageIndex, float scaleFactor)

Called when a user zooms a document.

Parameters
document Current document.
pageIndex The number of the page that the was zoomed.
scaleFactor The current scale factor.

public void onPageChanged (PdfDocument document, int pageIndex)

Called when user scrolled to a new page.

Parameters
document Currently opened document.
pageIndex Page number of new page.

public boolean onPageClick (PdfDocument document, int pageIndex, MotionEvent event, PointF pagePosition, Annotation clickedAnnotation)

Called when user taps / clicks on the page.

Parameters
document Currently opened document.
pageIndex Page number of the page being tapped.
event MotionEvent that triggered this page click. May be null if this page click was triggered from keyboard or accessibility event.
pagePosition Tapped page position (in PDF page coordinates with origin on bottom left). Coordinates passed here may exceed the page size (which is returned by getPageSize(int)) and can also be negative. If the click was triggered by the keyboard, pagePosition will be null.
clickedAnnotation Annotation that was tapped, or null if no annotation was tapped.
Returns
  • true if tap was handled by this DocumentListener and should not be handled by PSPDFKit anymore. If returning false PSPDFKit will continue executing it's default action.

public void onPageUpdated (PdfDocument document, int pageIndex)

Called when content of page with pageIndex has changed (for example due to annotation or form field being updated). All views displaying this page need to refresh.

Parameters
pageIndex Page index of the updated page. Page index is 0-based.

public void removeDrawableProvider (PdfDrawableProvider drawableProvider)

Removes a previously added PdfDrawableProvider. If the provider hasn't been added previously, this method will be a no-op.

Parameters
drawableProvider PdfDrawableProvider that should be removed. Must be non-null.

public boolean removeOnDocumentSavedListener (PdfThumbnailGrid.OnDocumentSavedListener onDocumentSavedListener)

Removes a listener from the list of registered onDocumentSaved listeners

Parameters
onDocumentSavedListener Listener to remove
Returns
  • true if the listener was removed

public boolean removeOnDocumentSavedListener (PdfThumbnailGrid.OnPageClickListener onPageClickListener)

Removes a listener from the list of registered onPageClick listeners

Parameters
onPageClickListener Listener to remove
Returns
  • true if the listener was removed, otherwise false

public void removeOnVisibilityChangedListener (OnVisibilityChangedListener listener)

Unregister a previously registered listener that no longer wants to receive visibility change events.

Parameters
listener Listener to be removed.

public void setBackgroundColor (int backgroundColor)

Sets the background color of the thumbnail grid.

Parameters
backgroundColor Thumbnail grid background color.

public void setDocument (PdfDocument document, PdfConfiguration configuration)

Called when the document has been loaded and is going to be displayed. This has to be called on the main thread.

Parameters
document Loaded PdfDocument.
configuration Containing document and presentation settings.

public void setDocumentEditorEnabled (boolean documentEditorEnabled)

Enables/Disables document editor. This should be set before displaying PdfThumbnailGrid. If enabled, a floating action button will be displayed, through which a document editing mode can be entered.

Parameters
documentEditorEnabled true to enable document editing mode, false to disable it.

public void setDocumentEditorExportEnabled (boolean exportEnabled)

Enables/Disables document editor "Export pages" option in action bar.

Parameters
exportEnabled true to enable document editing page export option, false to disable it.

public void setDocumentEditorSaveAsEnabled (boolean saveAsEnabled)

Enables/Disables document editor "Save As" option in action bar. If disabled, clicking on Done button will overwrite the document automatically.

Parameters
saveAsEnabled true to enable document editing "Save As" option, false to disable it.

public void setFilePicker (FilePicker filePicker)

Sets a file picker to use during a saving process. If not provided, a default implementation relying on Android Storage Access Framework will be used. For more info about Android Storage Access Framework see Open files using storage access framework.

Parameters
filePicker File picker to use during a saving process.

public void setItemLabelBackground (int itemLabelBackgroundDrawableRes)

Sets the thumbnail grid background label background.

Parameters
itemLabelBackgroundDrawableRes Thumbnail grid background label background resource drawable.

public void setItemLabelTextStyle (int itemLabelTextStyle)

Sets the thumbnail grid item's label text style.

Parameters
itemLabelTextStyle Style resource for the item label.

public final void setNewPageFactory (NewPageFactory newPageFactory)

Sets a NewPageFactory that will be used by the document editor. The factory will be called every time the user wants to add a new page to the edited document. Setting it to null will tell the document editor to use the default factory (which is using a page creation dialog).

Note: When setting a factory this must be done each time the activity is recreated, since it won't be retained.

Parameters
newPageFactory Factory that will return NewPage instances for the document editor.

public void setOnPageClickListener (PdfThumbnailGrid.OnPageClickListener onPageClickListener)

Sets the PdfThumbnailGrid.OnPageClickListener, replacing any previously set listener.

Parameters
onPageClickListener PdfThumbnailGrid.OnPageClickListener for receiving events of this view. Use addOnPageClickListener(OnPageClickListener) instead.

public void setRedactionAnnotationPreviewEnabled (boolean enable)

Sets redaction annotations preview as redacted.

Parameters
enable true to show redaction annotations as redacted, false to show them as marks.

public void setShowPageLabels (boolean showPageLabels)

Sets whether the page labels will be shown or just the page number.

Parameters
showPageLabels whether to show page labels or just the page number.

public void show ()

Called by the activity when the view should make itself visible.

Protected Methods

protected boolean fitSystemWindows (Rect insets)

protected void onDetachedFromWindow ()

protected Parcelable onSaveInstanceState ()