diff --git a/data/weather/src/main/java/de/mm20/launcher2/weather/breezy/BreezyWeatherProvider.kt b/data/weather/src/main/java/de/mm20/launcher2/weather/breezy/BreezyWeatherProvider.kt index 2427c75b5..03653dfdc 100644 --- a/data/weather/src/main/java/de/mm20/launcher2/weather/breezy/BreezyWeatherProvider.kt +++ b/data/weather/src/main/java/de/mm20/launcher2/weather/breezy/BreezyWeatherProvider.kt @@ -46,28 +46,7 @@ class BreezyWeatherProvider( internal suspend fun pushWeatherData(data: BreezyWeatherData) { val result = mutableListOf() - val lastUpdate = System.currentTimeMillis() - - result += Forecast( - timestamp = data.timestamp?.times(1000L) ?: return, - temperature = data.currentTemp ?: return, - icon = iconForId(data.currentConditionCode ?: return).id, - condition = data.currentCondition ?: return, - location = data.location ?: return, - provider = "Breezy Weather", - clouds = data.cloudCover, - humidity = data.currentHumidity?.toDouble(), - pressure = data.pressure?.toDouble(), - windSpeed = data.windSpeed?.toDouble()?.div(3.6), - precipProbability = data.precipProbability, - windDirection = data.windDirection?.toDouble(), - night = isNight( - data.timestamp.times(1000L), - data.sunRise?.times(1000L), - data.sunSet?.times(1000L) - ), - updateTime = lastUpdate, - ) + val lastUpdate = data.timestamp?.times(1000L) ?: return val sunrises = buildList { if (data.sunRise != null) add(data.sunRise.times(1000L)) @@ -101,7 +80,7 @@ class BreezyWeatherProvider( temperature = hourly.temp?.toDouble() ?: continue, icon = iconForId(hourly.conditionCode ?: continue).id, condition = textForId(hourly.conditionCode) ?: continue, - location = data.location, + location = data.location ?: return, provider = "Breezy Weather", humidity = hourly.humidity?.toDouble(), windSpeed = hourly.windSpeed?.toDouble()?.div(3.6), @@ -164,10 +143,6 @@ class BreezyWeatherProvider( return context.getString(resId) } - private fun isNight(timestamp: Long, sunrise: Long?, sunset: Long?): Boolean { - return (sunrise != null && timestamp < sunrise) || (sunset != null && timestamp > sunset) - } - companion object { internal fun isAvailable(context: Context): Boolean { return try {