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:
Ole-Morten Duesund 2026-03-10 19:17:07 +01:00
commit 15c6797fcd

View file

@ -298,7 +298,11 @@ class MainActivity : AppCompatActivity(), SensorEventListener {
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) {
throw e
@ -724,6 +728,15 @@ class MainActivity : AppCompatActivity(), SensorEventListener {
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. */
private fun saveLastLocation(location: Location) {
getSharedPreferences("widget_prefs", Context.MODE_PRIVATE).edit()