Class PdfScrollableThumbnailBar
-
- All Implemented Interfaces:
-
android.graphics.drawable.Drawable.Callback
,android.view.KeyEvent.Callback
,android.view.ViewManager
,android.view.ViewParent
,android.view.accessibility.AccessibilityEventSource
,com.pspdfkit.listeners.DocumentListener
,com.pspdfkit.ui.PSPDFKitViews.PSPDFView
,com.pspdfkit.ui.thumbnail.PdfThumbnailBarController
,com.pspdfkit.ui.thumbnail.ThumbnailAdapter.OnThumbnailClickListener
public class PdfScrollableThumbnailBar extends DocumentListenerViewGroup implements PSPDFKitViews.PSPDFView, ThumbnailAdapter.OnThumbnailClickListener, PdfThumbnailBarController
Scrollable bar showing thumbnails of pages, with larger images.
-
-
Field Summary
Fields Modifier and Type Field Description public int
thumbnailHeight
public int
thumbnailWidth
public int
backgroundColor
-
Constructor Summary
Constructors Constructor Description PdfScrollableThumbnailBar(Context context)
PdfScrollableThumbnailBar(Context context, AttributeSet attrs)
PdfScrollableThumbnailBar(Context context, AttributeSet attrs, int defStyleAttr)
PdfScrollableThumbnailBar(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
-
Method Summary
Modifier and Type Method Description int
getThumbnailHeight()
Returns the height of the thumbnails in thumbnail bar. void
setThumbnailHeight(@IntRange(from = 1) int thumbnailHeight)
Sets the height of the thumbnails in thumbnail bar. int
getThumbnailWidth()
Returns the width of the thumbnails in thumbnail bar. void
setThumbnailWidth(@IntRange(from = 1) int thumbnailWidth)
Sets the width of the thumbnails in thumbnail bar. int
getBackgroundColor()
void
setBackgroundColor(@ColorInt() int color)
boolean
isBackgroundTransparent()
int
getThumbnailBorderColor()
Returns the border color for the thumbnails in the thumbnail bar. int
getSelectedThumbnailBorderColor()
Returns the border color for the selected thumbnail in the thumbnail bar. void
setSelectedThumbnailBorderColor(@ColorInt() int borderColor)
Sets the border color for the selected thumbnail in the thumbnail bar. boolean
isRedactionAnnotationPreviewEnabled()
Returns redaction annotation preview mode, false
by default.void
setRedactionAnnotationPreviewEnabled(boolean enable)
Sets redaction annotations preview as redacted. void
setThumbnailBorderColor(@ColorInt() int borderColor)
Sets the border color for the thumbnails in the thumbnail bar. boolean
isUsingPageAspectRatio()
Returns whether the page aspect ratio is used to determine the thumbnail width. void
setUsePageAspectRatio(boolean usePageAspectRatio)
Configures the thumbnail bar to use the page aspect ratio to calculate the thumbnail width. void
setDrawableProviders(List<PdfDrawableProvider> drawableProviders)
Sets PdfDrawableProviders to provide custom PdfDrawable to be displayed in a thumbnail bar page items. DocumentListener
getDocumentListener()
void
setDocument(@NonNull() PdfDocument document, @NonNull() PdfConfiguration configuration)
Called when the document
has been loaded and is going to be displayed.void
addOnVisibilityChangedListener(@NonNull() OnVisibilityChangedListener listener)
Register a listener
that would like to receive visibility change events.void
removeOnVisibilityChangedListener(@NonNull() OnVisibilityChangedListener listener)
Unregister a previously registered listener
that no longer wants to receive visibility change events.void
show()
No-op for PdfScrollableThumbnailBar. void
hide()
No-op for PdfScrollableThumbnailBar. void
clearDocument()
Called by the activity when the view should unbind the previously set document. boolean
isDisplayed()
Called when the activity needs to know the visibility of this view. PSPDFKitViews.Type
getPSPDFViewType()
Returns the current type of this view. void
onPageChanged(@NonNull() PdfDocument document, int pageIndex)
Called when user scrolled to a new page. 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). int
getItemCount()
int
getSelectedPage()
void
onThumbnailChanged(@NonNull() View view, @IntRange(from = 0) int pageIndex)
Called whenever the user touched on a thumbnail, selecting a different page. void
setOnPageChangedListener(@Nullable() PdfThumbnailBar.OnPageChangedListener onPageChangedListener)
Sets a listener to be notified of page changing events. -
-
Constructor Detail
-
PdfScrollableThumbnailBar
PdfScrollableThumbnailBar(Context context)
-
PdfScrollableThumbnailBar
PdfScrollableThumbnailBar(Context context, AttributeSet attrs)
-
PdfScrollableThumbnailBar
PdfScrollableThumbnailBar(Context context, AttributeSet attrs, int defStyleAttr)
-
PdfScrollableThumbnailBar
PdfScrollableThumbnailBar(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
-
-
Method Detail
-
getThumbnailHeight
@IntRange(from = 1) int getThumbnailHeight()
Returns the height of the thumbnails in thumbnail bar.
- Returns:
Height of thumbnails in pixels.
-
setThumbnailHeight
void setThumbnailHeight(@IntRange(from = 1) int thumbnailHeight)
Sets the height of the thumbnails in thumbnail bar.
- Parameters:
thumbnailHeight
- Height of thumbnails in pixels.
-
getThumbnailWidth
@IntRange(from = 1) int getThumbnailWidth()
Returns the width of the thumbnails in thumbnail bar. In the case where isUsingPageAspectRatio is
true
this will return the actual width of the first thumbnail.- Returns:
Width of thumbnails in pixels.
-
setThumbnailWidth
void setThumbnailWidth(@IntRange(from = 1) int thumbnailWidth)
Sets the width of the thumbnails in thumbnail bar. This has no effect if isUsingPageAspectRatio is set to
true
.- Parameters:
thumbnailWidth
- Width of thumbnails in pixels.
-
getBackgroundColor
int getBackgroundColor()
-
setBackgroundColor
void setBackgroundColor(@ColorInt() int color)
-
isBackgroundTransparent
boolean isBackgroundTransparent()
-
getThumbnailBorderColor
@ColorInt() int getThumbnailBorderColor()
Returns the border color for the thumbnails in the thumbnail bar.
- Returns:
Border colors of thumbnails.
-
getSelectedThumbnailBorderColor
@ColorInt() int getSelectedThumbnailBorderColor()
Returns the border color for the selected thumbnail in the thumbnail bar.
- Returns:
Border colors of selected thumbnail.
-
setSelectedThumbnailBorderColor
void setSelectedThumbnailBorderColor(@ColorInt() int borderColor)
Sets the border color for the selected thumbnail in the thumbnail bar.
- Parameters:
borderColor
- Border colors of selected thumbnail.
-
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.
-
setThumbnailBorderColor
void setThumbnailBorderColor(@ColorInt() int borderColor)
Sets the border color for the thumbnails in the thumbnail bar.
- Parameters:
borderColor
- Border colors of thumbnails.
-
isUsingPageAspectRatio
boolean isUsingPageAspectRatio()
Returns whether the page aspect ratio is used to determine the thumbnail width.
- Returns:
true
if the thumbnail width is calculated based on the page aspect ratio and thumbnail height,false
if the thumbnail width is used as configured.
-
setUsePageAspectRatio
void setUsePageAspectRatio(boolean usePageAspectRatio)
Configures the thumbnail bar to use the page aspect ratio to calculate the thumbnail width.
- Parameters:
usePageAspectRatio
-true
to automatically calculate the thumbnail width based on the page aspect ratio and thumbnail height,false
to use the configured thumbnail width.
-
setDrawableProviders
void setDrawableProviders(List<PdfDrawableProvider> drawableProviders)
Sets PdfDrawableProviders to provide custom PdfDrawable to be displayed in a thumbnail bar page items.
-
getDocumentListener
@NonNull() DocumentListener getDocumentListener()
-
setDocument
@UiThread() void setDocument(@NonNull() PdfDocument document, @NonNull() 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.
-
addOnVisibilityChangedListener
void addOnVisibilityChangedListener(@NonNull() OnVisibilityChangedListener listener)
Register a
listener
that would like to receive visibility change events. Whenever the visibility of a managed PSPDFView changes, all registered listeners will be notified.- Parameters:
listener
- Listener to be added.
-
removeOnVisibilityChangedListener
void removeOnVisibilityChangedListener(@NonNull() OnVisibilityChangedListener listener)
Unregister a previously registered
listener
that no longer wants to receive visibility change events.- Parameters:
listener
- Listener to be removed.
-
show
void show()
No-op for PdfScrollableThumbnailBar.
-
hide
void hide()
No-op for PdfScrollableThumbnailBar.
-
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.
-
isDisplayed
boolean isDisplayed()
Called when the activity needs to know the visibility of this view. Returns
true
if this view is visible, otherwise returnsfalse
.
-
getPSPDFViewType
@NonNull() PSPDFKitViews.Type getPSPDFViewType()
Returns the current type of this view.
- Returns:
Any of Type.
-
onPageChanged
void onPageChanged(@NonNull() PdfDocument document, int pageIndex)
Called when user scrolled to a new page.
- Parameters:
document
- Currently opened document.pageIndex
- Page number of new page.
-
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.
-
getItemCount
int getItemCount()
-
getSelectedPage
int getSelectedPage()
-
onThumbnailChanged
void onThumbnailChanged(@NonNull() View view, @IntRange(from = 0) int pageIndex)
Called whenever the user touched on a thumbnail, selecting a different page. The thumbnail bar won't update its internal state (i.e. the currently shown highlighted page) after calling this method, but will wait for a subsequent call to onPageChanged before updating.
- Parameters:
view
- View that triggered this event.pageIndex
- Number of the selected page.
-
setOnPageChangedListener
void setOnPageChangedListener(@Nullable() PdfThumbnailBar.OnPageChangedListener onPageChangedListener)
Sets a listener to be notified of page changing events. Calling this method will replace any previously set listener. You may provide
null
to clear the listener.- Parameters:
onPageChangedListener
- OnPageChangedListener that should be notified, ornull
to clear the listener.
-
-
-
-