Filter Numeric Range is a filtering view made to filter between two numeric values.
The most common interface for this is a slider.The Android View and Compose UI code samples (part of the Android widget showcase repository on GitHub) illustrate the use of sliders.
InstantSearch provides the NumberRangeState as a state model,
which is an implementation of the NumberRangeView interface.
You need to connect NumberRangeState to the FilterRangeConnector or FilterRangeViewModel like any other NumberRangeView implementation.
Kotlin
class MyActivity : AppCompatActivity() { val searcher = HitsSearcher( applicationID = "YourApplicationID", apiKey = "YourSearchOnlyAPIKey", indexName = "YourIndexName" ) val price = "price" val groupID = FilterGroupID(price) val primaryBounds = 0..15 val initialRange = 0..15 val filters = filters { group(groupID) { range(price, initialRange) } } val filterState = FilterState(filters) val sliderState = NumberRangeState<Int>() val range = FilterRangeConnector( filterState = filterState, attribute = price, range = initialRange, bounds = primaryBounds ) val connections = ConnectionHandler(range) init { connections += searcher.connectFilterState(filterState) connections += range.connectView(sliderState) } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { MyRangeSlider(sliderState) // your own UI composable to display range and bounds as `Range<T>` } searcher.searchAsync() } fun Range<Int>.toClosedFloatRange(): ClosedFloatingPointRange<Float> { return min.toFloat()..max.toFloat() } override fun onDestroy() { super.onDestroy() connections.disconnect() searcher.cancel() }}