From 95798327e7cae6d27fc588447f6640a0c61faa60 Mon Sep 17 00:00:00 2001 From: MM20 <15646950+MM2-0@users.noreply.github.com> Date: Sun, 30 Jan 2022 15:00:27 +0100 Subject: [PATCH] Fix potential NPE --- .../ui/launcher/widgets/weather/WeatherWidgetWM.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ui/src/main/java/de/mm20/launcher2/ui/launcher/widgets/weather/WeatherWidgetWM.kt b/ui/src/main/java/de/mm20/launcher2/ui/launcher/widgets/weather/WeatherWidgetWM.kt index cd0a6b98..e3314eb6 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/launcher/widgets/weather/WeatherWidgetWM.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/launcher/widgets/weather/WeatherWidgetWM.kt @@ -22,6 +22,11 @@ class WeatherWidgetWM : ViewModel(), KoinComponent { private val dataStore: LauncherDataStore by inject() + val currentForecast = MutableLiveData(getCurrentlySelectedForecast()) + val dailyForecasts = MutableLiveData>(emptyList()) + val currentDayForecasts = MutableLiveData>(emptyList()) + val currentDailyForecast = MutableLiveData(null) + private var selectedDayIndex = 0 set(value) { field = min(value, forecasts.lastIndex) @@ -66,11 +71,6 @@ class WeatherWidgetWM : ViewModel(), KoinComponent { } } - val currentForecast = MutableLiveData(getCurrentlySelectedForecast()) - val dailyForecasts = MutableLiveData>(emptyList()) - val currentDayForecasts = MutableLiveData>(emptyList()) - val currentDailyForecast = MutableLiveData(null) - val hasLocationPermission = permissionsManager.hasPermission(PermissionGroup.Location).asLiveData() fun requestLocationPermission(context: AppCompatActivity) { permissionsManager.requestPermission(context, PermissionGroup.Location)