Skip to content

Commit

Permalink
Merge pull request #75 from Woosmap/fix/replaceGeofence
Browse files Browse the repository at this point in the history
don't block create a geofence if the old geofence to delete doesn't e…
  • Loading branch information
Llumbroso committed Mar 14, 2022
2 parents 56bddbb + 1c73b7e commit 697d8d4
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1366,11 +1366,16 @@ class PositionsManager(val context: Context, private val db: WoosmapDb) {
region.type = "isochrone"

Thread {
val regionDB = this.db.regionsDAO.getRegionFromId(oldId)
if(regionDB == null) {
val regionOld = this.db.regionsDAO.getRegionFromId(oldId)
if(regionOld == null) {
Log.d(WoosmapSdkTag, "Region to replace not exist id = " + oldId)
} else {
this.db.regionsDAO.deleteRegionFromId(oldId)
}
val regionNew = this.db.regionsDAO.getRegionFromId(newId)
if(regionNew != null) {
Log.d(WoosmapSdkTag, "Region already exist id = " + newId)
} else {
this.db.regionsDAO.createRegion(region)

if (Woosmap.getInstance().regionReadyListener != null) {
Expand Down Expand Up @@ -1443,11 +1448,16 @@ class PositionsManager(val context: Context, private val db: WoosmapDb) {
region.type = "circle"

Thread {
val regionDB = this.db.regionsDAO.getRegionFromId(oldId)
if(regionDB == null) {
val regionOld = this.db.regionsDAO.getRegionFromId(oldId)
if(regionOld == null) {
Log.d(WoosmapSdkTag, "Region to replace not exist id = " + oldId)
} else {
this.db.regionsDAO.deleteRegionFromId(oldId)
}
val regionNew = this.db.regionsDAO.getRegionFromId(newId)
if(regionNew != null) {
Log.d(WoosmapSdkTag, "Region already exist id = " + newId)
} else {
this.db.regionsDAO.createRegion(region)
mGeofencingClient.addGeofences(geofencingRequest, GeofencePendingIntent).run {
addOnSuccessListener {
Expand Down

0 comments on commit 697d8d4

Please sign in to comment.