Android Auto: increase search radius to 25 km if not enough chargers found within 5 km radius

This commit is contained in:
johan12345
2021-04-09 23:01:01 +02:00
parent 6e888499c4
commit bfa1c45ae6

View File

@@ -429,6 +429,19 @@ class MapScreen(ctx: CarContext, val session: EVMapSession, val favorites: Boole
)
chargers =
response.body()?.chargelocations?.filterIsInstance(ChargeLocation::class.java)
chargers?.let {
if (it.size < 6) {
// try again with larger radius
val response = api.getChargepointsRadius(
location.latitude,
location.longitude,
searchRadius * 5,
zoom = 16f
)
chargers =
response.body()?.chargelocations?.filterIsInstance(ChargeLocation::class.java)
}
}
}
// remove outdated availabilities