Skip to content

Instantly share code, notes, and snippets.

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
What would you like to do?
class VideoLoadStateViewHolder(
private val binding: LoadstateViewholderLayoutBinding,
retry: () -> Unit
) : RecyclerView.ViewHolder(binding.root) {
init {
binding.retryButton.setOnClickListener {
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