Skip to content

Commit

Permalink
Fixed adapter type parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
italankin committed Dec 3, 2023
1 parent ee2eb94 commit 4b1ee3a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface AdapterDelegate<VH : RecyclerView.ViewHolder, T> {
*
* @param adapter adapter
*/
fun onAttached(adapter: CompositeAdapter<T>)
fun onAttached(adapter: CompositeAdapter<*>)

/**
* Create [RecyclerView.ViewHolder].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ abstract class BaseAdapterDelegate<VH : RecyclerView.ViewHolder, T> : AdapterDel
/**
* @return adapter, which this delegate is attached to
*/
protected lateinit var adapter: CompositeAdapter<T>
protected lateinit var adapter: CompositeAdapter<*>

/**
* Get layout resource identifier for view holder's layout.
Expand All @@ -35,7 +35,7 @@ abstract class BaseAdapterDelegate<VH : RecyclerView.ViewHolder, T> : AdapterDel
*/
protected abstract fun createViewHolder(itemView: View): VH

override fun onAttached(adapter: CompositeAdapter<T>) {
override fun onAttached(adapter: CompositeAdapter<*>) {
this.adapter = adapter
}

Expand All @@ -59,7 +59,8 @@ abstract class BaseAdapterDelegate<VH : RecyclerView.ViewHolder, T> : AdapterDel
return 0
}

@Suppress("UNCHECKED_CAST")
fun getItem(position: Int): T {
return adapter.getItem(position)
return adapter.getItem(position) as T
}
}

0 comments on commit 4b1ee3a

Please sign in to comment.