Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ee66fd11 authored by Fynn Godau's avatar Fynn Godau Committed by Jonathan Klee
Browse files

Post delayed callbacks to main looper instead of mapView event queue

parent 9391d765
Loading
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -65,8 +65,8 @@ import org.microg.gms.maps.mapbox.utils.toMapbox

private fun <T : Any> LongSparseArray<T>.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()
                }