Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
MovieHunt blog part 5. movie home adapter
data class MovieModel(
val largeSize: Boolean
class MovieHomeAdapter(private val movieList: List<MovieModel>) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
override fun getItemViewType(position: Int): Int {
return if (movieList.get(position).largeSize) {
} else {
override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): RecyclerViewHolder {
val inflater = LayoutInflater.from(viewGroup.context)
return ViewHolder(inflater.inflate(viewType, viewGroup, false))
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
// bind the data to the view holder
class ViewHolder(view: View): RecyclerView.ViewHolder(view) {
// find the view by id, display the data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.