init
This commit is contained in:
1
domain/domain/.gitignore
vendored
Normal file
1
domain/domain/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
37
domain/domain/build.gradle.kts
Normal file
37
domain/domain/build.gradle.kts
Normal file
@@ -0,0 +1,37 @@
|
||||
plugins {
|
||||
id("com.android.library")
|
||||
id("kotlin-android")
|
||||
id("org.jetbrains.kotlin.android")
|
||||
id("com.google.dagger.hilt.android")
|
||||
id("com.google.devtools.ksp")
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk = Config.SdkVersion.COMPILE
|
||||
namespace = "com.testappbank.test"
|
||||
|
||||
defaultConfig {
|
||||
minSdk = Config.SdkVersion.MIN
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles("proguard-rules.pro")
|
||||
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
isCoreLibraryDesugaringEnabled = true
|
||||
sourceCompatibility = JavaVersion.VERSION_21
|
||||
targetCompatibility = JavaVersion.VERSION_21
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":domain:domain_impl"))
|
||||
|
||||
implementation(fileTree("dir" to "libs", "include" to listOf("*.jar")))
|
||||
|
||||
implementation(libs.hilt.android)
|
||||
ksp(libs.hilt.compiler)
|
||||
|
||||
coreLibraryDesugaring(libs.desugar.jdk.libs)
|
||||
}
|
||||
21
domain/domain/proguard-rules.pro
vendored
Normal file
21
domain/domain/proguard-rules.pro
vendored
Normal file
@@ -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.kts.kts.
|
||||
#
|
||||
# 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
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.testapp.domain.domain.gatway
|
||||
|
||||
import com.testapp.domain.domain.models.ActionResult
|
||||
import com.testapp.domain.domain.models.Weather
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
interface WeatherGateWay {
|
||||
|
||||
suspend fun getWeather(id: String): Weather
|
||||
suspend fun saveWeather(weather:Weather )
|
||||
suspend fun subscribeForWeatherList(): Flow<List<Weather>>
|
||||
suspend fun requestNewWeatherForPlace(placeName: String): ActionResult<Weather>
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.testapp.domain.domain.models
|
||||
|
||||
|
||||
sealed class ActionResult<out Data> {
|
||||
|
||||
class Success<Data>(val data: Data) : ActionResult<Data>()
|
||||
class Error(val reason: Throwable? = null) : ActionResult<Nothing>()
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.testapp.domain.domain.models
|
||||
|
||||
import java.util.Date
|
||||
|
||||
data class Weather(
|
||||
val id: String,
|
||||
val location: String,
|
||||
val date: Date,
|
||||
val temperature: Double
|
||||
) {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as Weather
|
||||
|
||||
if (id != other.id) return false
|
||||
if (location != other.location) return false
|
||||
if (date != other.date) return false
|
||||
if (temperature != other.temperature) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return id.hashCode()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.testapp.domain.domain.usecase
|
||||
|
||||
import com.testapp.domain.domain.models.Weather
|
||||
|
||||
interface GetWeather {
|
||||
|
||||
suspend fun getWeather(id:String):Weather
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.testapp.domain.domain.usecase
|
||||
|
||||
import com.testapp.domain.domain.models.Weather
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
interface GetWeatherList {
|
||||
|
||||
suspend fun subscribeForWeatherList(): Flow<List<Weather>>
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.testapp.domain.domain.usecase
|
||||
|
||||
import com.testapp.domain.domain.models.ActionResult
|
||||
import com.testapp.domain.domain.models.Weather
|
||||
|
||||
interface RequestNewWeather {
|
||||
|
||||
suspend fun requestNewWeatherForPlace(placeName: String): ActionResult<Weather>
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.testapp.domain.domain.usecase
|
||||
|
||||
import com.testapp.domain.domain.models.ActionResult
|
||||
import com.testapp.domain.domain.models.Weather
|
||||
|
||||
interface SaveWeather {
|
||||
|
||||
suspend fun saveWeather(weather: Weather)
|
||||
|
||||
}
|
||||
1
domain/domain_impl/.gitignore
vendored
Normal file
1
domain/domain_impl/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
37
domain/domain_impl/build.gradle.kts
Normal file
37
domain/domain_impl/build.gradle.kts
Normal file
@@ -0,0 +1,37 @@
|
||||
plugins {
|
||||
id("com.android.library")
|
||||
id("kotlin-android")
|
||||
id("org.jetbrains.kotlin.android")
|
||||
id("com.google.dagger.hilt.android")
|
||||
id("com.google.devtools.ksp")
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk = Config.SdkVersion.COMPILE
|
||||
namespace = "com.testappbank.test"
|
||||
|
||||
defaultConfig {
|
||||
minSdk = Config.SdkVersion.MIN
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles("proguard-rules.pro")
|
||||
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
isCoreLibraryDesugaringEnabled = true
|
||||
sourceCompatibility = JavaVersion.VERSION_21
|
||||
targetCompatibility = JavaVersion.VERSION_21
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(fileTree("dir" to "libs", "include" to listOf("*.jar")))
|
||||
|
||||
implementation(project(":domain:domain"))
|
||||
|
||||
implementation(libs.hilt.android)
|
||||
ksp(libs.hilt.compiler)
|
||||
|
||||
coreLibraryDesugaring(libs.desugar.jdk.libs)
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.testapp.domain.usecase
|
||||
|
||||
import com.testapp.domain.domain.gatway.WeatherGateWay
|
||||
import com.testapp.domain.domain.models.Weather
|
||||
import com.testapp.domain.domain.usecase.GetWeather
|
||||
import javax.inject.Inject
|
||||
|
||||
class GetWeatherImpl @Inject constructor(
|
||||
private val gateWay: WeatherGateWay,
|
||||
) : GetWeather {
|
||||
|
||||
override suspend fun getWeather(id: String): Weather =
|
||||
gateWay.getWeather(id)
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.testapp.domain.usecase
|
||||
|
||||
import com.testapp.domain.domain.gatway.WeatherGateWay
|
||||
import com.testapp.domain.domain.models.Weather
|
||||
import com.testapp.domain.domain.usecase.GetWeatherList
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import javax.inject.Inject
|
||||
|
||||
class GetWeatherListImpl @Inject constructor(
|
||||
private val gateWay: WeatherGateWay,
|
||||
) : GetWeatherList {
|
||||
|
||||
override suspend fun subscribeForWeatherList(): Flow<List<Weather>> =
|
||||
gateWay.subscribeForWeatherList()
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.testapp.domain.usecase
|
||||
|
||||
import com.testapp.domain.domain.gatway.WeatherGateWay
|
||||
import com.testapp.domain.domain.models.ActionResult
|
||||
import com.testapp.domain.domain.models.Weather
|
||||
import com.testapp.domain.domain.usecase.RequestNewWeather
|
||||
import javax.inject.Inject
|
||||
|
||||
class RequestNewWeatherImpl @Inject constructor(
|
||||
private val gateWay: WeatherGateWay,
|
||||
|
||||
) : RequestNewWeather {
|
||||
|
||||
override suspend fun requestNewWeatherForPlace(placeName: String): ActionResult<Weather> =
|
||||
gateWay.requestNewWeatherForPlace(placeName)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.testapp.domain.usecase
|
||||
|
||||
import com.testapp.domain.domain.gatway.WeatherGateWay
|
||||
import com.testapp.domain.domain.models.ActionResult
|
||||
import com.testapp.domain.domain.models.Weather
|
||||
import com.testapp.domain.domain.usecase.SaveWeather
|
||||
import javax.inject.Inject
|
||||
|
||||
class SaveWeatherImpl @Inject constructor(
|
||||
val gateWay: WeatherGateWay
|
||||
) : SaveWeather {
|
||||
|
||||
override suspend fun saveWeather(weather: Weather) {
|
||||
gateWay.saveWeather(weather)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user