public final class

PdfSearchViewInline

extends DocumentListenerFrameLayout
implements PSPDFKitViews.PSPDFView PdfSearchView
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.FrameLayout
         ↳ com.pspdfkit.internal.views.utils.DocumentListenerFrameLayout
           ↳ com.pspdfkit.ui.search.PdfSearchViewInline

Class Overview

Search view to be placed in the action bar of a AppCompatActivity.

Summary

Constants
int INLINE_SEARCH_SHOW_DELAY Delay for showing the inline search after touching the action.
String LOG_TAG
int SEARCH_DELAY Delay waited after a call to performSearch(String) before starting the search.
[Expand]
Inherited Constants
From class android.view.ViewGroup
From class android.view.View
Fields
protected int currentPage Tracks current page of the document.
protected PdfDocument document
protected EditText inputField
protected boolean isDisplayed
protected final OnVisibilityChangedListenerManager listeners
protected Disposable searchInProgress
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
PdfSearchViewInline(Context context)
PdfSearchViewInline(Context context, AttributeSet attrs)
Public Methods
void addOnVisibilityChangedListener(OnVisibilityChangedListener listener)
Adds a new listener for visibility changes.
void clearDocument()
Called by the activity when the view should unbind the previously set document.
void clearOnVisibilityChangedListeners()
Removes all previously registered visibility change listeners.
final void clearSearch()
Clears the search input field as well as any previously collected search results.
int getBackIconColorTint()
Returns the icon color for the back icon.
int getHintTextColor()
Returns hint text color for the inline search text input field.
Integer getMaxSearchResults()
Returns the maximum count of search results, null if not set, or SearchConfiguration#UNLIMITED_SEARCH_RESULTS if limiting is turned off.
int getNavigationTextColor()
Returns the text color for the navigation text (that states the current displayed result).
int getNextIcon()
Returns next search result button icon.
int getNextIconColorTint()
Returns the icon color for the next search result icon.
PSPDFKitViews.Type getPSPDFViewType()
Returns the current type of this view.
int getPrevIcon()
Returns previous search result button icon.
int getPrevIconColorTint()
Returns the icon color for the previous search result icon.
final List<SearchResult> getSearchResults()
Returns the current list of search results (may be empty if there are no search hits or search still in progress), or null if no search was performed.
int getSnippetLength()
Returns the number of preview characters extracted with every search result.
int getStartSearchChars()
Returns the number of characters that need to be entered for the search to start.
int getTextColor()
Returns text color for the inline search text input field.
void hide()
Hides the view in the parent.
boolean isDisplayed()
Called when the activity needs to know the visibility of this view.
boolean isStartSearchOnCurrentPage()
Returns whether the search should start on the current page or not.
void onMoreSearchResults(List<SearchResult> results)
Called when another chunk of search results is ready.
void onPageChanged(PdfDocument document, int pageIndex)
Called when user scrolled to a new page.
void onSearchCanceled()
Called when search has been cancelled.
void onSearchComplete()
Called when searching has finished.
void onSearchError(Throwable ex)
Called in case of an error that prevented searching the document.
void onSearchStarted(String query)
Called when a fresh search has been started.
boolean onTouchEvent(MotionEvent event)
final void performSearch(String searchQuery, EnumSet<CompareOptions> compareOptions)
Performs the search action using the provided extra compare options.
final void performSearch(String searchQuery)
Performs the search action.
void removeOnVisibilityChangedListener(OnVisibilityChangedListener listener)
Removes added listener for visibility changes.
void setBackIconColorTint(int backIconColorTint)
Sets the icon color for the back icon.
void setDocument(PdfDocument document, PdfConfiguration configuration)
Called when the document has been loaded and is going to be displayed.
void setHintTextColor(int hintTextColor)
Sets hint text color for the inline search text input field.
void setInputFieldText(String text, boolean startSearch)
Inserts text in the search input field and optionally starts search.
void setMaxSearchResults(Integer maxSearchResults)
Sets maximum number of search results.
void setNavigationTextColor(int navigationTextColor)
Sets the text color for the navigation text (that states the current displayed result).
void setNextIcon(int nextIcon)
Sets next search result button icon.
void setNextIconColorTint(int nextIconColorTint)
Sets the icon color for the next search result icon.
void setPrevIcon(int prevIcon)
Sets previous search result button icon.
void setPrevIconColorTint(int prevIconColorTint)
Sets the icon color for the previous search result icon.
void setSearchConfiguration(SearchConfiguration searchConfiguration)
Sets the search configuration to this search view.
final void setSearchViewListener(PdfSearchView.Listener searchViewListener)
Sets a listener to be notified of search events on this view.
void setSnippetLength(int snippetLength)
Sets the number of preview characters extracted with every search result.
void setStartSearchChars(int startSearchChars)
Sets the number of characters that need to be entered for the search to start.
void setStartSearchOnCurrentPage(boolean startSearchOnCurrentPage)
Sets whether the search should start on the current page or not.
void setTextColor(int textColor)
Sets text color for the inline search text input field.
void show()
Shows the view in the parent.
Protected Methods
void applyTheme()
void clearSearchResults()
When called subclasses have to update their UI and remove any previously collected search results from memory.
final void dispatchSearchResultSelected(SearchResult selectedSearchResult)
Subclasses may call this method providing a selectedSearchResult (e.g.
void hideKeyboard()
void init()
void onDetachedFromWindow()
void onRestoreInstanceState(Parcelable state)
Parcelable onSaveInstanceState()
void showKeyboard()
[Expand]
Inherited Methods
From class com.pspdfkit.internal.views.utils.DocumentListenerFrameLayout
From class android.widget.FrameLayout
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.listeners.DocumentListener
From interface com.pspdfkit.ui.PSPDFKitViews.PSPDFView
From interface com.pspdfkit.ui.search.PdfSearchView

Constants

public static final int INLINE_SEARCH_SHOW_DELAY

Delay for showing the inline search after touching the action.

Constant Value: 300 (0x0000012c)

protected static final String LOG_TAG

Constant Value: "PSPDFKit.SearchView"

public static final int SEARCH_DELAY

Delay waited after a call to performSearch(String) before starting the search.

Constant Value: 300 (0x0000012c)

Fields

protected int currentPage

Tracks current page of the document.

protected PdfDocument document

protected EditText inputField

protected boolean isDisplayed

protected final OnVisibilityChangedListenerManager listeners

protected Disposable searchInProgress

Public Constructors

public PdfSearchViewInline (Context context)

public PdfSearchViewInline (Context context, AttributeSet attrs)

Public Methods

public void addOnVisibilityChangedListener (OnVisibilityChangedListener listener)

Adds a new listener for visibility changes. If the listener has already been added previously, this method will be a no-op. Adding null is not allowed, and will result in an exception.

Parameters
listener OnVisibilityChangedListener that should be notified. Must be non-null.

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 clearOnVisibilityChangedListeners ()

Removes all previously registered visibility change listeners. To remove just one listener use removeOnVisibilityChangedListener(OnVisibilityChangedListener). Upon calling this method no listeners will be notified of any changes.

public final void clearSearch ()

Clears the search input field as well as any previously collected search results. This will also cancel any currently running search operation. Implementations of PdfSearchView need to call onSearchCleared() on the current listener.

public int getBackIconColorTint ()

Returns the icon color for the back icon.

Returns
  • Tint color for the back icon.

public int getHintTextColor ()

Returns hint text color for the inline search text input field.

Returns
  • Input field hint text color.

public Integer getMaxSearchResults ()

Returns the maximum count of search results, null if not set, or SearchConfiguration#UNLIMITED_SEARCH_RESULTS if limiting is turned off.

public int getNavigationTextColor ()

Returns the text color for the navigation text (that states the current displayed result).

Returns
  • Text color for the navigation text.

public int getNextIcon ()

Returns next search result button icon.

Returns
  • Next search result button resource drawable.

public int getNextIconColorTint ()

Returns the icon color for the next search result icon.

Returns
  • Tint color for the next search result icon.

public PSPDFKitViews.Type getPSPDFViewType ()

Returns the current type of this view.

Returns

public int getPrevIcon ()

Returns previous search result button icon.

Returns
  • Previous search result button resource drawable.

public int getPrevIconColorTint ()

Returns the icon color for the previous search result icon.

Returns
  • Tint color for the previous search result icon.

public final List<SearchResult> getSearchResults ()

Returns the current list of search results (may be empty if there are no search hits or search still in progress), or null if no search was performed. Note that the returned list is immutable.

Returns
  • List of search results, or null.

public int getSnippetLength ()

Returns the number of preview characters extracted with every search result. This defaults to {@value com.pspdfkit.configuration.search.SearchConfiguration#DEFAULT_SNIPPET_LENGTH}.

public int getStartSearchChars ()

Returns the number of characters that need to be entered for the search to start. This defaults to {@value com.pspdfkit.configuration.search.SearchConfiguration#DEFAULT_START_SEARCH_CHARS}.

public int getTextColor ()

Returns text color for the inline search text input field.

Returns
  • Input field text color.

public void hide ()

Hides the view in the parent.

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 isStartSearchOnCurrentPage ()

Returns whether the search should start on the current page or not. This defaults to {@value com.pspdfkit.configuration.search.SearchConfiguration#DEFAULT_START_SEARCH_ON_CURRENT_PAGE}.

public void onMoreSearchResults (List<SearchResult> results)

Called when another chunk of search results is ready.

Parameters
results List of search results.

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 void onSearchCanceled ()

Called when search has been cancelled.

public void onSearchComplete ()

Called when searching has finished.

public void onSearchError (Throwable ex)

Called in case of an error that prevented searching the document.

Parameters
ex Throwable containing the search error reason.

public void onSearchStarted (String query)

Called when a fresh search has been started.

Parameters
query Search term.

public boolean onTouchEvent (MotionEvent event)

public final void performSearch (String searchQuery, EnumSet<CompareOptions> compareOptions)

Performs the search action using the provided extra compare options.

Parameters
searchQuery String query to be searched.
compareOptions Compare options used to perform the search action. When null it will default the default options specified by SearchOptions.Builder.

public final void performSearch (String searchQuery)

Performs the search action.

Parameters
searchQuery String query to be searched.

public void removeOnVisibilityChangedListener (OnVisibilityChangedListener listener)

Removes added listener for visibility changes. Upon calling this method the listener will no longer be notified of any changes. If the listener has not been added, this method will be a no-op. Adding null is not allowed,and will result in an exception.

Parameters
listener OnVisibilityChangedListener that should be removed. Must be non-null.

public void setBackIconColorTint (int backIconColorTint)

Sets the icon color for the back icon.

Parameters
backIconColorTint Tint color for the back icon.

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 setHintTextColor (int hintTextColor)

Sets hint text color for the inline search text input field.

Parameters
hintTextColor Input field hint text color.

public void setInputFieldText (String text, boolean startSearch)

Inserts text in the search input field and optionally starts search.

Parameters
text Search text.
startSearch Hides keyboard and starts search if true.

public void setMaxSearchResults (Integer maxSearchResults)

Sets maximum number of search results. Defaults to {@value SearchOptions.Builder#MAX_SEARCH_RESULTS} or {@value SearchOptions.Builder#MAX_SEARCH_RESULTS_LOW_MEM} on devices with little of RAM.

Parameters
maxSearchResults Maximum count of search results, null to fallback to default or SearchConfiguration#UNLIMITED_SEARCH_RESULTS to turn off limiting.

public void setNavigationTextColor (int navigationTextColor)

Sets the text color for the navigation text (that states the current displayed result).

Parameters
navigationTextColor Text color for the navigation text.

public void setNextIcon (int nextIcon)

Sets next search result button icon.

Parameters
nextIcon Next search result button resource drawable.

public void setNextIconColorTint (int nextIconColorTint)

Sets the icon color for the next search result icon.

Parameters
nextIconColorTint Tint color for the next search result icon.

public void setPrevIcon (int prevIcon)

Sets previous search result button icon.

Parameters
prevIcon Previous search result button resource drawable.

public void setPrevIconColorTint (int prevIconColorTint)

Sets the icon color for the previous search result icon.

Parameters
prevIconColorTint Tint color for the previous search result icon.

public void setSearchConfiguration (SearchConfiguration searchConfiguration)

Sets the search configuration to this search view.

Parameters
searchConfiguration Search configuration to be set for this AbstractPdfSearchView.

public final void setSearchViewListener (PdfSearchView.Listener searchViewListener)

Sets a listener to be notified of search events on this view. May be null to remove any previously set listener.

Parameters
searchViewListener A Listener which should be notified of search events, or null to remove a previously registered listener.

public void setSnippetLength (int snippetLength)

Sets the number of preview characters extracted with every search result.

Parameters
snippetLength Number of characters, defaults to {@value com.pspdfkit.configuration.search.SearchConfiguration#DEFAULT_SNIPPET_LENGTH}.

public void setStartSearchChars (int startSearchChars)

Sets the number of characters that need to be entered for the search to start.

Parameters
startSearchChars Number of characters needed to trigger the search, defaults to {@value com.pspdfkit.configuration.search.SearchConfiguration#DEFAULT_START_SEARCH_CHARS}.

public void setStartSearchOnCurrentPage (boolean startSearchOnCurrentPage)

Sets whether the search should start on the current page or not. This defaults to {@value com.pspdfkit.configuration.search.SearchConfiguration#DEFAULT_START_SEARCH_ON_CURRENT_PAGE}.

Parameters
startSearchOnCurrentPage true to start search on the current page, false to start from the beginning of the document.

public void setTextColor (int textColor)

Sets text color for the inline search text input field.

Parameters
textColor Input field text color.

public void show ()

Shows the view in the parent.

Protected Methods

protected void applyTheme ()

protected void clearSearchResults ()

When called subclasses have to update their UI and remove any previously collected search results from memory.

protected final void dispatchSearchResultSelected (SearchResult selectedSearchResult)

Subclasses may call this method providing a selectedSearchResult (e.g. from user interaction) so that any registered listener may be notified of this event. May also receive null in case the previous selection was cleared.

protected void hideKeyboard ()

protected void init ()

protected void onDetachedFromWindow ()

protected void onRestoreInstanceState (Parcelable state)

protected Parcelable onSaveInstanceState ()

protected void showKeyboard ()