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
|
private var selectedDayIndex = 0
|
||||||
set(value) {
|
set(value) {
|
||||||
field = min(value, forecasts.lastIndex)
|
field = min(value, forecasts.lastIndex)
|
||||||
|
if (field < 0) return
|
||||||
selectedForecastIndex = min(
|
selectedForecastIndex = min(
|
||||||
selectedForecastIndex,
|
selectedForecastIndex,
|
||||||
forecasts[value].hourlyForecasts.lastIndex
|
forecasts[value].hourlyForecasts.lastIndex
|
||||||
@ -32,6 +33,7 @@ class WeatherWidgetWM : ViewModel(), KoinComponent {
|
|||||||
|
|
||||||
private var selectedForecastIndex = 0
|
private var selectedForecastIndex = 0
|
||||||
set(value) {
|
set(value) {
|
||||||
|
if (selectedDayIndex < 0) return
|
||||||
field = min(value, forecasts[selectedDayIndex].hourlyForecasts.lastIndex)
|
field = min(value, forecasts[selectedDayIndex].hourlyForecasts.lastIndex)
|
||||||
currentForecast.postValue(getCurrentlySelectedForecast())
|
currentForecast.postValue(getCurrentlySelectedForecast())
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user