Database clear button

This commit is contained in:
Alexey 2025-08-07 17:01:46 +03:00
commit 4b07ce505f
2 changed files with 7 additions and 4 deletions

View file

@ -88,7 +88,13 @@ fun SettingsMain(vm: TileViewModel, launcher: ActivityResultLauncher<DocumentFil
Log.i(TAG, "found in db: %d, %d, %d".format(t.level, t.x, t.y))
}
}
} }) { Text(text = "Load database") }
}
}) { Text(text = "Load database") }
Button(onClick = {
coroutineScope.launch {
vm.repository.clearTiles()
}
}) { Text(text = "Clear database") }
}
}
}

View file

@ -1,9 +1,7 @@
package com.mirenkov.ktheightmap
import android.util.Log
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.async
import kotlinx.coroutines.launch
@ -14,7 +12,6 @@ class TileRepository(private val tileDao: TileDao) {
coroutineScope.launch(Dispatchers.IO) { tileDao.pushTile(tile) }
}
@OptIn(ExperimentalCoroutinesApi::class)
suspend fun getTile(x: Int, y: Int, level: Int): Tile? {
val tileDeferred = coroutineScope.async(Dispatchers.IO) {
tileDao.getTile(x, y, level)