Vis ventestatus i botnark når GPS ikkje er tilgjengeleg
Når tilfluktsromdata er lasta men GPS-posisjon manglar, viser botnaka no «Ventar på GPS…» i staden for å vera tom. Posisjonsfiks erstattar ventestatusen automatisk når han kjem. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
12b83993c4
commit
15c6797fcd
1 changed files with 14 additions and 1 deletions
|
|
@ -298,7 +298,11 @@ class MainActivity : AppCompatActivity(), SensorEventListener {
|
||||||
Toast.makeText(this@MainActivity, R.string.error_shelter_not_found, Toast.LENGTH_SHORT).show()
|
Toast.makeText(this@MainActivity, R.string.error_shelter_not_found, Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
currentLocation?.let { updateNearestShelters(it) }
|
if (currentLocation != null) {
|
||||||
|
updateNearestShelters(currentLocation!!)
|
||||||
|
} else {
|
||||||
|
showWaitingForLocation()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e: CancellationException) {
|
} catch (e: CancellationException) {
|
||||||
throw e
|
throw e
|
||||||
|
|
@ -724,6 +728,15 @@ class MainActivity : AppCompatActivity(), SensorEventListener {
|
||||||
binding.loadingOverlay.visibility = View.GONE
|
binding.loadingOverlay.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a waiting state in the bottom sheet when shelters are loaded
|
||||||
|
* but no GPS fix is available yet.
|
||||||
|
*/
|
||||||
|
private fun showWaitingForLocation() {
|
||||||
|
binding.selectedShelterAddress.text = getString(R.string.status_no_location)
|
||||||
|
binding.selectedShelterDetails.text = getString(R.string.status_shelters_loaded, allShelters.size)
|
||||||
|
}
|
||||||
|
|
||||||
/** Persist last GPS fix so the widget can use it even when the app isn't running. */
|
/** Persist last GPS fix so the widget can use it even when the app isn't running. */
|
||||||
private fun saveLastLocation(location: Location) {
|
private fun saveLastLocation(location: Location) {
|
||||||
getSharedPreferences("widget_prefs", Context.MODE_PRIVATE).edit()
|
getSharedPreferences("widget_prefs", Context.MODE_PRIVATE).edit()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue