API Reference
/
Android Widgets
/
Clear Filters
Apr. 24, 2019
Clear Filters
About this widget
ClearFilters lets the user clear all refinements that are currently active within the given FilterState.
To add ClearFilters to your search experience, use these components:
FilterClearInteractor: The logic for clearing refinements in theFilterState.FilterState: The current state of the filters.FilterClearView: The view that will render the clear filter UI.
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 = FilterClearViewModel()
val connection = ConnectionHandler()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val someView = View(this)
val view: FilterClearView = FilterClearViewImpl(someView)
connection += searcher.connectFilterState(filterState)
connection += viewModel.connectFilterState(filterState)
connection += viewModel.connectView(view)
searcher.searchAsync()
}
override fun onDestroy() {
super.onDestroy()
connection.disconnect()
searcher.cancel()
}
}
Parameters
filterState
|
type: FilterState
Required
The |
||
|
Copy
|
|||
filterClearView
|
type: FilterClearView
Required
The view that will render the clear filter UI. |
||
|
Copy
|
|||
groupIDs
|
type: List<FilterGroupID>
default: listOf()
Optional
The groupIDs of filters to clear. All filters will be cleared if unspecified. |
||
|
Copy
|
|||
mode
|
type: ClearMode
default: ClearMode.Specified
Optional
Whether we should clear the |
||
|
Copy
|
|||