mirror of
https://github.com/android10/Android-CleanArchitecture.git
synced 2026-03-13 10:13:41 +08:00
Refactor user module to include user related injections.
This commit is contained in:
@@ -10,14 +10,18 @@ import com.google.gson.JsonSyntaxException;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Collection;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
/**
|
||||
* Class used to transform from Strings representing json to valid objects.
|
||||
*/
|
||||
@Singleton
|
||||
public class UserEntityJsonMapper {
|
||||
|
||||
private final Gson gson;
|
||||
|
||||
@Inject
|
||||
public UserEntityJsonMapper() {
|
||||
this.gson = new Gson();
|
||||
}
|
||||
|
||||
@@ -7,8 +7,13 @@ package com.fernandocejas.android10.sample.presentation.internal.di.modules;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import com.fernandocejas.android10.sample.data.executor.JobExecutor;
|
||||
import com.fernandocejas.android10.sample.domain.executor.PostExecutionThread;
|
||||
import com.fernandocejas.android10.sample.domain.executor.ThreadExecutor;
|
||||
import com.fernandocejas.android10.sample.presentation.UIThread;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
/**
|
||||
* Dagger module that provides objects which will live during the application lifecycle.
|
||||
@@ -22,11 +27,19 @@ public final class ApplicationModule {
|
||||
this.application = application;
|
||||
}
|
||||
|
||||
@Provides Context provideApplicationContext() {
|
||||
@Provides @Singleton Context provideApplicationContext() {
|
||||
return this.application;
|
||||
}
|
||||
|
||||
@Provides LayoutInflater provideLayoutInflater() {
|
||||
@Provides @Singleton LayoutInflater provideLayoutInflater() {
|
||||
return LayoutInflater.from(this.application);
|
||||
}
|
||||
|
||||
@Provides @Singleton ThreadExecutor provideThreadExecutor(JobExecutor jobExecutor) {
|
||||
return jobExecutor;
|
||||
}
|
||||
|
||||
@Provides @Singleton PostExecutionThread providePostExecutionThread(UIThread uiThread) {
|
||||
return uiThread;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,16 +6,12 @@ package com.fernandocejas.android10.sample.presentation.internal.di.modules;
|
||||
|
||||
import com.fernandocejas.android10.sample.data.cache.UserCache;
|
||||
import com.fernandocejas.android10.sample.data.cache.UserCacheImpl;
|
||||
import com.fernandocejas.android10.sample.data.executor.JobExecutor;
|
||||
import com.fernandocejas.android10.sample.data.repository.UserDataRepository;
|
||||
import com.fernandocejas.android10.sample.domain.executor.PostExecutionThread;
|
||||
import com.fernandocejas.android10.sample.domain.executor.ThreadExecutor;
|
||||
import com.fernandocejas.android10.sample.domain.interactor.GetUserDetailsUseCase;
|
||||
import com.fernandocejas.android10.sample.domain.interactor.GetUserDetailsUseCaseImpl;
|
||||
import com.fernandocejas.android10.sample.domain.interactor.GetUserListUseCase;
|
||||
import com.fernandocejas.android10.sample.domain.interactor.GetUserListUseCaseImpl;
|
||||
import com.fernandocejas.android10.sample.domain.repository.UserRepository;
|
||||
import com.fernandocejas.android10.sample.presentation.UIThread;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import javax.inject.Singleton;
|
||||
@@ -23,14 +19,6 @@ import javax.inject.Singleton;
|
||||
@Module
|
||||
public class UserModule {
|
||||
|
||||
@Provides @Singleton ThreadExecutor provideThreadExecutor(JobExecutor jobExecutor) {
|
||||
return jobExecutor;
|
||||
}
|
||||
|
||||
@Provides @Singleton PostExecutionThread providePostExecutionThread(UIThread uiThread) {
|
||||
return uiThread;
|
||||
}
|
||||
|
||||
@Provides @Singleton UserCache provideUserCache(UserCacheImpl userCache) {
|
||||
return userCache;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user