From 069585f85966724827240e1cd85ae77cb0209e47 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 11 Apr 2026 17:56:12 +0000 Subject: Stop 1 Hz conditions hammering; improve error logging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The camera idle listener fires every time following-mode GPS moves the map (~1 Hz). Each fire was calling loadConditions, which meant a new API request (and spinner flash) every second. Fix: skip the camera idle loadConditions call when isFollowing == true — the GPS first-fix handler already owns that trigger. Camera idle only loads conditions when the user has manually panned away from their position. Also include exception class + message in the logcat tag so the actual API failure reason is visible without --stacktrace: adb logcat -s Nav:E https://claude.ai/code/session_01HXPjBsogsJVRwCiekDGkJX --- android-app/app/src/main/kotlin/org/terst/nav/MainActivity.kt | 6 +++++- android-app/app/src/main/kotlin/org/terst/nav/ui/MainViewModel.kt | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'android-app/app/src/main') diff --git a/android-app/app/src/main/kotlin/org/terst/nav/MainActivity.kt b/android-app/app/src/main/kotlin/org/terst/nav/MainActivity.kt index bdd8bd9..ecf2254 100644 --- a/android-app/app/src/main/kotlin/org/terst/nav/MainActivity.kt +++ b/android-app/app/src/main/kotlin/org/terst/nav/MainActivity.kt @@ -454,7 +454,11 @@ class MainActivity : AppCompatActivity(), SafetyFragment.SafetyListener { ) } maplibreMap.cameraPosition.target?.let { center -> - viewModel.loadConditions(center.latitude, center.longitude) + // Only refresh conditions when the user has manually panned — + // in following mode the GPS handler already triggers the load. + if (mapHandler?.isFollowing?.value == false) { + viewModel.loadConditions(center.latitude, center.longitude) + } } } diff --git a/android-app/app/src/main/kotlin/org/terst/nav/ui/MainViewModel.kt b/android-app/app/src/main/kotlin/org/terst/nav/ui/MainViewModel.kt index df3ab5e..b2d5529 100644 --- a/android-app/app/src/main/kotlin/org/terst/nav/ui/MainViewModel.kt +++ b/android-app/app/src/main/kotlin/org/terst/nav/ui/MainViewModel.kt @@ -177,7 +177,7 @@ class MainViewModel( try { repository.fetchCurrentConditions(lat, lon) .onSuccess { _marineConditions.value = it } - .onFailure { android.util.Log.e("Nav", "fetchCurrentConditions failed", it) } + .onFailure { android.util.Log.e("Nav", "fetchCurrentConditions failed: ${it.javaClass.simpleName} — ${it.message}", it) } } finally { _conditionsLoading.value = false } -- cgit v1.2.3