Skip to content

Instantly share code, notes, and snippets.

@annchar
Last active June 6, 2021 10:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save annchar/b33c19ffa3eb02f3b68137671bb27bcb to your computer and use it in GitHub Desktop.
Save annchar/b33c19ffa3eb02f3b68137671bb27bcb to your computer and use it in GitHub Desktop.
private val cryptoListAdapter by lazy {
CryptoListAdapter {
showToastMessage(getString(R.string.item_clicked, it.symbol))
}
}
private fun initView() {
...
// initial recyclerView
binding.rcCryptoList.addItemDecoration(itemDecorator)
binding.rcCryptoList.adapter = cryptoListAdapter
}
private fun initObservers() {
viewLifecycleOwner.lifecycleScope.launch {
viewModel.getCryptoList().observe(viewLifecycleOwner, {
cryptoListAdapter.submitData(lifecycle, it)
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment