|
@@ -17,6 +17,8 @@ import androidx.core.content.ContextCompat
|
|
import com.flacksta.chef.journeygpstracker.database.GpsData
|
|
import com.flacksta.chef.journeygpstracker.database.GpsData
|
|
import com.flacksta.chef.journeygpstracker.database.GpsPosRepository
|
|
import com.flacksta.chef.journeygpstracker.database.GpsPosRepository
|
|
import com.google.android.gms.location.*
|
|
import com.google.android.gms.location.*
|
|
|
|
+import kotlinx.coroutines.GlobalScope
|
|
|
|
+import kotlinx.coroutines.delay
|
|
import kotlinx.coroutines.launch
|
|
import kotlinx.coroutines.launch
|
|
import kotlinx.coroutines.runBlocking
|
|
import kotlinx.coroutines.runBlocking
|
|
|
|
|
|
@@ -40,12 +42,10 @@ class TrackingService : Service() {
|
|
Log.i(mTag,"Requested foreground service...")
|
|
Log.i(mTag,"Requested foreground service...")
|
|
}
|
|
}
|
|
|
|
|
|
- private fun insertPos(pos: Location) = runBlocking {
|
|
|
|
- launch {
|
|
|
|
- var d = GpsData(0, System.currentTimeMillis(), pos.latitude, pos.longitude, pos.accuracy)
|
|
|
|
- val repo: GpsPosRepository = trackApp.repository
|
|
|
|
- repo.insert(d)
|
|
|
|
- }
|
|
|
|
|
|
+ private fun insertPos(pos: Location) = GlobalScope.launch {
|
|
|
|
+ var d = GpsData(0, System.currentTimeMillis(), pos.latitude, pos.longitude, pos.accuracy)
|
|
|
|
+ val repo: GpsPosRepository = trackApp.repository
|
|
|
|
+ repo.insert(d)
|
|
}
|
|
}
|
|
|
|
|
|
private fun requestLocationUpdates() {
|
|
private fun requestLocationUpdates() {
|