r/android_devs • u/VasiliyZukanov • Jun 20 '20
Coding Dagger Hilt: Custom Entry Point for FragmentFactory Integration
https://www.techyourchance.com/dagger-hilt-entry-point/
19
Upvotes
3
u/Zhuinden EpicPandaForce @ SO Jun 20 '20
@EntryPoint @InstallIn(ActivityComponent.class) public interface MainActivityEntryPoint { public FragmentManager getFragmentManager(); public FragmentFactory getFragmentFactory(); } @Override protected void onCreate(Bundle savedInstanceState) { MainActivityEntryPoint entryPoint = EntryPointAccessors.fromActivity(this, MainActivityEntryPoint.class); entryPoint.getFragmentManager().setFragmentFactory(entryPoint.getFragmentFactory()); super.onCreate(savedInstanceState);
This is very interesting, nice fix. 😳
1
u/[deleted] Jun 20 '20
Assuming you have a single mutlibinding aware Fragment Factory as per this blog post why can't you simply set the Fragment Factory once in the Application class? And then you don't have to worry about this workaround for Hilt.