summaryrefslogtreecommitdiff
path: root/android-app/app/src/main/kotlin/org
diff options
context:
space:
mode:
authorClaude <noreply@anthropic.com>2026-06-05 07:51:24 +0000
committerClaude <noreply@anthropic.com>2026-06-05 07:51:24 +0000
commitaeba2b21b2e495a100757f62a07f6eda512a4ab0 (patch)
tree6b1611b9e52c446a353da75ff21e735db551c893 /android-app/app/src/main/kotlin/org
parent3f7a1a181be300a04a8cfb00022aedc5d97676da (diff)
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
Diffstat (limited to 'android-app/app/src/main/kotlin/org')
-rw-r--r--android-app/app/src/main/kotlin/org/terst/nav/data/model/WeatherResponse.kt6
-rw-r--r--android-app/app/src/main/kotlin/org/terst/nav/data/repository/WeatherRepository.kt8
2 files changed, 7 insertions, 7 deletions
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<String>,
@Json(name = "windspeed_10m") val windspeed10m: List<Double>,
@Json(name = "winddirection_10m") val winddirection10m: List<Double>,
- @Json(name = "temperature_2m") val temperature2m: List<Double>,
- @Json(name = "precipitation_probability") val precipitationProbability: List<Int>,
- @Json(name = "weathercode") val weathercode: List<Int>
+ @Json(name = "temperature_2m") val temperature2m: List<Double>? = null,
+ @Json(name = "precipitation_probability") val precipitationProbability: List<Int>? = null,
+ @Json(name = "weathercode") val weathercode: List<Int>? = 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(),