Use AndroidAppContext.get() in android implementation to make DB fully platform independent

This commit is contained in:
Olof Hedman
2025-09-29 11:58:18 +02:00
parent db00c93771
commit 9a1a2b6e14
4 changed files with 9 additions and 12 deletions

View File

@@ -87,15 +87,10 @@ import app.klottr.util.SettingsStore
import app.klottr.util.UUID
import app.klottr.util.formatCoords
import app.klottr.util.formatDistance
import coil3.ImageLoader
import coil3.request.ImageRequest
import coil3.request.SuccessResult
import coil3.toBitmap
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.IO
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.io.File
import kotlin.collections.component1
import kotlin.collections.component2
import kotlin.collections.iterator
@@ -125,7 +120,7 @@ fun KlottrAppShell(
// Initiera SQLDelight-databasen med hjälp av DatabaseFactory.
val db = remember {
val driver = app.klottr.db.DatabaseFactory(context).createDriver()
val driver = app.klottr.db.DatabaseFactory.createDriver()
app.klottr.db.KlottrDatabase(driver)
}

View File

@@ -45,9 +45,10 @@ class MainActivity : ComponentActivity() {
super.onCreate(savedInstanceState)
// Initiera SQLDelight-databasen
val driver = DatabaseFactory(this).createDriver()
val database = KlottrDatabase(driver)
val notesQueries = database.notesQueries
//OH: Dessa verkar inte användas?
// val driver = DatabaseFactory(this).createDriver()
// val database = KlottrDatabase(driver)
// val notesQueries = database.notesQueries
KLog.setEnabled(BuildConfig.KLLOG_DEBUG) // Styr loggnivå via buildflagga
app.klottr.prefs.KvPrefs.init(applicationContext)