can anyone help with refactoring this class to Kotlin, having trouble with generics conversation.
Model:
abstract class ViewHolderDataBinder<DM : ViewHolderDataModel,
VH : RecyclerView.ViewHolder>(val viewType: Int) {
abstract fun createViewHolder(parent: ViewGroup): VH
abstract fun bindView(model: DM, holder: VH)
}
Java code that want to convert in to Kotlin:
SparseArray<ViewHolderDataBinder> viewHolderDataBinders = new SparseArray<>();
And I want to refactor it in to this
val viewHolderDataBinders = SparseArray<ViewHolderDataBinder>()
but Kotlin requires to add type parameters in to ViewHolderDataBinder
.
Is there any way to not add type parameter as It was not necessary in Java?
UPDATE
if I use private val viewHolderDataBinders = SparseArray<ViewHolderDataBinder<*, *>>()
then getting error here binder.bindView(item, holder)
it says that item
and holder
requires Nothing
but Found
.....