Reputation: 34360
I am converting this code to kotlin
where
abstract class BaseModel(){
}
BaseViewHolder
abstract class BaseViewHolder<T : BaseModel>(itemView: View) : RecyclerView.ViewHolder(itemView){
abstract fun bindData(data: T)
}
BaseAdapter
abstract class BaseAdapter<T:BaseModel, U : BaseViewHolder<*>>(var items: List<T>) : RecyclerView.Adapter<U>() {
override fun onCreateViewHolder(p0: ViewGroup, p1: Int): U {
}
override fun getItemCount(): Int {
return items.size
}
override fun onBindViewHolder(holder: U, pos: Int) {
holder.bindData(items.get(pos))
}
}
In onBindViewHolder
the method holder.bindData
gives an error type mismatch require Nothing found T
What am I doing wrong??
Upvotes: 2
Views: 1030
Reputation: 1983
Change your BaseViewHolder<*>
from *
to T
Just like this
...BaseAdapter<T:BaseModel, U : BaseViewHolder<T>>...
Upvotes: 1