ViewBindingPropertyDelegate
ViewBindingPropertyDelegate copied to clipboard
Not cleared binding for dialog fragment
I am create BottomSheetDialogFragment
with using this libs
Example view binding
private val binding: BottomAccountDialogBinding by viewBinding(BottomAccountDialogBinding::bind)
In onCreateView
returned view
inflater.inflate(R.layout.bottom_account_dialog, container, false)
I am open new fragment of dialog and after going back on dialog fragment using popBackStack
, onCreateView
method is called again but binding not cleared
I am see what onDestroyView
is called but ViewBindingProperty
not cleared my view binding
@MainThread public override fun clear() { mainHandler.post { viewBinding = null } }
This method not called for my BottomAccountDialogBinding
I'am see what DialogFragmentViewBindingProperty
using fragment lifecycle but not view lifecycle
if (thisRef.showsDialog) { return thisRef } else { return thisRef.viewLifecycleOwner }
I'am tried change showsDialog parameter for my dialog fragment befor called binding in onViewCreated
and in onDestroyView
method and this is cleared binding else arises this problem
I think it's worth it return lifecycle for DialogFragmentViewBindingProperty
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.