I was looking into plaid source and they have this...
# android
l
I was looking into plaid source and they have this delegate for databinding https://github.com/nickbutcher/plaid/blob/757ee036c4eed46431982c1de5e6d0b57809fea2/core/src/main/java/io/plaidapp/core/util/delegates/ContentViewBindingDelegate.kt I’ve created mine like this, is there any performance or big difference between the two?
Copy code
inline fun <reified T : ViewDataBinding> FragmentActivity.contentView(@LayoutRes layoutRes: Int) = lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
    DataBindingUtil.setContentView<T>(this, layoutRes)
}
k
You probably should use
LazyThreadSafetyMode.NONE
, since this will always run on the UI thread anyway Using
SYNCHRONIZED
might be a little less performant due to extra (unnecessary) concurrency synchronization mechanism
👍 1