Reputation: 763
I have a doubt regarding Dagger 2.
I have a BaseFragment class in which i am writing AndroidSupportInjection.inject(this), and all my fragments are extending from this Fragment class. I also have a FragmentBuilder class where i mention all the Fragments using @ContributesAndroidInjector annotation where i need injection to happen.
My doubt is, if in a Fragment i don’t need any dependency still i have to mention it in my FragmentBuilder class because its extending from BaseFragment. Is it a all right to do so or this will lead to any memory leak or is this a wrong design pattern ?
Please help!!
Upvotes: 0
Views: 104
Reputation: 4737
In your situation i'll go with 2 "base" fragments, the first BaseFragment
doesn't allow injection then you make a BaseInjectableFragment
that inherit from the first one and you make it injectable, this looks more cleaner this way.
Upvotes: 1