Filter Numeric Range
About this widget
Filter Numeric Range is a filtering view made to filter between two numeric values. The most common interface for this is a slider.
To add a filter numeric range to your search experience, use these components:
Searcher
: TheSearcher
that handles your searches.FilterState
: The current state of the filters.FilterRangeViewModel
: The logic applied to the numeric ranges.NumberRangeView
: The view that will render the numeric range filter.
Examples
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
class MyActivity : AppCompatActivity() {
val client = ClientSearch(
ApplicationID("YourApplicationID"),
APIKey("YourAPIKey")
)
val index = client.initIndex(IndexName("YourIndexName"))
val searcher = SearcherSingleIndex(index)
val filterState = FilterState()
val attribute = Attribute("price")
val viewModel = FilterRangeViewModel<Int>()
val connection = ConnectionHandler()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val view: NumberRangeView<Int> = MySliderNumberRangeView()
connection += searcher.connectFilterState(filterState)
connection += viewModel.connectFilterState(filterState, attribute)
connection += viewModel.connectView(view)
searcher.searchAsync()
}
override fun onDestroy() {
super.onDestroy()
connection.disconnect()
searcher.cancel()
}
}
Parameters
searcher
|
type: Searcher
Required
The |
||
Copy
|
|||
filterState
|
type: FilterState
Required
The |
||
Copy
|
|||
numberRangeView
|
type: NumberRangeView
Required
The view that will render the numeric range filter. |
||
Copy
|
|||
attribute
|
type: Attribute
Required
The attribute to filter. |
||
Copy
|
|||
bounds
|
type: Range?
Optional
If specified, the limits of the acceptable range within which values will be coerced. |
||
Copy
|
|||
groupID
|
type: FilterGroupID
default: FilterGroupID(attribute.raw)
Optional
When specified, all created filters will be grouped under this ID and will be composed with this operator.
Defaults to the attribute used, applying |
||
Copy
|