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
| apply plugin: 'io.gitlab.arturbosch.detekt' | |
| detekt { | |
| config = files("$rootDir/default-detekt-config.yml") | |
| filters = ".*build.*,.*/resources/.*,.*/tmp/.*" | |
| //Optional baseline, uncomment & run gradle command detektBaseline to exclude existing issues | |
| //baseline = file("detekt-baseline.xml") | |
| } |
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
| class App : Application() { | |
| override fun onCreate() { | |
| super.onCreate() | |
| Posts.init() | |
| } | |
| } |
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
| object Posts { | |
| fun init() = loadKoinModules( | |
| viewModelModule, | |
| useCaseModule, | |
| repositoryModule, | |
| networkModule, | |
| cacheModule | |
| ) | |
| } |
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
| val viewModelModule: Module = module { | |
| viewModel { PostListViewModel(usersPostsUseCase = get()) } | |
| viewModel { PostDetailsViewModel(userPostUseCase = get(), commentsUseCase = get()) } | |
| } | |
| val useCaseModule: Module = module { | |
| factory { UsersPostsUseCase(userRepository = get(), postRepository = get()) } | |
| factory { UserPostUseCase(userRepository = get(), postRepository = get()) } | |
| factory { CommentsUseCase(commentRepository = get()) } | |
| } |
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
| allprojects { | |
| apply from: "$rootDir/ktlint.gradle" | |
| } |
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
| repositories { | |
| jcenter() | |
| } | |
| configurations { | |
| ktlint | |
| } | |
| dependencies { | |
| ktlint "com.github.shyiko:ktlint:0.29.0" |
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
| apply from: "$rootDir/common-android-library.gradle" | |
| dependencies { | |
| implementation project(Modules.cache) | |
| implementation project(Modules.network) | |
| implementation project(Modules.presentation) | |
| implementation Libraries.koin | |
| implementation Libraries.rxkotlin | |
| implementation SupportLibraries.appcompat |
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
| apply plugin: 'com.android.library' | |
| apply plugin: 'kotlin-android' | |
| apply plugin: 'kotlin-android-extensions' | |
| android { | |
| compileSdkVersion Versions.compileSdk | |
| defaultConfig { | |
| minSdkVersion Versions.minSdk | |
| targetSdkVersion Versions.targetSdk |
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
| fun <T> MutableLiveData<Resource<T>>.setSuccess(data: T? = null) = | |
| postValue(Resource(ResourceState.SUCCESS, data)) | |
| fun <T> MutableLiveData<Resource<T>>.setLoading() = | |
| postValue(Resource(ResourceState.LOADING, value?.data)) | |
| fun <T> MutableLiveData<Resource<T>>.setError(message: String? = null) = | |
| postValue(Resource(ResourceState.ERROR, value?.data, message)) |
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
| class PostRepositoryImplTest { | |
| private lateinit var repository: PostRepositoryImpl | |
| private val mockCacheDataSource: PostCacheDataSource = mock() | |
| private val mockRemoteDataSource: PostRemoteDataSource = mock() | |
| private val postId = post.id | |
| private val cacheItem = post.copy(title = "cache") |