Only check for beacons if the index is present (#2916)

* Only check for beacons if the index is present

* Remove assert

* Review comment
This commit is contained in:
Daniel Shokouhi 2022-09-26 07:52:08 -07:00 committed by GitHub
parent 1449ff5409
commit e541db2ca8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -58,14 +58,14 @@ class IBeaconMonitor {
sendUpdate(context, sorted)
return
}
assert(sorted.count() == beacons.count())
beacons.forEachIndexed foreach@{ i, existingBeacon ->
if (name(sorted[i].uuid, sorted[i].major, sorted[i].minor) != name(existingBeacon.uuid, existingBeacon.major, existingBeacon.minor) || // the distance order switched
kotlin.math.abs(sorted[i].distance - existingBeacon.distance) > 0.5 // the distance difference is greater than 0.5m
) {
requireUpdate = true
return@foreach
if (i < sorted.size) {
if (name(sorted[i].uuid, sorted[i].major, sorted[i].minor) != name(existingBeacon.uuid, existingBeacon.major, existingBeacon.minor) || // the distance order switched
kotlin.math.abs(sorted[i].distance - existingBeacon.distance) > 0.5 // the distance difference is greater than 0.5m
) {
requireUpdate = true
return@foreach
}
}
}
if (requireUpdate) {