File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed
viewbinding-nonreflection/src/main/java/com/dylanc/viewbinding/nonreflection Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -66,24 +66,23 @@ class FragmentBindingDelegate<VB : ViewBinding>(
66
66
) : ReadOnlyProperty<Fragment, VB> {
67
67
68
68
private var lifecycleObserver: LifecycleObserver ? = null
69
- private var _binding : VB ? = null
70
- private val binding: VB get() = _binding !!
69
+ private var binding: VB ? = null
71
70
72
71
@Suppress(" UNCHECKED_CAST" )
73
72
override fun getValue (thisRef : Fragment , property : KProperty <* >): VB {
74
73
if (lifecycleObserver == null ) {
75
74
lifecycleObserver = object : LifecycleObserver {
76
75
@OnLifecycleEvent(Lifecycle .Event .ON_DESTROY )
77
76
fun onDestroyView () {
78
- _binding = null
77
+ binding = null
79
78
}
80
79
}.also {
81
80
thisRef.viewLifecycleOwner.lifecycle.addObserver(it)
82
81
}
83
82
}
84
- if (_binding == null ) {
85
- _binding = bind(thisRef.requireView())
83
+ if (binding == null ) {
84
+ binding = bind(thisRef.requireView())
86
85
}
87
- return binding
86
+ return binding!!
88
87
}
89
- }
88
+ }
You can’t perform that action at this time.
0 commit comments