API Reference
/
Android Widgets
/
Current Filters
Apr. 24, 2019
Current Filters
About this widget
Current Refinements shows the currently active refinements within a given FilterState
and lets users remove filters individually.
To add current refinements to your search experience, use these components:
FilterCurrentViewModel
: The logic for current refinements in theFilterState
.FilterState
: The current state of the filters.FilterCurrentView
: The view that will render the current filters.FilterCurrentPresenter
: Optional. The presenter that defines the way we want to display the Filters.
Examples
Copy
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 viewModel = FilterCurrentViewModel()
val connection = ConnectionHandler()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val chipGroup = ChipGroup(this)
val view: FilterCurrentView = FilterCurrentViewImpl(chipGroup)
connection += searcher.connectFilterState(filterState)
connection += viewModel.connectFilterState(filterState)
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
|
|||
filterCurrentView
|
type: FilterCurrentView
Required
The view that will render the current filters. |
||
Copy
|
|||
items
|
type: Map<FilterAndID, Filter>
default: mapOf()
Optional
The default filters to display. |
||
Copy
|
|||
groupIDs
|
type: List<FilterGroupID>
default: listOf()
Optional
When specified, only matching current refinements will be displayed. |
||
Copy
|
Presenter
presenter
|
type: FilterPresenter
default: FilterCurrentPresenterImpl()
Optional
The presenter that defines the way we want to display a filter. |
||
Copy
|