Class PdfThumbnailGrid

  • All Implemented Interfaces:
    android.graphics.drawable.Drawable.Callback , android.view.KeyEvent.Callback , android.view.ViewManager , android.view.ViewParent , android.view.accessibility.AccessibilityEventSource , com.pspdfkit.internal.document.editor.OnFileWriteCompleteListener , com.pspdfkit.listeners.DocumentListener , com.pspdfkit.ui.PSPDFKitViews.PSPDFView , com.pspdfkit.ui.drawable.PdfDrawableManager

    
    public class PdfThumbnailGrid
    extends RelativeLayout implements PSPDFKitViews.PSPDFView, DocumentListener, PdfDrawableManager, OnFileWriteCompleteListener
                        

    Scrollable grid view of document pages.

    • Constructor Detail

      • PdfThumbnailGrid

        PdfThumbnailGrid(Context context)
      • PdfThumbnailGrid

        PdfThumbnailGrid(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
    • Method Detail

      • getDocumentEditorSavingToolbarHandler

        @Nullable() DocumentEditorSavingToolbarHandler getDocumentEditorSavingToolbarHandler()

        Returns document editor saving toolbar handler, may return null if document has not been set.

        Returns:

        document editor saving toolbar handler.

      • isDisplayed

         boolean isDisplayed()

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

      • getBackgroundColor

        @ColorInt() int getBackgroundColor()

        Returns the background color of the thumbnail grid.

        Returns:

        Thumbnail grid background color.

      • setBackgroundColor

         void setBackgroundColor(@ColorInt() int backgroundColor)

        Sets the background color of the thumbnail grid.

        Parameters:
        backgroundColor - Thumbnail grid background color.
      • getItemLabelTextStyle

        @StyleRes() int getItemLabelTextStyle()

        Returns the thumbnail grid item's label text style.

        Returns:

        Style resource for the item label.

      • setItemLabelTextStyle

         void setItemLabelTextStyle(@StyleRes() int itemLabelTextStyle)

        Sets the thumbnail grid item's label text style.

        Parameters:
        itemLabelTextStyle - Style resource for the item label.
      • getFilePicker

        @NonNull() 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.

      • setFilePicker

         void setFilePicker(@Nullable() 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.
      • isRedactionAnnotationPreviewEnabled

         boolean isRedactionAnnotationPreviewEnabled()

        Returns redaction annotation preview mode, false by default.

        Returns:

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

      • setRedactionAnnotationPreviewEnabled

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

        @DrawableRes() int getItemLabelBackground()

        Returns the thumbnail grid background label background.

        Returns:

        Thumbnail grid background label background resource drawable.

      • setItemLabelBackground

         void setItemLabelBackground(@DrawableRes() int itemLabelBackgroundDrawableRes)

        Sets the thumbnail grid background label background.

        Parameters:
        itemLabelBackgroundDrawableRes - Thumbnail grid background label background resource drawable.
      • addOnDocumentSavedListener

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

        @Nullable() 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.

      • setDocumentEditorSaveAsEnabled

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

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

        @UiThread() void onDocumentLoaded(@NonNull() 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.
      • onDocumentSave

         boolean onDocumentSave(@NonNull() PdfDocument document, @NonNull() 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.
        Returns:

        true if the document should be saved, false if saving should be cancelled.

      • onDocumentSaved

         void onDocumentSaved(@NonNull() PdfDocument document)

        Called after the document has been saved.

        Parameters:
        document - Instance of document that was saved.
      • onDocumentSaveCancelled

         void onDocumentSaveCancelled(PdfDocument document)

        Called if document saving has been cancelled.

        Parameters:
        document - Instance of document that was saved.
      • onPageClick

         boolean onPageClick(@NonNull() PdfDocument document, @IntRange(from = 0) int pageIndex, @Nullable() MotionEvent event, @Nullable() PointF pagePosition, @Nullable() 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.
        pagePosition - Tapped page position (in PDF page coordinates with origin on bottom left).
        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.

      • onDocumentClick

         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.

      • onPageChanged

         void onPageChanged(@NonNull() PdfDocument document, @IntRange(from = 0) int pageIndex)

        Called when user scrolled to a new page.

        Parameters:
        document - Currently opened document.
        pageIndex - Page number of new page.
      • onDocumentZoomed

         void onDocumentZoomed(@NonNull() PdfDocument document, @IntRange(from = 0) 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.
      • onPageUpdated

         void onPageUpdated(@NonNull() PdfDocument document, @IntRange(from = 0) 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.
      • show

         void show()

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

      • hide

         void hide()

        Called by the activity when the view should hide itself.

      • clearDocument

         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.

      • isShowPageLabels

         boolean isShowPageLabels()

        Returns true if page labels are shown, false otherwise.

        Returns:

        true if page labels are shown, false otherwise.

      • onDocumentSaved

         void onDocumentSaved()

        Called when saving a document in place is complete.

      • onDocumentExported

         void onDocumentExported(@NonNull() Uri destinationUri)

        Called when saving a document or exporting pages to a given destination is complete.

        Parameters:
        destinationUri - Destination Uri where the document is saved.
      • getSelectedPages

        @NonNull() 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

      • setNewPageFactory

         final void setNewPageFactory(@Nullable() 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 instances for the document editor.
      • setDocumentEditorEnabled

         void setDocumentEditorEnabled(boolean documentEditorEnabled)

        Enables/Disables document editor. This should be set before displaying . 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.
      • setShowPageLabels

         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.