Last active
June 17, 2020 09:47
-
-
Save tonnylitao/787bf03f767f972d8faae57ed1c1c1ea to your computer and use it in GitHub Desktop.
bind data in recycler adapter 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
| override fun onBindViewHolder( | |
| holder: ViewHolder, | |
| position: Int | |
| ){ | |
| getItem(position)?.run(holder.binding::bind) | |
| } | |
| } //end of RecyclerAdapter | |
| private fun ViewDataBinding.bind( | |
| item: RecyclerItem | |
| ) { | |
| setVariable( | |
| item.variableId, | |
| item.dataToBind | |
| ) | |
| executePendingBindings() | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment