mirror of
https://github.com/android10/Android-CleanArchitecture.git
synced 2025-08-26 07:17:04 +08:00
Let dagger manage domain objects instances.
This commit is contained in:
@ -9,11 +9,14 @@ import com.fernandocejas.android10.sample.domain.exception.ErrorBundle;
|
||||
import com.fernandocejas.android10.sample.domain.executor.PostExecutionThread;
|
||||
import com.fernandocejas.android10.sample.domain.executor.ThreadExecutor;
|
||||
import com.fernandocejas.android10.sample.domain.repository.UserRepository;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
/**
|
||||
* This class is an implementation of {@link GetUserDetailsUseCase} that represents a use case for
|
||||
* retrieving data related to an specific {@link User}.
|
||||
*/
|
||||
@Singleton
|
||||
public class GetUserDetailsUseCaseImpl implements GetUserDetailsUseCase {
|
||||
|
||||
private final UserRepository userRepository;
|
||||
@ -32,6 +35,7 @@ public class GetUserDetailsUseCaseImpl implements GetUserDetailsUseCase {
|
||||
* @param postExecutionThread {@link PostExecutionThread} used to post updates when the use case
|
||||
* has been executed.
|
||||
*/
|
||||
@Inject
|
||||
public GetUserDetailsUseCaseImpl(UserRepository userRepository, ThreadExecutor threadExecutor,
|
||||
PostExecutionThread postExecutionThread) {
|
||||
if (userRepository == null || threadExecutor == null || postExecutionThread == null) {
|
||||
|
@ -10,11 +10,14 @@ import com.fernandocejas.android10.sample.domain.executor.PostExecutionThread;
|
||||
import com.fernandocejas.android10.sample.domain.executor.ThreadExecutor;
|
||||
import com.fernandocejas.android10.sample.domain.repository.UserRepository;
|
||||
import java.util.Collection;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
/**
|
||||
* This class is an implementation of {@link GetUserListUseCase} that represents a use case for
|
||||
* retrieving a collection of all {@link User}.
|
||||
*/
|
||||
@Singleton
|
||||
public class GetUserListUseCaseImpl implements GetUserListUseCase {
|
||||
|
||||
private final UserRepository userRepository;
|
||||
@ -32,6 +35,7 @@ public class GetUserListUseCaseImpl implements GetUserListUseCase {
|
||||
* @param postExecutionThread {@link PostExecutionThread} used to post updates when the use case
|
||||
* has been executed.
|
||||
*/
|
||||
@Inject
|
||||
public GetUserListUseCaseImpl(UserRepository userRepository, ThreadExecutor threadExecutor,
|
||||
PostExecutionThread postExecutionThread) {
|
||||
if (userRepository == null || threadExecutor == null || postExecutionThread == null) {
|
||||
|
@ -39,14 +39,11 @@ public class UserModule {
|
||||
return userDataRepository;
|
||||
}
|
||||
|
||||
@Provides GetUserListUseCase provideGetUserListUseCase(UserRepository userRepository,
|
||||
ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread) {
|
||||
return new GetUserListUseCaseImpl(userRepository, threadExecutor, postExecutionThread);
|
||||
@Provides GetUserListUseCase provideGetUserListUseCase(GetUserListUseCaseImpl getUserListUseCase) {
|
||||
return getUserListUseCase;
|
||||
}
|
||||
|
||||
@Provides GetUserDetailsUseCase provideGetUserDetailsUseCase(UserRepository userRepository,
|
||||
ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread) {
|
||||
return new GetUserDetailsUseCaseImpl(userRepository,
|
||||
threadExecutor, postExecutionThread);
|
||||
@Provides GetUserDetailsUseCase provideGetUserDetailsUseCase(GetUserDetailsUseCaseImpl getUserDetailsUseCase) {
|
||||
return getUserDetailsUseCase;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user