Open Nilairan opened 3 years ago
Please check the latest version (1.4.7)
Doesn't work for me. Tried versions 1.4.7 and 1.5.0. If dialog fragment is used with showsDialog = true, viewBinding keeps references to old views after pop dialog from back stack.
I am create
BottomSheetDialogFragment
with using this libs Example view bindingprivate val binding: BottomAccountDialogBinding by viewBinding(BottomAccountDialogBinding::bind)
InonCreateView
returned viewinflater.inflate(R.layout.bottom_account_dialog, container, false)
I am open new fragment of dialog and after going back on dialog fragment usingpopBackStack
,onCreateView
method is called again but binding not cleared I am see whatonDestroyView
is called butViewBindingProperty
not cleared my view binding@MainThread public override fun clear() { mainHandler.post { viewBinding = null } }
This method not called for myBottomAccountDialogBinding
I'am see whatDialogFragmentViewBindingProperty
using fragment lifecycle but not view lifecycleif (thisRef.showsDialog) { return thisRef } else { return thisRef.viewLifecycleOwner }
I'am tried change showsDialog parameter for my dialog fragment befor called binding inonViewCreated
and inonDestroyView
method and this is cleared binding else arises this problem I think it's worth it return lifecycle forDialogFragmentViewBindingProperty