Fix crash if there's no weather data
This commit is contained in:
parent
2a01bccb62
commit
c5803b7e75
@ -21,6 +21,7 @@ class WeatherWidgetWM : ViewModel(), KoinComponent {
|
||||
private var selectedDayIndex = 0
|
||||
set(value) {
|
||||
field = min(value, forecasts.lastIndex)
|
||||
if (field < 0) return
|
||||
selectedForecastIndex = min(
|
||||
selectedForecastIndex,
|
||||
forecasts[value].hourlyForecasts.lastIndex
|
||||
@ -32,6 +33,7 @@ class WeatherWidgetWM : ViewModel(), KoinComponent {
|
||||
|
||||
private var selectedForecastIndex = 0
|
||||
set(value) {
|
||||
if (selectedDayIndex < 0) return
|
||||
field = min(value, forecasts[selectedDayIndex].hourlyForecasts.lastIndex)
|
||||
currentForecast.postValue(getCurrentlySelectedForecast())
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user