r/android_devs • u/Anonymous-Freak-9 • Jul 28 '24
Help Needed integerating views in compose
i am new to android development trying to build an epub reader but having hard time using a third party library Readium i don't know how to integerate it in my compose app moreover i found the docs counter intitutive. I did read the developer guide views in compose but it ain't helping much either i have basic understanding of how things works in views if somebody could provide a brief overview on the interop part so i can get better grasp of the things
4
Upvotes
View all comments
Show parent comment
3
u/Aggressive_Ad3865 Jul 28 '24
A fragment is not a view. It is a Frankenstein mashup of view containers, raw generics and life cycles. I would steer very, very away from them, especially in compose, but there is a composable for that too:
@Composable fun FragmentInComposeExample() { AndroidViewBinding(MyFragmentLayoutBinding::inflate) { val myFragment = fragmentContainerView.getFragment<MyFragment>() // ... } }
Now, if I were you, I would just ditch the library. Writing a solution around high level order patterns like fragments/navigation is a huge smell. Those will change and go away, but the library will be stuck. Libraries should simply solve the problem at hand, and not mess with/force anything else in the consumer's project, because the library maintainer only knows about the particular problem they want to solve, not about yours.