API Reference / Android Widgets / Loading
Widget signature
LoadingConnector(
  searcher: Searcher,
  viewModel: LoadingViewModel,
  debouncer: Debouncer
)

About this widget

Components that show a loading indicator during pending requests.

To add a loading indicator to your search experience, use these components:

  • Searcher: The Searcher that handles your searches.
  • LoadingViewModel: The logic applied to the loading indicator.
  • LoadingView: The concrete view displayed during loading.

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
class MyActivity: AppCompatActivity() {
    val client = ClientSearch(
        ApplicationID("YourApplicationID"),
        APIKey("YourAPIKey")
    )
    val index = client.initIndex(IndexName("YourIndexName"))
    val searcher = SearcherSingleIndex(index)
    val loading = LoadingConnector(searcher)
    val connection = ConnectionHandler(loading)

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val swipeRefreshLayout = SwipeRefreshLayout(this)
        val view: LoadingView = LoadingViewSwipeRefreshLayout(swipeRefreshLayout)
        connection += loading.connectView(view)
        searcher.searchAsync()
    }

    override fun onDestroy() {
        super.onDestroy()
        connection.disconnect()
        searcher.cancel()
    }
}

Parameters

searcher
type: Searcher
Required

The Searcher that handles your searches.

viewModel
type: LoadingViewModel
default: LoadingViewModel()
Optional

The logic applied to the loading indicator.

debouncer
type: Debouncer
default: Debouncer(debounceLoadingInMillis)
Optional

Delays searcher operations by a specified time duration.

ViewModel

isLoading
type: Boolean
default: false
Optional

When true, the interface starts in a loading state.

1
LoadingViewModel(isLoading = true)

View

view
type: LoadingView
Required

The concrete view displayed during load.

1
2
3
val swipeRefreshLayout = SwipeRefreshLayout(this)
val view: LoadingView = LoadingViewSwipeRefreshLayout(swipeRefreshLayout)
loading.connectView(view)

Did you find this page helpful?