diff --git a/app/src/main/java/saulmm/avengers/injector/AppModule.java b/app/src/main/java/saulmm/avengers/injector/AppModule.java index 488ed4b..a4168dc 100644 --- a/app/src/main/java/saulmm/avengers/injector/AppModule.java +++ b/app/src/main/java/saulmm/avengers/injector/AppModule.java @@ -7,7 +7,13 @@ import dagger.Module; import dagger.Provides; + +import javax.inject.Named; import javax.inject.Singleton; + +import rx.Scheduler; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; import saulmm.avengers.AvengersApplication; import saulmm.avengers.BuildConfig; import saulmm.avengers.repository.CharacterRepository; @@ -40,4 +46,14 @@ Endpoint provideRestEndpoint() { @Provides @Singleton CharacterRepository provideDataRepository(RestDataSource restDataSource) { return restDataSource; } + + @Provides @Named("executor_thread") + Scheduler provideExecutorThread() { + return Schedulers.newThread(); + } + + @Provides @Named("ui_thread") + Scheduler provideUiThread() { + return AndroidSchedulers.mainThread(); + } } diff --git a/app/src/main/java/saulmm/avengers/injector/components/AppComponent.java b/app/src/main/java/saulmm/avengers/injector/components/AppComponent.java index 393a031..040b61c 100644 --- a/app/src/main/java/saulmm/avengers/injector/components/AppComponent.java +++ b/app/src/main/java/saulmm/avengers/injector/components/AppComponent.java @@ -7,6 +7,8 @@ import dagger.Component; import javax.inject.Singleton; + +import rx.Scheduler; import saulmm.avengers.AvengersApplication; import saulmm.avengers.injector.AppModule; import saulmm.avengers.repository.CharacterRepository; @@ -19,4 +21,6 @@ public interface AppComponent { CharacterRepository dataRepository(); Endpoint restEndpoint(); MarvelAuthorizer marvelAuthorizer(); + + Scheduler uiThread(); } diff --git a/app/src/main/java/saulmm/avengers/injector/modules/ActivityModule.java b/app/src/main/java/saulmm/avengers/injector/modules/ActivityModule.java index 6646587..31ea2b5 100644 --- a/app/src/main/java/saulmm/avengers/injector/modules/ActivityModule.java +++ b/app/src/main/java/saulmm/avengers/injector/modules/ActivityModule.java @@ -24,16 +24,6 @@ public ActivityModule(Context mContext) { this.mContext = mContext; } - @Provides @Activity @Named("executor_thread") - Scheduler provideExecutorThread() { - return Schedulers.newThread(); - } - - @Provides @Activity @Named("ui_thread") - Scheduler provideUiThread() { - return AndroidSchedulers.mainThread(); - } - @Provides @Activity Context provideActivityContext() { return mContext; diff --git a/domain/src/main/java/saulmm/avengers/GetCharactersUsecase.java b/domain/src/main/java/saulmm/avengers/GetCharactersUsecase.java index a1b3493..f40faf0 100644 --- a/domain/src/main/java/saulmm/avengers/GetCharactersUsecase.java +++ b/domain/src/main/java/saulmm/avengers/GetCharactersUsecase.java @@ -18,7 +18,9 @@ public class GetCharactersUsecase extends Usecase> { Scheduler uiThread, executorThread; - @Inject public GetCharactersUsecase(CharacterRepository repository, @Named("ui_thread") Scheduler uiThread, @Named("executor_thread") Scheduler executorThread) { + @Inject public GetCharactersUsecase(CharacterRepository repository, + @Named("ui_thread") Scheduler uiThread, @Named("executor_thread") Scheduler executorThread) { + mRepository = repository; this.uiThread = uiThread; this.executorThread = executorThread;