Android Auto: Avoid possible extra template refresh due to race condition

This commit is contained in:
johan12345
2022-08-22 23:03:08 +02:00
parent 2f93e92b57
commit d5f55366a9

View File

@@ -373,10 +373,8 @@ class MapScreen(ctx: CarContext, val session: EVMapSession) :
// Reloading chargers in onStart does not seem to count towards content limit.
// So let's do this so the user gets fresh chargers when re-entering the app.
chargers = null
availabilities.clear()
invalidate()
filtersWithValue.observe(this) {
filtersWithValue.observe(this@MapScreen) {
loadChargers()
}
}
@@ -398,6 +396,12 @@ class MapScreen(ctx: CarContext, val session: EVMapSession) :
}
override fun onStop(owner: LifecycleOwner) {
// Reloading chargers in onStart does not seem to count towards content limit.
// So let's do this so the user gets fresh chargers when re-entering the app.
// Deleting the data already in onStop makes sure that we show a loading screen directly
// (i.e. onGetTemplate is not called while the old data is still there)
chargers = null
availabilities.clear()
removeListeners()
}