https://kotlinlang.org logo
#android
Title
# android
j

juliocbcotta

03/24/2017, 4:41 PM
Trevor, I don`t know if I got it right but.... What I meant was something like ...
Copy code
@Module(subcomponents = ComponentA.class)
public class ActivityAModule
@Inject
ActivityA activity;

@Provides
@ActivityScope
public providePresenter()
{
return new PresenterA( (View) activity);
}

 @Binds
    @IntoMap
    @ActivityKey(ActivityA.class)
    abstract AndroidInjector.Factory<? extends Activity> bindActivityInjectorFactory(MainComponent.Builder builder);
The modules that don`t need the Activity.. would not need to have the instance..
t

trevjones

03/24/2017, 4:54 PM
what does the dagger processor do when you run it like this? my understanding was that the activity is not on the object graph at which point the processor would fail. Although this is all just based on my understanding and resulting assumptions.
I would think you would need either a
@BindsInstance
method on your component builder or a
@Provides
from a module. But because the creation of the component is abstracted away out of your control you can’t actually provide the instance of the activity in order to perform the binding via either the component builder binds instance method or via module constructor injection.
j

juliocbcotta

03/24/2017, 9:43 PM
Ohh, just now I saw the thread..
Well, that does not work.. it was more a suggestion of how it could work
I am trying to archive it with
@BindInstance
, but I am failing
I tried to create an issue in the dagger github, but the developer did not understand what I meant… or I did not understand what he meant
If you could help me to hightlight the problem there… it would be of great help.
t

trevjones

03/24/2017, 11:17 PM
looks like your SO question got a good answer a little while ago
j

juliocbcotta

03/27/2017, 2:03 PM
Thank you! 😄
2 Views