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

Commit 485a35f7 authored by Fynn Godau's avatar Fynn Godau
Browse files

Merge branch '910-queue' into 'master'

Post delayed callbacks to main looper instead of mapView event queue

See merge request !76
parents 9391d765 55219549
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()
                }