So I've been spending a lot of time with Mortar and Flow this weekend, and I think I've finally worked most of it out. I've found that it's a little bit more complex than I originally thought, mostly because I haven't quite gotten my mind around Dagger's ObjectGraph Scoping, which Mortar relies on heavily. I've read as much as I could find on this on Dagger's site, but I find information on this subject lacking when it relates specifically to Dagger.
So I have a few questions: 1. I see examples of them scoping @Singleton's:
@Layout(R.layout.screen_friend)
public class FriendScreen implements Blueprint {
@Override public String getMortarScopeName() {
return getClass().getName();
}
@Override public Object getDaggerModule() {
return new Module();
}
@dagger.Module(
injects = FriendView.class
)
static class Module {
}
@Singleton
public static class Presenter extends ViewPresenter<TestView> {
@Inject
public Presenter() {
Log.d("FriendScreen", "Friend Presenter Created");
}
@Override protected void onLoad(Bundle savedInstanceState) {
super.onLoad(savedInstanceState);
}
}
Is Presenter in this case scoped to this Module specifically because it's an inner class? 2. How can I make sure that an instance of it is only created in this Object Graph but not the global application object graph? 2. What if the Presenter was too big, and I wanted to move it to it's own separate class? How would I scope it just to this module? 3. I noticed that some of the Module classes in their examples are static, and others aren't. Does this have any effect on scoping? 4. Where can I read more to better understand Dagger's Object Graph. I need to get a better understanding of includes, injects, addsTo and how those are used in ObjectGraph creation etc:
@dagger.Module( //
includes = ActionBarModule.class,
injects = MainView.class,
addsTo = ApplicationModule.class, //
library = true //
)