-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6473c7f
commit 9fe32db
Showing
88 changed files
with
1,060 additions
and
50 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
22 changes: 22 additions & 0 deletions
22
domain-di/src/main/java/com/wednesday/template/domain/DomainModule.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.wednesday.template.domain | ||
|
||
import com.wednesday.template.domain.weather.GetFavouriteCitiesFlowUseCase | ||
import com.wednesday.template.domain.weather.GetFavouriteCitiesFlowUseCaseImpl | ||
import com.wednesday.template.domain.weather.RemoveCityFavouriteUseCase | ||
import com.wednesday.template.domain.weather.RemoveCityFavouriteUseCaseImpl | ||
import com.wednesday.template.domain.weather.SearchCitiesUseCase | ||
import com.wednesday.template.domain.weather.SearchCitiesUseCaseImpl | ||
import com.wednesday.template.domain.weather.SetCityFavouriteUseCase | ||
import com.wednesday.template.domain.weather.SetCityFavouriteUseCaseImpl | ||
import org.koin.dsl.module | ||
|
||
val domainModule = module { | ||
// Weather | ||
single<GetFavouriteCitiesFlowUseCase> { GetFavouriteCitiesFlowUseCaseImpl(get()) } | ||
|
||
single<SetCityFavouriteUseCase> { SetCityFavouriteUseCaseImpl(get()) } | ||
|
||
single<RemoveCityFavouriteUseCase> { RemoveCityFavouriteUseCaseImpl(get()) } | ||
|
||
single<SearchCitiesUseCase> { SearchCitiesUseCaseImpl(get()) } | ||
} |
8 changes: 8 additions & 0 deletions
8
domain-entity/src/main/java/com/wednesday/template/domain/base/Result.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.wednesday.template.domain.base | ||
|
||
sealed class Result<out T> { | ||
|
||
class Success<T>(val data: T) : Result<T>() | ||
|
||
class Error(val exception: Exception) : Result<Nothing>() | ||
} |
This file contains 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
21 changes: 21 additions & 0 deletions
21
.../src/main/java/com/wednesday/template/domain/weather/GetFavouriteCitiesFlowUseCaseImpl.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.wednesday.template.domain.weather | ||
|
||
import com.wednesday.template.repo.weather.WeatherRepository | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.onEach | ||
import timber.log.Timber | ||
|
||
class GetFavouriteCitiesFlowUseCaseImpl( | ||
private val weatherRepository: WeatherRepository | ||
): GetFavouriteCitiesFlowUseCase { | ||
|
||
override fun invokeInternal(param: Unit): Flow<List<City>> { | ||
Timber.tag(TAG).d("invokeInternal") | ||
return weatherRepository.getFavouriteCitiesFlow() | ||
.onEach { Timber.tag(TAG).d("invokeInternal: emit = $it") } | ||
} | ||
|
||
companion object { | ||
private const val TAG = "GetFavouriteCitiesFlowUseCaseImpl" | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...mpl/src/main/java/com/wednesday/template/domain/weather/RemoveCityFavouriteUseCaseImpl.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.wednesday.template.domain.weather | ||
|
||
import com.wednesday.template.repo.weather.WeatherRepository | ||
import timber.log.Timber | ||
|
||
class RemoveCityFavouriteUseCaseImpl( | ||
private val weatherRepository: WeatherRepository | ||
) : RemoveCityFavouriteUseCase { | ||
|
||
override suspend fun invokeInternal(param: City) { | ||
Timber.tag(TAG).d("invokeInternal: param = $param") | ||
return weatherRepository.removeCityAsFavourite(param) | ||
} | ||
|
||
companion object { | ||
private const val TAG = "RemoveCityFavouriteUseCaseImpl" | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
domain-impl/src/main/java/com/wednesday/template/domain/weather/SearchCitiesUseCaseImpl.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.wednesday.template.domain.weather | ||
|
||
import com.wednesday.template.repo.weather.WeatherRepository | ||
import timber.log.Timber | ||
|
||
class SearchCitiesUseCaseImpl( | ||
private val weatherRepository: WeatherRepository | ||
): SearchCitiesUseCase { | ||
|
||
override suspend fun invokeInternal(param: String): List<City> { | ||
Timber.tag(TAG).d("invokeInternal: param = $param") | ||
return weatherRepository.searchCities(param) | ||
} | ||
|
||
companion object { | ||
private const val TAG = "SearchCitiesUseCaseImpl" | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...n-impl/src/main/java/com/wednesday/template/domain/weather/SetCityFavouriteUseCaseImpl.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.wednesday.template.domain.weather | ||
|
||
import com.wednesday.template.repo.weather.WeatherRepository | ||
import timber.log.Timber | ||
|
||
class SetCityFavouriteUseCaseImpl( | ||
private val weatherRepository: WeatherRepository | ||
) : SetCityFavouriteUseCase { | ||
|
||
override suspend fun invokeInternal(param: City) { | ||
Timber.tag(TAG).d("invokeInternal: param = $param") | ||
return weatherRepository.setCityAsFavourite(param) | ||
} | ||
|
||
companion object { | ||
private const val TAG = "SetCityFavouriteUseCaseImpl" | ||
} | ||
} |
This file contains 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
10 changes: 10 additions & 0 deletions
10
domain/src/main/java/com/wednesday/template/domain/base/BaseFlowUseCase.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.wednesday.template.domain.base | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface BaseFlowUseCase<IN, OUT> { | ||
|
||
operator fun invoke(param: IN): Flow<OUT> = invokeInternal(param) | ||
|
||
fun invokeInternal(param: IN): Flow<OUT> | ||
} |
14 changes: 14 additions & 0 deletions
14
domain/src/main/java/com/wednesday/template/domain/base/BaseSuspendUseCase.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.wednesday.template.domain.base | ||
|
||
interface BaseSuspendUseCase<IN, OUT> { | ||
|
||
suspend operator fun invoke(param: IN): Result<OUT> { | ||
return try { | ||
Result.Success(invokeInternal(param)) | ||
} catch (e: Exception) { | ||
Result.Error(e) | ||
} | ||
} | ||
|
||
suspend fun invokeInternal(param: IN): OUT | ||
} |
15 changes: 15 additions & 0 deletions
15
domain/src/main/java/com/wednesday/template/domain/base/BaseUseCase.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.wednesday.template.domain.base | ||
|
||
interface BaseUseCase<IN, OUT> { | ||
|
||
operator fun invoke(param: IN): Result<OUT> { | ||
return try { | ||
Result.Success(invokeInternal(param)) | ||
} catch (e: Exception) { | ||
Result.Error(e) | ||
} | ||
} | ||
|
||
fun invokeInternal(param: IN): OUT | ||
} | ||
|
5 changes: 5 additions & 0 deletions
5
domain/src/main/java/com/wednesday/template/domain/weather/GetFavouriteCitiesFlowUseCase.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.wednesday.template.domain.weather | ||
|
||
import com.wednesday.template.domain.base.BaseFlowUseCase | ||
|
||
interface GetFavouriteCitiesFlowUseCase: BaseFlowUseCase<Unit, List<City>> |
5 changes: 5 additions & 0 deletions
5
domain/src/main/java/com/wednesday/template/domain/weather/RemoveCityFavouriteUseCase.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.wednesday.template.domain.weather | ||
|
||
import com.wednesday.template.domain.base.BaseSuspendUseCase | ||
|
||
interface RemoveCityFavouriteUseCase: BaseSuspendUseCase<City, Unit> |
5 changes: 5 additions & 0 deletions
5
domain/src/main/java/com/wednesday/template/domain/weather/SearchCitiesUseCase.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.wednesday.template.domain.weather | ||
|
||
import com.wednesday.template.domain.base.BaseSuspendUseCase | ||
|
||
interface SearchCitiesUseCase: BaseSuspendUseCase<String, List<City>> |
5 changes: 5 additions & 0 deletions
5
domain/src/main/java/com/wednesday/template/domain/weather/SetCityFavouriteUseCase.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.wednesday.template.domain.weather | ||
|
||
import com.wednesday.template.domain.base.BaseSuspendUseCase | ||
|
||
interface SetCityFavouriteUseCase: BaseSuspendUseCase<City, Unit> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
plugins { | ||
id 'com.android.library' | ||
id 'kotlin-android' | ||
} | ||
|
||
apply from: "$rootProject.projectDir/android.gradle" | ||
|
||
dependencies { | ||
implementation project(":interactor") | ||
implementation project(":interactor-impl") | ||
|
||
def ext = rootProject.ext | ||
|
||
implementation ext.koin.core | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
24 changes: 24 additions & 0 deletions
24
...ctor-di/src/androidTest/java/com/wednesday/template/interactor/ExampleInstrumentedTest.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.wednesday.template.interactor | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("com.wednesday.template.interactor.test", appContext.packageName) | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.wednesday.template.interactor_di"> | ||
|
||
</manifest> |
22 changes: 22 additions & 0 deletions
22
interactor-di/src/main/java/com/wednesday/template/interactor/InteractorModule.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.wednesday.template.interactor | ||
|
||
import com.wednesday.template.interactor.base.CoroutineContextController | ||
import com.wednesday.template.interactor.base.CoroutineContextControllerImpl | ||
import com.wednesday.template.interactor.weather.FavouriteWeatherInteractor | ||
import com.wednesday.template.interactor.weather.SearchCityInteractor | ||
import com.wednesday.template.interactor.weather.favourite.FavouriteWeatherInteractorImpl | ||
import com.wednesday.template.interactor.weather.UICityMapper | ||
import com.wednesday.template.interactor.weather.UICityMapperImpl | ||
import com.wednesday.template.interactor.weather.search.SearchCityInteractorImpl | ||
import org.koin.dsl.module | ||
|
||
val interactorModule = module { | ||
single<CoroutineContextController> { CoroutineContextControllerImpl() } | ||
|
||
// Weather | ||
single<UICityMapper> { UICityMapperImpl() } | ||
|
||
factory<FavouriteWeatherInteractor> { FavouriteWeatherInteractorImpl(get(), get(), get(), get(), get()) } | ||
|
||
factory<SearchCityInteractor> { SearchCityInteractorImpl(get(), get(), get()) } | ||
} |
17 changes: 17 additions & 0 deletions
17
interactor-di/src/test/java/com/wednesday/template/interactor/ExampleUnitTest.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.wednesday.template.interactor | ||
|
||
import org.junit.Test | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Example local unit test, which will execute on the development machine (host). | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
class ExampleUnitTest { | ||
@Test | ||
fun addition_isCorrect() { | ||
assertEquals(4, 2 + 2) | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Empty file.
Oops, something went wrong.