java.lang.Object | |||||
↳ | android.view.View | ||||
↳ | android.view.ViewGroup | ||||
↳ | android.widget.FrameLayout | ||||
↳ | com.pspdfkit.internal.views.utils.DocumentListenerFrameLayout | ||||
↳ | com.pspdfkit.ui.search.PdfSearchViewModular |
Search view sitting inside a panel that slides in above the rest of the content.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | LOG_TAG | ||||||||||
int | SEARCH_DELAY | Delay waited after a call to performSearch(String) before starting the search. |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
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 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
PdfSearchViewModular(Context context) | |||||||||||
PdfSearchViewModular(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 |
getBackgroundColor()
Returns background color of the modular search view.
| ||||||||||
int |
getHighlightBackgroundColor()
Returns the background color of the highlighted search result.
| ||||||||||
int |
getHighlightBorderColor()
Returns the border color of the highlighted search result.
| ||||||||||
int |
getHighlightTextColor()
Returns the text color of the highlighted search result.
| ||||||||||
int |
getInputFieldBackgroundColor()
Returns modular search input field background color.
| ||||||||||
int |
getInputFieldHintColor()
Returns modular search input field hint text color.
| ||||||||||
int |
getInputFieldTextColor()
Returns modular search input field text color.
| ||||||||||
int |
getListItemBackgroundColor()
Returns the background color of the list items.
| ||||||||||
void |
getListItemBackgroundColor(int listItemBackgroundColor)
Sets the background color of the list items.
| ||||||||||
int |
getListItemSubtitleColor()
Returns the text color of the list item subtitle.
| ||||||||||
int |
getListItemTitleColor()
Returns the title color of the list items.
| ||||||||||
int |
getListSelector()
Returns the list item selector.
| ||||||||||
Integer |
getMaxSearchResults()
Returns the maximum count of search results,
null if not set, or SearchConfiguration#UNLIMITED_SEARCH_RESULTS if limiting is turned off. | ||||||||||
PSPDFKitViews.Type |
getPSPDFViewType()
Returns the current type of this view.
| ||||||||||
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 |
getSeparatorColor()
Returns the input field separator color.
| ||||||||||
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.
| ||||||||||
void |
hide()
Hides the modular search view.
| ||||||||||
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 |
setBackgroundColor(int backgroundColor)
Sets background color of the modular search view.
| ||||||||||
void |
setDocument(PdfDocument document, PdfConfiguration configuration)
Called when the
document has been loaded and is going to be displayed. | ||||||||||
void |
setHighlightBackgroundColor(int highlightBackgroundColor)
Sets the background color of the highlighted search result.
| ||||||||||
void |
setHighlightBorderColor(int highlightBorderColor)
Sets the border color of the highlighted search result.
| ||||||||||
void |
setHighlightTextColor(int highlightTextColor)
Sets the text color of the highlighted search result.
| ||||||||||
void |
setInputFieldBackgroundColor(int inputFieldBackgroundColor)
Sets modular search input field background color.
| ||||||||||
void |
setInputFieldHintColor(int inputFieldHintColor)
Sets modular search input field hint text color.
| ||||||||||
void |
setInputFieldText(String text, boolean startSearch)
Inserts text in the search input field and optionally starts search.
| ||||||||||
void |
setInputFieldTextColor(int inputFieldTextColor)
Sets modular search input field text color.
| ||||||||||
void |
setListItemSubtitleColor(int listItemSubtitleColor)
Sets the text color of the list item subtitle.
| ||||||||||
void |
setListItemTitleColor(int listItemTitleColor)
Sets the title color of the list items.
| ||||||||||
void |
setListSelector(int listSelector)
Sets the list item selector.
| ||||||||||
void |
setMaxSearchResults(Integer maxSearchResults)
Sets maximum number of search results.
| ||||||||||
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 |
setSeparatorColor(int separatorColor)
Sets the input field separator color.
| ||||||||||
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 |
show()
Shows the modular search view.
|
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. | ||||||||||
boolean | fitSystemWindows(Rect insets) | ||||||||||
void | hideKeyboard() | ||||||||||
void | init() | ||||||||||
void | onDetachedFromWindow() | ||||||||||
void | onMeasure(int widthMeasureSpec, int heightMeasureSpec) | ||||||||||
void | onRestoreInstanceState(Parcelable state) | ||||||||||
Parcelable | onSaveInstanceState() | ||||||||||
void | showKeyboard() |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() |
Delay waited after a call to performSearch(String)
before starting the search.
Tracks current page of the document.
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.
listener | OnVisibilityChangedListener that should be notified. Must be non-null. |
---|
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.
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.
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.
Returns background color of the modular search view.
Returns the background color of the highlighted search result.
Returns the border color of the highlighted search result.
Returns the text color of the highlighted search result.
Returns modular search input field background color.
Returns modular search input field hint text color.
Returns modular search input field text color.
Returns the background color of the list items.
Sets the background color of the list items.
listItemBackgroundColor | Background color of the list items. |
---|
Returns the text color of the list item subtitle.
Returns the title color of the list items.
Returns the list item selector.
Returns the maximum count of search results, null
if not set, or SearchConfiguration#UNLIMITED_SEARCH_RESULTS if limiting is turned off.
Returns the current type of this view.
PSPDFKitViews.Type
.
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.
null
.
Returns the input field separator color.
Returns the number of preview characters extracted with every search result. This defaults to {@value com.pspdfkit.configuration.search.SearchConfiguration#DEFAULT_SNIPPET_LENGTH}.
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}.
Hides the modular search view.
Called when the activity needs to know the visibility of this view. Returns true
if this view is visible, otherwise returns false
.
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}.
Called when another chunk of search results is ready.
results | List of search results. |
---|
Called when user scrolled to a new page.
document | Currently opened document. |
---|---|
pageIndex | Page number of new page. |
Called when search has been cancelled.
Called when searching has finished.
Called in case of an error that prevented searching the document.
ex | Throwable containing the search error reason.
|
---|
Called when a fresh search has been started.
query | Search term. |
---|
Performs the search action using the provided extra compare options.
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.
|
Performs the search action.
searchQuery | String query to be searched. |
---|
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.
listener | OnVisibilityChangedListener that should be removed. Must be non-null. |
---|
Sets background color of the modular search view.
backgroundColor | Modular search view background color. |
---|
Called when the document
has been loaded and is going to be displayed. This has
to be called on the main thread.
document | Loaded PdfDocument. |
---|---|
configuration | Containing document and presentation settings. |
Sets the background color of the highlighted search result.
highlightBackgroundColor | Highlighted search result background color. |
---|
Sets the border color of the highlighted search result.
highlightBorderColor | Border color of the highlighted search result. |
---|
Sets the text color of the highlighted search result.
highlightTextColor | Highlighted search result text color. |
---|
Sets modular search input field background color.
inputFieldBackgroundColor | Background color of the search input field. |
---|
Sets modular search input field hint text color.
inputFieldHintColor | Hint text color of the input field. |
---|
Inserts text in the search input field and optionally starts search.
text | Search text. |
---|---|
startSearch | Hides keyboard and starts search if true .
|
Sets modular search input field text color.
inputFieldTextColor | Text color of the input field. |
---|
Sets the text color of the list item subtitle.
listItemSubtitleColor | Text color of the list item subtitle (search snippet). |
---|
Sets the title color of the list items.
listItemTitleColor | Text color of the list item title (page number). |
---|
Sets the list item selector.
listSelector | Search result list item selector. |
---|
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.
maxSearchResults | Maximum count of search results, null to fallback to default
or SearchConfiguration#UNLIMITED_SEARCH_RESULTS to turn off limiting.
|
---|
Sets the search configuration to this search view.
searchConfiguration | Search configuration to be set for this AbstractPdfSearchView .
|
---|
Sets a listener to be notified of search events on this view. May be null
to remove
any previously set listener.
searchViewListener | A Listener which should be notified of search events, or
null to remove a previously registered listener.
|
---|
Sets the input field separator color.
separatorColor | Color of the horizontal line separator below the input field. |
---|
Sets the number of preview characters extracted with every search result.
snippetLength | Number of characters, defaults to {@value com.pspdfkit.configuration.search.SearchConfiguration#DEFAULT_SNIPPET_LENGTH}. |
---|
Sets the number of characters that need to be entered for the search to start.
startSearchChars | Number of characters needed to trigger the search, defaults to {@value com.pspdfkit.configuration.search.SearchConfiguration#DEFAULT_START_SEARCH_CHARS}. |
---|
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}.
startSearchOnCurrentPage | true to start search on the current page, false to start from the beginning of the document. |
---|
Shows the modular search view.
When called subclasses have to update their UI and remove any previously collected search results from memory.
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.