You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 20, 2021. It is now read-only.
I really like this library and it has brought some great improvements into my code. Thanks :-)
However I'm facing a challenge now:
I'm using Dagger2 as a dependency injection framework in my app.
I have a (CompositeAndroid) plugin that needs to have access to some injected classes.
However since plugins are added in the constructor of an Activity (or Fragment) and fields are injected in onCreate() of the root base Activity it is not possible to access injected fields on construction so I cannot pass it as a parameter to the plugin from the Activity.
Example:
abstract class LockableSupportActivityBase : DaggerSupportActivityBase() {
@Inject
protected lateinit var preferenceHandler: PreferenceHandler
init {
// this throws NotInitializedException on "preferenceHandler"
addActivityPlugins(LockPlugin(preferenceHandler))
}
}
Injecting the Plugin itself is also not possible since it has to be added to the Activity in the constructor and the activity also has access to injected properties only right after super.onCreate() (so it's too late).
Example:
abstract class LockableSupportActivityBase : DaggerSupportActivityBase() {
@Inject
protected lateinit var lockPlugin: LockPlugin
init {
// this throws NotInitializedException on "lockPlugin"
addActivityPlugins(lockPlugin)
}
}
Is there a way to work around this or is this a problem that needs a more sophisticated fix?
The text was updated successfully, but these errors were encountered:
Hi,
I really like this library and it has brought some great improvements into my code. Thanks :-)
However I'm facing a challenge now:
I'm using Dagger2 as a dependency injection framework in my app.
I have a (CompositeAndroid) plugin that needs to have access to some injected classes.
However since plugins are added in the constructor of an Activity (or Fragment) and fields are injected in
onCreate()
of the root base Activity it is not possible to access injected fields on construction so I cannot pass it as a parameter to the plugin from the Activity.Example:
Injecting the Plugin itself is also not possible since it has to be added to the Activity in the constructor and the activity also has access to injected properties only right after
super.onCreate()
(so it's too late).Example:
Is there a way to work around this or is this a problem that needs a more sophisticated fix?
The text was updated successfully, but these errors were encountered: