Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Gradle Version catalog + upgrade dependencies (#424)
- Loading branch information
Romain Boisselle
committed
Nov 29, 2022
1 parent
d51db04
commit a480fe3
Showing
16 changed files
with
128 additions
and
85 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
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
33 changes: 20 additions & 13 deletions
33
...ork/android/kodein-di-framework-android-x/src/main/java/org/kodein/di/android/x/scopes.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,39 +1,46 @@ | ||
package org.kodein.di.android.x | ||
|
||
import androidx.lifecycle.DefaultLifecycleObserver | ||
import androidx.lifecycle.Lifecycle | ||
import androidx.lifecycle.LifecycleObserver | ||
import androidx.lifecycle.LifecycleEventObserver | ||
import androidx.lifecycle.LifecycleOwner | ||
import androidx.lifecycle.OnLifecycleEvent | ||
import org.kodein.di.bindings.* | ||
import org.kodein.di.internal.synchronizedIfNull | ||
import java.util.* | ||
|
||
open class AndroidLifecycleScope private constructor(private val newRegistry: () -> ScopeRegistry) : Scope<LifecycleOwner> { | ||
open class AndroidLifecycleScope private constructor( | ||
private val newRegistry: () -> ScopeRegistry | ||
) : Scope<LifecycleOwner>, DefaultLifecycleObserver { | ||
|
||
companion object multiItem: AndroidLifecycleScope(::StandardScopeRegistry) | ||
companion object multiItem : AndroidLifecycleScope(::StandardScopeRegistry) | ||
|
||
object singleItem: AndroidLifecycleScope(::SingleItemScopeRegistry) | ||
object singleItem : AndroidLifecycleScope(::SingleItemScopeRegistry) | ||
|
||
private val map = HashMap<LifecycleOwner, ScopeRegistry>() | ||
|
||
override fun getRegistry(context: LifecycleOwner): ScopeRegistry { | ||
return synchronizedIfNull( | ||
lock = map, | ||
lock = map, | ||
predicate = { map[context] }, | ||
ifNotNull = { it }, | ||
ifNull = { | ||
val registry = newRegistry() | ||
map[context] = registry | ||
context.lifecycle.addObserver(object : LifecycleObserver { | ||
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) | ||
fun onDestroy() { | ||
context.lifecycle.removeObserver(this) | ||
registry.clear() | ||
map.remove(context) | ||
context.lifecycle.addObserver( | ||
LifecycleEventObserver { _, event -> | ||
if (event == Lifecycle.Event.ON_DESTROY) { | ||
context.lifecycle.removeObserver(this) | ||
registry.clear() | ||
map.remove(context) | ||
} | ||
} | ||
}) | ||
) | ||
registry | ||
} | ||
) | ||
} | ||
|
||
override fun onDestroy(owner: LifecycleOwner) { | ||
super.onDestroy(owner) | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
[versions] | ||
# Core | ||
kaverit-version = "2.2.1" | ||
kotlin-version = "1.7.20" | ||
# Android | ||
android-appcompat-version = "28.0.0" | ||
androidx-appcompat-version = "1.5.1" | ||
androidx-fragment-version = "1.5.4" | ||
androidx-lifecycle-version = "2.5.1" | ||
# Compose | ||
compose-version = "1.2.1" | ||
# Ktor | ||
ktor-version = "2.1.3" | ||
# JxInject | ||
javax-inject-version = "1" | ||
# TornadoFX | ||
openjfx-version = "0.0.7" | ||
javafx-version = "12.0.1" | ||
tornadofx-version = "1.7.20" | ||
testfx-version = "4.0.4-alpha" | ||
# Test | ||
junit-version = "4.13.2" | ||
junit-jupiter-version = "5.6.0" | ||
|
||
[libraries] | ||
# Core | ||
kosi-kaverit = { module = "org.kodein.type:kaverit", version.ref = "kaverit-version" } | ||
# Android | ||
android-appcompat = { module = "com.android.support:appcompat-v7", version.ref = "android-appcompat-version" } | ||
android-x-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat-version" } | ||
android-x-fragment-ktx = { module = "androidx.fragment:fragment-ktx", version.ref = "androidx-fragment-version" } | ||
android-x-lifecycle-viewmodel-ktx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "androidx-lifecycle-version" } | ||
android-x-lifecycle-viewmodel-savedstate = { module = "androidx.lifecycle:lifecycle-viewmodel-savedstate", version.ref = "androidx-lifecycle-version" } | ||
android-x-lifecycle-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "androidx-lifecycle-version" } | ||
# Ktor | ||
ktor-server-core = { module = "io.ktor:ktor-server-core", version.ref = "ktor-version" } | ||
ktor-server-sessions = { module = "io.ktor:ktor-server-sessions", version.ref = "ktor-version" } | ||
ktor-test-server = { module = "io.ktor:ktor-server-tests", version.ref = "ktor-version" } | ||
ktor-test-server-default-headers = { module = "io.ktor:ktor-server-default-headers", version.ref = "ktor-version" } | ||
# JxInject | ||
javax-inject = { module = "javax.inject:javax.inject", version.ref = "javax-inject-version" } | ||
# TornadoFX | ||
tornadofx = { module = "no.tornado:tornadofx", version.ref = "tornadofx-version" } | ||
kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin-version" } | ||
testfx = { module = "org.testfx:testfx-core", version.ref = "testfx-version" } | ||
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-jupiter-version" } | ||
# Test | ||
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin-version" } | ||
kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin-version" } | ||
junit = { module = "junit:junit", version.ref = "junit-version" } | ||
|
||
[plugins] | ||
openjfx = { id = "org.openjfx.javafxplugin", version.ref = "openjfx-version" } | ||
compose = { id = "org.jetbrains.compose", version.ref = "compose-version" } |
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
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