From 057dd8d10bcec9018a83003a0b123ac7d6855e58 Mon Sep 17 00:00:00 2001 From: Tymofiy Bortnyk Date: Sun, 31 May 2026 23:00:10 +0300 Subject: [PATCH] Drop redundant runOnUiThread in getCurrentPosition handler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit LocationProvider.getCurrentPosition already invokes its callback on the main thread — requestLocationUpdates is registered with the main Looper, the timeout uses a main-Looper Handler, and the early-return paths run synchronously on the calling (main) thread. Wrapping result.success in runOnUiThread was therefore unnecessary indirection. Per CodeRabbit review on #18. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../src/main/kotlin/org/bortnik/meteogram/MainActivity.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/android/app/src/main/kotlin/org/bortnik/meteogram/MainActivity.kt b/android/app/src/main/kotlin/org/bortnik/meteogram/MainActivity.kt index b0ca6ab..42b3017 100644 --- a/android/app/src/main/kotlin/org/bortnik/meteogram/MainActivity.kt +++ b/android/app/src/main/kotlin/org/bortnik/meteogram/MainActivity.kt @@ -236,10 +236,9 @@ class MainActivity : FlutterActivity() { } "getCurrentPosition" -> { val timeoutMs = (call.argument("timeoutMs") ?: 15000).toLong() + // LocationProvider always invokes its callback on the main thread. LocationProvider.getCurrentPosition(this, timeoutMs) { coords -> - runOnUiThread { - result.success(coords?.let { mapOf("latitude" to it[0], "longitude" to it[1]) }) - } + result.success(coords?.let { mapOf("latitude" to it[0], "longitude" to it[1]) }) } } "getLastKnownPosition" -> {