Last active
June 17, 2020 10:00
-
-
Save tonnylitao/f94c716ed088510c64acb82533f152ad to your computer and use it in GitHub Desktop.
complicated demo for https://medium.com/@tonny/recyclerview-2020-when-recyclerview-meets-data-binding-616ca5c2147d
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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