The issue with the graph you produced is the scoping. Since Service is a Singleton Transfuse cannot create it with the Activity dependency (Service -> Adapter -> Activity). It looks like you want your Service class notifying the TestAdapter class. If you really require Service to be a Singleton I would recommend using the @Observes functionality to update the TestAdapter class in a decoupled way. I've submitted a pull request to your repository with the changes.
Transfuse will inject the Activity currently associated with the object graph. If you do not scope an object Transfuse will create a new one each time in your graph. Transfuse has built into it injections relevant to the scope. If you are using a @Activity everything including the associated views to properties to extras are automatically mapped and available for injection. Take a look at the generated Activity classes and you will see what I mean.
I need to add some better validation so people can't get into this spot with scoping. Any ideas around this?
I think you also uncovered a bug with injecting non-public fields, which I will fix momentarily.Let me know if you need any clarification. Thanks.
John
I could see the case for requiring @ActivityScope to inject the activity, but that gets messy too. Typically the scopes are meant to determine the lifecycle of objects, not necessarily what can be injected into them. I think at least a bit more documentation is needed on how Transfuse injects and definitely some more validation. What I am leaning towards to to only allow Activity related injections in prototype and context-scoped beans and their related graph.
Is it possible to show an error message telling "you can't inject an Activity to a Singleton-scoped instance" or sth like that? Just curious if it is very hard to implement proper error message in annotation processing.
Transfuse will inject the Activity currently associated with the object graph. If you do not scope an object Transfuse will create a new one each time in your graph. Transfuse has built into it injections relevant to the scope. If you are using a @Activity everything including the associated views to properties to extras are automatically mapped and available for injection. Take a look at the generated Activity classes and you will see what I mean.I exactly expect create a new one ("prototype" scope) as default. btw, I generally think in the Guice mindset as I've been using it since switched from Spring in 2008, and my first Android project uses RoboGuice, can't live without DI.So, even if there is no compile error, there is a bug in my code. and my usage will create different Adapter instance to the Service and Activity.Another problem is my Adapter isn't suppose to need to inject an Activity, it just need any Context that I suppose will be application.getApplicationContext(). In Dagger, I (am forced to) know preciously what Context/Activity to inject, so I know in that case injecting an Activity or other context makes not much difference. And now Transfuse manages everything so I need to pay attention on the scope and what Context Transfuse can provide.I'll spend some time to learn about the scoping and see I can get my model work.