Skip to content

Instantly share code, notes, and snippets.

@tonnylitao
Last active June 17, 2020 10:00
Show Gist options
  • Select an option

  • Save tonnylitao/f94c716ed088510c64acb82533f152ad to your computer and use it in GitHub Desktop.

Select an option

Save tonnylitao/f94c716ed088510c64acb82533f152ad to your computer and use it in GitHub Desktop.
data class Comment(
...
) : RecyclerItem {
...
}
data class ComplexModel(
val model: SomeModel
...
) : RecyclerItem {
override val layoutId: Int
get() = R.layout.list_itme
override val variableId: Int
get() = BR.data
override val dataToBind: Any
get() = model.aMappingOfModel()
override val id: Int
get() = model.id
}
//PostFragment
private val adapter by lazy {
RecyclerAdapter(RecyclerItem.diffCallback<Post>())
}
//AFragment
private val adapter by lazy {
RecyclerAdapter(RecyclerItem.diffCallback<ComplexModel>())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment