Skip to content

Instantly share code, notes, and snippets.

@DivS-15
Created May 22, 2022 11:05
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
class VideoLoadStateViewHolder(
private val binding: LoadstateViewholderLayoutBinding,
retry: () -> Unit
) : RecyclerView.ViewHolder(binding.root) {
init {
binding.retryButton.setOnClickListener {
retry.invoke()
}
}
fun bind(loadState: LoadState){
binding.progressBar.isVisible = loadState is LoadState.Loading
binding.retryButton.isVisible = loadState is LoadState.Error
binding.retryText.isVisible = loadState is LoadState.Error
}
companion object{
fun create(parent: ViewGroup, retry: () -> Unit): VideoLoadStateViewHolder{
val view = LayoutInflater.from(parent.context).inflate(R.layout.loadstate_viewholder_layout, parent, false)
val binding = LoadstateViewholderLayoutBinding.bind(view)
return VideoLoadStateViewHolder(binding, retry)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment