-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
19 write all interfaces and classes for the core module (#32)
- Loading branch information
Showing
13 changed files
with
146 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
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,38 @@ | ||
plugins { | ||
alias(libs.plugins.android.library) | ||
alias(libs.plugins.jetbrains.kotlin.android) | ||
} | ||
|
||
android { | ||
namespace = "com.github.yuriisurzhykov.purs.core.android" | ||
compileSdk = ProjectProperties.compileSdkVersion | ||
|
||
defaultConfig { | ||
minSdk = ProjectProperties.minSdkVersion | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
consumerProguardFiles("consumer-rules.pro") | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
proguardFiles( | ||
getDefaultProguardFile("proguard-android-optimize.txt"), | ||
"proguard-rules.pro" | ||
) | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility = ProjectProperties.javaSourceCompatibility | ||
targetCompatibility = ProjectProperties.javaTargetCompatibility | ||
} | ||
kotlinOptions { | ||
jvmTarget = ProjectProperties.kotlinJvmTarget | ||
} | ||
} | ||
|
||
dependencies { | ||
api(projects.core) | ||
implementation(libs.androidx.core.ktx) | ||
} |
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,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 |
14 changes: 14 additions & 0 deletions
14
core/android/src/main/kotlin/com/github/yuriisurzhykov/purs/core/android/AndroidLogger.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.github.yuriisurzhykov.purs.core.android | ||
|
||
import android.util.Log | ||
import com.github.yuriisurzhykov.purs.core.Logger | ||
|
||
fun AndroidLogcatLogger(): Logger = object : Logger { | ||
override fun d(tag: String, message: String) { | ||
Log.d(tag, message) | ||
} | ||
|
||
override fun e(tag: String, message: String) { | ||
Log.e(tag, message) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,9 +1,12 @@ | ||
plugins { | ||
id("java-library") | ||
alias(libs.plugins.jetbrains.kotlin.jvm) | ||
} | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_19 | ||
targetCompatibility = JavaVersion.VERSION_19 | ||
} | ||
|
||
dependencies { | ||
implementation(libs.kotlinx.coroutines.core) | ||
} |
4 changes: 3 additions & 1 deletion
4
...m/github/yuriisurzhykov/purs/core/Core.kt → .../github/yuriisurzhykov/purs/core/Clear.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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
package com.github.yuriisurzhykov.purs.core | ||
|
||
class Core { | ||
interface Clear { | ||
|
||
fun clear() | ||
} |
37 changes: 37 additions & 0 deletions
37
core/src/main/java/com/github/yuriisurzhykov/purs/core/Dispatchers.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,37 @@ | ||
package com.github.yuriisurzhykov.purs.core | ||
|
||
import kotlinx.coroutines.CoroutineDispatcher | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Job | ||
import kotlinx.coroutines.launch | ||
import kotlinx.coroutines.withContext | ||
|
||
interface Dispatchers { | ||
|
||
fun launchUi(scope: CoroutineScope, block: suspend CoroutineScope.() -> Unit): Job | ||
fun launchBackground(scope: CoroutineScope, block: suspend CoroutineScope.() -> Unit): Job | ||
suspend fun switchToUi(block: suspend CoroutineScope.() -> Unit) | ||
|
||
abstract class Abstract( | ||
private val uiScope: CoroutineDispatcher, | ||
private val backgroundScope: CoroutineDispatcher | ||
) : Dispatchers { | ||
override fun launchUi( | ||
scope: CoroutineScope, | ||
block: suspend CoroutineScope.() -> Unit | ||
): Job = scope.launch(uiScope, block = block) | ||
|
||
override fun launchBackground( | ||
scope: CoroutineScope, | ||
block: suspend CoroutineScope.() -> Unit | ||
): Job = scope.launch(backgroundScope, block = block) | ||
|
||
override suspend fun switchToUi(block: suspend CoroutineScope.() -> Unit) = | ||
withContext(uiScope, block) | ||
} | ||
|
||
class Base : Abstract( | ||
uiScope = kotlinx.coroutines.Dispatchers.Main, | ||
backgroundScope = kotlinx.coroutines.Dispatchers.Default | ||
) | ||
} |
7 changes: 7 additions & 0 deletions
7
core/src/main/java/com/github/yuriisurzhykov/purs/core/Logger.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,7 @@ | ||
package com.github.yuriisurzhykov.purs.core | ||
|
||
interface Logger { | ||
fun d(tag: String, message: String) | ||
|
||
fun e(tag: String, message: String) | ||
} |
8 changes: 8 additions & 0 deletions
8
core/src/main/java/com/github/yuriisurzhykov/purs/core/Mapper.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.github.yuriisurzhykov.purs.core | ||
|
||
interface Mapper<S, R> { | ||
|
||
fun map(source: S): R | ||
|
||
interface Unit<T> : Mapper<T, Unit<T>> | ||
} |
6 changes: 6 additions & 0 deletions
6
core/src/main/java/com/github/yuriisurzhykov/purs/core/Read.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,6 @@ | ||
package com.github.yuriisurzhykov.purs.core | ||
|
||
interface Read<T> { | ||
|
||
fun read(): T | ||
} |
6 changes: 6 additions & 0 deletions
6
core/src/main/java/com/github/yuriisurzhykov/purs/core/Save.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,6 @@ | ||
package com.github.yuriisurzhykov.purs.core | ||
|
||
interface Save<T> { | ||
|
||
fun save(data: T) | ||
} |
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