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
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
abstract val query: Q

The current search query

Link copied to clipboard
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
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
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
Link copied to clipboard
fun resultsForPage(pageIndex: Int): List<R>
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