This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @AppScoped | |
| public class MessageViewModel extends ViewModel{ | |
| @NonNull | |
| private final MessageRepository mRepository; | |
| @Inject | |
| public MessageViewModel(@NonNull MessageRepository repository) { | |
| this.mRepository = repository; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Module | |
| public abstract class MessageModule { | |
| @FragmentScoped | |
| @ContributesAndroidInjector | |
| abstract MessageFragment messageFragment(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @ActivityScoped | |
| public class MessageFragment extends DaggerFragment implements BaseView { | |
| private TextView mMessageTextView; | |
| private MessageViewModel mViewModel; | |
| @Inject | |
| ViewModelProvider.Factory viewModelFactory; | |
| @Inject |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Module | |
| public abstract class ActivityBindingModule { | |
| @ActivityScoped | |
| @ContributesAndroidInjector(modules = {QuakesModule.class}) | |
| abstract QuakesActivity ratesActivity(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface BaseView { | |
| void bindViewModel(); | |
| void unbindViewModel(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Module | |
| public abstract class ActivityBindingModule { | |
| @ActivityScoped | |
| @ContributesAndroidInjector(modules = {MessageModule.class}) | |
| abstract MessageActivity messageActivity(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Documented | |
| @Scope | |
| @Retention(RetentionPolicy.RUNTIME) | |
| public @interface AppScoped { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @AppScoped | |
| @Component(modules = {ViewModelModule.class, | |
| AppModule.class, | |
| ActivityBindingModule.class, | |
| AndroidSupportInjectionModule.class}) | |
| public interface AppComponent extends AndroidInjector<Application> { | |
| @Component.Builder | |
| interface Builder { | |
| @BindsInstance |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Module | |
| public abstract class AppModule { | |
| // expose Application as an injectable context | |
| @Binds | |
| abstract Context bindContext(Application application); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Application extends DaggerApplication { | |
| @Override | |
| protected AndroidInjector<? extends DaggerApplication> applicationInjector() { | |
| return DaggerAppComponent.builder().application(this).build(); | |
| } | |
| } |