From 2e43b871c5200fbf4c0d26b0f8fce2e8a238d70b Mon Sep 17 00:00:00 2001 From: MM20 <15646950+MM2-0@users.noreply.github.com> Date: Sun, 27 Mar 2022 15:10:38 +0200 Subject: [PATCH] Fix weather widget 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..8eaaee33 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 @@ -58,6 +58,11 @@ class WeatherWidgetWM : ViewModel(), KoinComponent { dailyForecasts.postValue(value) } + val currentForecast = MutableLiveData(getCurrentlySelectedForecast()) + val dailyForecasts = MutableLiveData>(emptyList()) + val currentDayForecasts = MutableLiveData>(emptyList()) + val currentDailyForecast = MutableLiveData(null) + init { viewModelScope.launch { forecastsFlow.collectLatest { @@ -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)