SearchState

abstract class SearchState<R : SearchResult, Q>

Generic search state interface that can be used to search and manage the results

Parameters

R

: The type of the search result

Q

: The type of the search query

Inheritors

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
abstract val emptyQuery: Q

Initial query value and also the value to which the query is reset when the search is terminated

Link copied to clipboard

Returns true if there are any search results.

Link copied to clipboard

Returns true if the search has completed.

Link copied to clipboard

Returns true if no search is active.

Link copied to clipboard

Returns true if a search is currently in progress.

Link copied to clipboard
abstract val query: Q

The current search query

Link copied to clipboard

The set of page indices that contain search results.

Link copied to clipboard
abstract val results: List<R>

Contains the search results

Link copied to clipboard

Contains the search results, the map key is the page index

Link copied to clipboard
abstract val resultsQuery: Q?

The query associated with the current results

Link copied to clipboard

The currently selected search result, or null if no result is selected.

Link copied to clipboard
abstract val selectedResultIndex: Int

Index of currently selected result

Link copied to clipboard
val size: Int

Total amount of search results

Link copied to clipboard
abstract val status: SearchStatus

The current search status of the search

Functions

Link copied to clipboard
fun getResultAt(index: Int): R?

Returns the result at the given index or null if the index is out of bounds

Link copied to clipboard
fun hasResultsForPage(pageIndex: Int): Boolean

Checks if there are search results on the specified page.

Link copied to clipboard
fun indexOfResult(result: R): Int

Depending on the amount of search results, this method is potentially faster than results.indexOf

Link copied to clipboard

Checks if the search has completed for the specified query.

Link copied to clipboard
fun resultsForPage(pageIndex: Int): List<R>

Returns the search results for the specified page.

Link copied to clipboard
fun sanitizeSelectionIndex(lastSelectedIndex: Int): Int

Checks selectedResultIndex if it's still within the bounds of the result list and if not returns a valid index