Skip to content

Instantly share code, notes, and snippets.

@ajailani4
Created June 3, 2021 11:19
Show Gist options
  • Save ajailani4/9b7447d3a4e2917e0a9d123773336b7c to your computer and use it in GitHub Desktop.
Save ajailani4/9b7447d3a4e2917e0a9d123773336b7c to your computer and use it in GitHub Desktop.
class FooterAdapter : LoadStateAdapter<FooterAdapter.ViewHolder>() {
private lateinit var binding: FooterProgressBarBinding
class ViewHolder(binding: FooterProgressBarBinding) : RecyclerView.ViewHolder(binding.root)
override fun onCreateViewHolder(parent: ViewGroup, loadState: LoadState): ViewHolder {
binding = FooterProgressBarBinding.inflate(
LayoutInflater.from(parent.context), parent, false
)
return ViewHolder(binding)
}
override fun onBindViewHolder(holder: ViewHolder, loadState: LoadState) {
if (loadState is LoadState.Loading) {
binding.progressBar.visibility = View.VISIBLE
} else {
binding.progressBar.visibility = View.GONE
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment