我正在使用范围进行片段/活动注射。我使用@ContributesAndroidInjector
为每个片段/活动定义了一些模块。
片段模块
@FragmentScope
@ContributesAndroidInjector(modules = [TestingModule::class])
abstract fun bindTestingScreenFragment(): TestingScreen
TestingModule
@Module(includes = [TestingModule.TestingAbstractModule::class])
class TestingModule {
@Provides
fun provideDefaultArgs(testingScreen: TestingScreen): Bundle? = testingScreen.arguments
}
我想将包注入片段范围内,所以无论我在TestingScreen
片段范围内注入束,我都会得到TestingScreen
参数。
我需要知道的是,在provideDefaultArgs
中,我正在注入当前正在注入的屏幕,因此,如何在没有任何循环依赖的情况下注入该屏幕,以上代码可以正常工作而没有任何错误。有人对此有任何想法吗?