Я использую из dagger
, как показано ниже, у меня несколько Qualifiers
:
@Module(
includes = [LoginDialogFragmentModule.LoginPresenterAPIViewAbstractModule::class,
RemoteAPIDataModule::class,
RemoteAPIDataModuleTS::class
]
)
public class LoginDialogFragmentModule {
@LoginDialogFragmentScoped
@Provides
fun provideLoginPresenterAPI(
courseView: LoginContract.LoginView,
dataSourcesApi: DataSourcesApi
): LoginPresenter {
return LoginPresenter(
courseView,
dataSourcesApi
)
}
@LoginDialogFragmentScoped
@Provides
@LoginComposQualifiers
fun provideCompositeDisposableLogin(): CompositeDisposable {
return CompositeDisposable()
}
@LoginDialogFragmentScoped
@Provides
fun loginAPI(
loginDialogFragment: LoginDialogFragment,
@CommonComposQualifiers mCompositeCommonDisposable: CompositeDisposable,
@LoginComposQualifiers mCompositeLoginDisposable: CompositeDisposable,
@CommonApiQualifiers publicApi: PublicApi,
@LoginApiQualifires publicApiTS: PublicApiTS
): DataSourcesApi {
return DataSourcesApi(
loginDialogFragment.context!!,
mCompositeCommonDisposable,
mCompositeLoginDisposable,
publicApi,
publicApiTS
)
}
@Module
interface LoginPresenterAPIViewAbstractModule {
@LoginDialogFragmentScoped
@Binds
fun loginPresenterAPI(loginPresenter: LoginPresenter): LoginContract.iLoginPresenters
@LoginDialogFragmentScoped
@Binds
fun loginView(loginDialogFragment: LoginDialogFragment): LoginContract.LoginView
}
}
И в моем фрагменте, как показано ниже:
@LoginDialogFragmentScoped
class LoginDialogFragment :
DefaultLifecycleObserver,
DaggerAppCompatDialogFragment(),
LoginContract.LoginView {
@Inject
@LoginComposQualifiers
lateinit var mCompositeDisposable: CompositeDisposable
@Inject
lateinit var loginPresenter: LoginPresenter
private lateinit var loginViewModel: LoginDialogViewModel
override fun onDestroy(owner: LifecycleOwner) {
try {
mCompositeDisposable.clear()
mCompositeDisposable.dispose()
} catch (ex: Exception) {
}
}
}
Но это меня ошибка ниже:
error: [Dagger/MissingBinding] @yyy.yyy.di.qualifiers.LoginComposQualifiers io.reactivex.disposables.CompositeDisposable cannot be provided without an @Provides-annotated method.