From 5521954975c28df65d5b272c395ef8b155b60f49 Mon Sep 17 00:00:00 2001 From: Fynn Godau Date: Fri, 19 May 2023 14:46:25 +0200 Subject: [PATCH] Post delayed callbacks to main looper instead of mapView event queue --- .../src/main/kotlin/org/microg/gms/maps/mapbox/GoogleMap.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/GoogleMap.kt b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/GoogleMap.kt index 58ccb3a08..3ffcca9e7 100644 --- a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/GoogleMap.kt +++ b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/GoogleMap.kt @@ -65,8 +65,8 @@ import org.microg.gms.maps.mapbox.utils.toMapbox private fun LongSparseArray.values() = (0 until size()).mapNotNull { valueAt(it) } -fun runOnMainLooper(method: () -> Unit) { - if (Looper.myLooper() == Looper.getMainLooper()) { +fun runOnMainLooper(forceQueue: Boolean = false, method: () -> Unit) { + if (!forceQueue && Looper.myLooper() == Looper.getMainLooper()) { method() } else { Handler(Looper.getMainLooper()).post { @@ -833,7 +833,7 @@ class GoogleMapImpl(context: Context, var options: GoogleMapOptions) : AbstractG * null), otherwise that results in other problems (e.g. Gas Now app not * initializing). */ - mapView?.post { + runOnMainLooper(forceQueue = true) { Log.d(TAG, "Invoking callback now: map cannot be initialized because it is not shown (yet)") runCallback() } -- GitLab