You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
privateclassFragmentViewBindingProperty<F:Fragment, T:ViewBinding>(
viewBinder: (F) ->T
) : ViewBindingProperty<F, T>(viewBinder) {
overridefungetLifecycleOwner(thisRef:F) = thisRef.viewLifecycleOwner
}
/** * Create new [ViewBinding] associated with the [Fragment]*/
@JvmName("viewBindingFragment")
publicfun <F:Fragment, T:ViewBinding> Fragment.viewBinding(viewBinder: (F) ->T): ViewBindingProperty<F, T> {
returnFragmentViewBindingProperty(viewBinder)
}
/** * Create new [ViewBinding] associated with the [Fragment] * * @param vbFactory Function that create new instance of [ViewBinding]. `MyViewBinding::bind` can be used * @param viewProvider Provide a [View] from the Fragment. By default call [Fragment.requireView]*/
@JvmName("viewBindingFragment")
publicinlinefun <F:Fragment, T:ViewBinding> Fragment.viewBinding(
crossinline vbFactory: (View) ->T,
crossinline viewProvider: (F) ->View = Fragment::requireView
): ViewBindingProperty<F, T> {
return viewBinding { fragment:F-> vbFactory(viewProvider(fragment)) }
}
/** * Create new [ViewBinding] associated with the [Fragment] * * @param vbFactory Function that create new instance of [ViewBinding]. `MyViewBinding::bind` can be used * @param viewBindingRootId Root view's id that will be used as root for the view binding*/
@JvmName("viewBindingFragment")
publicinlinefun <T:ViewBinding> Fragment.viewBinding(
crossinline vbFactory: (View) ->T,
@IdRes viewBindingRootId:Int
): ViewBindingProperty<Fragment, T> {
return viewBinding(vbFactory) { fragment:Fragment-> fragment.requireView().findViewById(viewBindingRootId) }
}