我已经花了数小时尝试在谷歌中找到我的两个匕首实现的区别。 它实现这样为什么我得到@提供注释错误?
@Module
class MatchesModule
{
@Provides
@NetworkScope
@IntoMap
@RetrofitModulesName(eRetrofitModules.MATCHES)
fun retrofitMatches(okHttpClient: OkHttpClient, rxAdaptor: RxJava2CallAdapterFactory, iBuilder: Retrofit.Builder): Retrofit = iBuilder.addConverterFactory(GsonConverterFactory.create(mDeserializerMatches));
}
这种方法提供了改造的对象,也是我才能把所有这些Retrofit
对象的映射使用注释@IntoMap
和@RetrofitModulesName(...)
。
@Module
class PreviewModule
{
@Provides
@PreviewScope
fun provideMatchesPresenter(retrofitModules: Map<eRetrofitModules, Retrofit>): IMatchPresenter = MatchPresenter(retrofitModules)
}
我得到的所有Retrofit
对象并将它们传递给MathcPresenter
一切正常,并罚款。 但我想在我的演示者中获得Map<Foo, Provider<Retrovit>>
。 所以,我说这个词Provider
来论证
@Provides
@PreviewScope
fun provideMatchesPresenter(retrofitModules: Map<eRetrofitModules,
Provider<Retrofit>>): IMatchPresenter = MatchPresenter(retrofitModules)
以及到MathcPresenter
class MatchPresenter(retrofitModules: Map<eRetrofitModules, Provider<Retrofit>>): IMatchPresenter
的构造函数,现在我不能undersand为什么,但我得到这样的错误
Error:(6, 1) error: [com.example.alexeyt.sunshinekotlin.moduls.previewmodule.PreviewComponent.inject(com.example.alexeyt.sunshinekotlin.ui.fragments.previewFragments.PreviewFragment)] java.util.Map> cannot be provided without an @Provides-annotated method.
PreviewScope
@Scope
@Retention(AnnotationRetention.RUNTIME)
annotation class PreviewScope
我在做什么错?
什么是'@ PreviewScope'? –
@DivyeshKalotra加入问题 –
@DivyeshKalotra但你为什么要问'预览范围'?据我了解这是没有关系......它是完美的作品,直到我加入提供程序<>'的参数 –