From aeba2b21b2e495a100757f62a07f6eda512a4ab0 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 5 Jun 2026 07:51:24 +0000 Subject: Fix wind grid deserialization: make forecast-only fields nullable The batch wind-grid endpoint only requests windspeed_10m and winddirection_10m, so temperature_2m, precipitation_probability, and weathercode are absent from its response. Moshi required these fields and threw, causing fetchWindGrid to silently fail. Made those three fields nullable with null defaults in WeatherHourly. Updated the two call sites in WeatherRepository that access them via the full forecast endpoint to use safe-call syntax. https://claude.ai/code/session_017TwkSjhzhmTcHKmVG5MWUa --- .../src/main/kotlin/org/terst/nav/data/model/WeatherResponse.kt | 6 +++--- .../kotlin/org/terst/nav/data/repository/WeatherRepository.kt | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'android-app/app/src/main/kotlin') diff --git a/android-app/app/src/main/kotlin/org/terst/nav/data/model/WeatherResponse.kt b/android-app/app/src/main/kotlin/org/terst/nav/data/model/WeatherResponse.kt index 784f17a..46091ae 100644 --- a/android-app/app/src/main/kotlin/org/terst/nav/data/model/WeatherResponse.kt +++ b/android-app/app/src/main/kotlin/org/terst/nav/data/model/WeatherResponse.kt @@ -15,7 +15,7 @@ data class WeatherHourly( @Json(name = "time") val time: List, @Json(name = "windspeed_10m") val windspeed10m: List, @Json(name = "winddirection_10m") val winddirection10m: List, - @Json(name = "temperature_2m") val temperature2m: List, - @Json(name = "precipitation_probability") val precipitationProbability: List, - @Json(name = "weathercode") val weathercode: List + @Json(name = "temperature_2m") val temperature2m: List? = null, + @Json(name = "precipitation_probability") val precipitationProbability: List? = null, + @Json(name = "weathercode") val weathercode: List? = null ) diff --git a/android-app/app/src/main/kotlin/org/terst/nav/data/repository/WeatherRepository.kt b/android-app/app/src/main/kotlin/org/terst/nav/data/repository/WeatherRepository.kt index a716051..62549ad 100644 --- a/android-app/app/src/main/kotlin/org/terst/nav/data/repository/WeatherRepository.kt +++ b/android-app/app/src/main/kotlin/org/terst/nav/data/repository/WeatherRepository.kt @@ -27,9 +27,9 @@ class WeatherRepository( timeIso = h.time[i], windKt = h.windspeed10m[i], windDirDeg = h.winddirection10m[i], - tempC = h.temperature2m[i], - precipProbabilityPct = h.precipitationProbability[i], - weatherCode = h.weathercode[i] + tempC = h.temperature2m?.get(i) ?: 0.0, + precipProbabilityPct = h.precipitationProbability?.get(i) ?: 0, + weatherCode = h.weathercode?.get(i) ?: 0 ) } }.also { result -> @@ -75,7 +75,7 @@ class WeatherRepository( MarineConditions( windSpeedKt = w.windspeed10m.firstOrNull(), windDirDeg = w.winddirection10m.firstOrNull(), - tempC = w.temperature2m.firstOrNull(), + tempC = w.temperature2m?.firstOrNull(), waveHeightM = m.waveHeight.firstOrNull(), waveDirDeg = m.waveDirection.firstOrNull(), swellHeightM = m.swellWaveHeight.firstOrNull(), -- cgit v1.2.3