ViewBindingPropertyDelegate icon indicating copy to clipboard operation
ViewBindingPropertyDelegate copied to clipboard

Not cleared binding for dialog fragment

Open Nilairan opened this issue 3 years ago • 2 comments

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

Nilairan avatar Apr 08 '21 09:04 Nilairan

Please check the latest version (1.4.7)

kirich1409 avatar Jul 07 '21 18:07 kirich1409

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.

raman-branavitski avatar Oct 28 '21 11:10 raman-branavitski