@@ -9,22 +9,24 @@ import android.view.ViewGroup
99import androidx.annotation.RequiresApi
1010import androidx.appcompat.app.AppCompatActivity
1111import androidx.core.view.children
12+ import androidx.core.view.isInvisible
13+ import androidx.core.view.isVisible
1214import androidx.fragment.app.Fragment
1315import androidx.recyclerview.widget.RecyclerView
1416import androidx.viewbinding.ViewBinding
1517
1618
1719inline fun <T : ViewBinding > Activity.viewBinding (crossinline bindingInflater : (LayoutInflater ) -> T ) =
18- lazy(LazyThreadSafetyMode .NONE ) {
19- bindingInflater.invoke(layoutInflater)
20- }
20+ lazy(LazyThreadSafetyMode .NONE ) {
21+ bindingInflater.invoke(layoutInflater)
22+ }
2123
2224fun <T : ViewBinding > Fragment.viewBinding (viewBindingFactory : (View ) -> T , disposeRecyclerViewsAutomatically : Boolean = true) =
23- FragmentViewBindingDelegate (this , viewBindingFactory, disposeRecyclerViewsAutomatically)
25+ FragmentViewBindingDelegate (this , viewBindingFactory, disposeRecyclerViewsAutomatically)
2426
2527
2628fun <T : ViewBinding > globalViewBinding (viewBindingFactory : (View ) -> T ) =
27- GlobalViewBindingDelegate (viewBindingFactory)
29+ GlobalViewBindingDelegate (viewBindingFactory)
2830
2931internal fun ensureMainThread () {
3032 if (Looper .myLooper() != Looper .getMainLooper()) {
@@ -39,4 +41,16 @@ fun ViewBinding?.disposeRecyclers() {
3941 it.adapter = null
4042 }
4143 }
44+ }
45+
46+ fun ViewBinding.gone () {
47+ root.isVisible = false
48+ }
49+
50+ fun ViewBinding.show () {
51+ root.isVisible = true
52+ }
53+
54+ fun ViewBinding.invisible () {
55+ root.isInvisible = true
4256}
0 commit comments