Repo created
This commit is contained in:
parent
75dc487a7a
commit
39c29d175b
6317 changed files with 388324 additions and 2 deletions
15
legacy/di/build.gradle.kts
Normal file
15
legacy/di/build.gradle.kts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
plugins {
|
||||
id(ThunderbirdPlugins.Library.android)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "app.k9mail.legacy.di"
|
||||
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(libs.koin.android)
|
||||
}
|
||||
35
legacy/di/src/main/kotlin/app/k9mail/legacy/di/DI.kt
Normal file
35
legacy/di/src/main/kotlin/app/k9mail/legacy/di/DI.kt
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
package app.k9mail.legacy.di
|
||||
|
||||
import android.app.Application
|
||||
import org.koin.android.ext.koin.androidContext
|
||||
import org.koin.android.ext.koin.androidLogger
|
||||
import org.koin.core.context.startKoin
|
||||
import org.koin.core.module.Module
|
||||
import org.koin.java.KoinJavaComponent.get as koinGet
|
||||
|
||||
object DI {
|
||||
private const val DEBUG = false
|
||||
|
||||
@JvmStatic
|
||||
fun start(application: Application, modules: List<Module>, allowOverride: Boolean = false) {
|
||||
startKoin {
|
||||
allowOverride(allowOverride)
|
||||
|
||||
if (BuildConfig.DEBUG && DEBUG) {
|
||||
androidLogger()
|
||||
}
|
||||
|
||||
androidContext(application)
|
||||
modules(modules)
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun <T : Any> get(clazz: Class<T>): T {
|
||||
return koinGet(clazz)
|
||||
}
|
||||
|
||||
inline fun <reified T : Any> get(): T {
|
||||
return koinGet(T::class.java)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue