This isn't so much of an issue but more of a design question. How would you go about reusing common views in u2020-mvp?
For example, I'd like to create a common LoginView which can be shown in different activities/fragments. The associated LoginComponent, LoginPresenter, and LoginModule all use @LoginScope. The idea here is to have all the functionality of logging-in encapsulated in LoginView which I can use at anytime.
I tried to accomplish this in few ways and ran into issues. For the examples below, let's assume we want to put LoginView into our MainActivity.
- Include LoginModule in MainComponent as follows. I ran into issues with Dagger complaining about @LoginScope being used in @MainScope.
@MainScope
@Component(
dependencies = ApplicationComponent.class,
modules = {
MainModule.class,
LoginModule.class
}
)
- Defining LoginComponent as the "parent" component and MainComponent as a subcomponent. This solution is not desirable either because the common component acts as the "parent" component. Also you run into the issue of not being able to use multiple common components.
@MainScope
@Subcomponent(
modules = MainModule.class)
@LoginScope
@Component(
dependencies = ApplicationComponent.class,
modules = LoginModule.class
)
Is there no proper way to use common views in u2020-mvp?
The other option is to include the common view as part of a Fragment however there isn't an example here of mvp with Dagger injection of Fragments, views and its presenters.
This isn't so much of an issue but more of a design question. How would you go about reusing common views in u2020-mvp?
For example, I'd like to create a common LoginView which can be shown in different activities/fragments. The associated LoginComponent, LoginPresenter, and LoginModule all use @LoginScope. The idea here is to have all the functionality of logging-in encapsulated in LoginView which I can use at anytime.
I tried to accomplish this in few ways and ran into issues. For the examples below, let's assume we want to put LoginView into our MainActivity.
Is there no proper way to use common views in u2020-mvp?
The other option is to include the common view as part of a Fragment however there isn't an example here of mvp with Dagger injection of Fragments, views and its presenters.