diff --git a/app/src/main/kotlin/bums/lunatic/launcher/workers/LocationUpdateService.kt b/app/src/main/kotlin/bums/lunatic/launcher/workers/LocationUpdateService.kt index 56d032d..2422a2c 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/workers/LocationUpdateService.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/workers/LocationUpdateService.kt @@ -53,11 +53,16 @@ class LocationUpdateService : Service(), LocationListener { WorkersDb.getRealm()?.apply { LocationLog().let { loc -> loc.fillData(it) - var list = query().sort("time", Sort.DESCENDING).find() + + var list = query().query("userId == $0", PrefString.telegramMyId.get("")).sort("time", Sort.DESCENDING).find() + val post = (list.size == 0 || (list.size > 0 && list.first().time < (System.currentTimeMillis() - (1000L * 60L * 5L))) && inRangeLocation(lat,long,50) == false) writeBlocking { - copyToRealm(loc) + if (post) { + loc.userId = PrefString.telegramMyId.get("") + copyToRealm(loc) + } } - (list.size == 0 || (list.size > 0 && list.first().time < (System.currentTimeMillis() - (1000L * 60L * 5L))) && inRangeLocation(lat,long,50) == false).letTrue { + post.letTrue { Executors.newSingleThreadScheduledExecutor().schedule({ try { //////-1002450229641