All Downloads are FREE. Search and download functionalities are using the official Maven repository.

main.com.sceyt.chatuikit.presentation.components.role.adapter.ChooseRoleAdapter.kt Maven / Gradle / Ivy

There is a newer version: 1.7.2
Show newest version
package com.sceyt.chatuikit.presentation.components.role.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.sceyt.chatuikit.databinding.SceytItemChooseRoleBinding

class ChooseRoleAdapter(private var rolesList: ArrayList,
                        private val clickListener: ChooseRoleListener) : RecyclerView.Adapter() {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ChooseRoleViewHolder {
        val itemView = SceytItemChooseRoleBinding.inflate(LayoutInflater.from(parent.context), parent, false)
        return ChooseRoleViewHolder(itemView, clickListener)
    }

    override fun onBindViewHolder(holder: ChooseRoleViewHolder, position: Int) {
        holder.bindTo(rolesList[position])
    }

    override fun getItemCount(): Int {
        return rolesList.size
    }

    fun getData() = rolesList

    fun interface ChooseRoleListener {
        fun onRoleClick(role: RoleItem)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy