androidbroadcast / ViewBindingPropertyDelegate

Make work with Android View Binding simpler
https://proandroiddev.com/make-android-view-binding-great-with-kotlin-b71dd9c87719
Apache License 2.0
1.42k stars 102 forks source link

Not cleared binding for dialog fragment #53

Open Nilairan opened 3 years ago

Nilairan commented 3 years ago

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

kirich1409 commented 3 years ago

Please check the latest version (1.4.7)

raman-branavitski commented 2 years ago

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.