I have a 3rd party sdk which provides a Fragment subclass I cannot change. Can I somehow wrap it in ...
u
I have a 3rd party sdk which provides a Fragment subclass I cannot change. Can I somehow wrap it in
AndroidView
and make all the fragment lifecycle work? (Since they don't provide a View)
i
If you use
AndroidViewBinding
with a
FragmentContainerView
, the Fragment lifecycle (and adding/removing that Composable) will all work perfectly
u
hmm, so the trick is to use the view instantiated fragment, which ties it to the view lifecycle, which is then handled by complse?
i
AndroidViewBinding
has some special code specifically to work with
FragmentContainerView
to hook it up to the disposal of the composable (which is really the lifecycle you want)
u
yes, basically its identical to the issue of having google maps fragment in compose. Ill look into the AndroidViewBinding thanks!
c
Wait. If I want to use google maps I need to use AndroidViewBinding?
i
Only AndroidViewBinding will automatically remove the Fragment when you remove that Composable from your compose hierarchy
c
Oof. Just submitted a bug that got rid of androidViewBinding and disables the viewBinding BuildFeature{}. Guess I will have to revert that when we get to maps!
i
(the same thing applies to every fragment)
And you don't need View Binding to use AndroidViewBinding btw. It is more that it has an inflate lambda
Which you can just manually implement yourself
c
Interesting. Alright. I will definitely revisit it when the time comes. Thanks ian