Should I use DataBinding in a RecyclerView? Or is ...
# android
v
Should I use DataBinding in a RecyclerView? Or is it an overkill?
e
In the component or in the items? In the RecyclerView itself, it may be not necessary. But in the items is a good call to avoid ViewHolders.
v
Using it in place of findViewById...
e
You can simply use Kotlin Synthetic access for it. Or wait for the new View Binding. 😊
1
v
Meh, yeah... Kotlin Synthetic in comparison to DataBinding, any performance difference or tradeoffs?
e
Image from iOS.jpg
That was shown in Google IO. The "???" Is the new View Binding.
v
I'm guessing it's not stable yet?
e
No, it is not. I would go with Synthetic if you only need the
findViewById
. Data Binding seems like a overkill.
v
Okay... Thanks
😊 1
r
My information might be out-of-date, but one consideration you might make is that synthetics in `ViewHolder`s have to be re-evaluated every time it is reused. This can affect performance
👍 1
g
isn't it what
LayoutContainer
for? Iirc it will be cached.
r
You’re correct. I wasn’t aware of
LayoutContainer
until you mentioned it. Relevant docs: https://kotlinlang.org/docs/tutorials/android-plugin.html#layoutcontainer-support
s
What's the objective of layout container?