Use dependency injection for most singletons
This commit is contained in:
@@ -42,6 +42,8 @@ dependencies {
|
||||
|
||||
implementation(libs.bundles.androidx.lifecycle)
|
||||
|
||||
implementation(libs.koin.android)
|
||||
|
||||
implementation(project(":ktx"))
|
||||
implementation(project(":preferences"))
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import de.mm20.launcher2.ktx.isAtLeastApiLevel
|
||||
import de.mm20.launcher2.preferences.LauncherPreferences
|
||||
import kotlinx.coroutines.*
|
||||
|
||||
class BadgeProvider private constructor(val context: Context) {
|
||||
class BadgeProvider(val context: Context) {
|
||||
|
||||
private val scope = CoroutineScope(Job() + Dispatchers.Main)
|
||||
|
||||
@@ -138,13 +138,4 @@ class BadgeProvider private constructor(val context: Context) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private lateinit var instance: BadgeProvider
|
||||
|
||||
fun getInstance(context: Context): BadgeProvider {
|
||||
if (!::instance.isInitialized) instance = BadgeProvider(context.applicationContext)
|
||||
return instance
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package de.mm20.launcher2.badges
|
||||
|
||||
import org.koin.android.ext.koin.androidContext
|
||||
import org.koin.dsl.module
|
||||
|
||||
val badgesModule = module {
|
||||
single { BadgeProvider(androidContext()) }
|
||||
}
|
||||
Reference in New Issue
Block a user