-
-
Save DivS-15/375b2fd385a5230e5c3e0ae79f8d1e93 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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