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

Commit 5f03df30 authored by Fynn Godau's avatar Fynn Godau
Browse files

Track started status

parent 2f9a8482
Loading
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -120,6 +120,8 @@ class GoogleMapImpl(context: Context, var options: GoogleMapOptions) : AbstractG
    val waitingCameraUpdates = mutableListOf<CameraUpdate>()
    var locationEnabled: Boolean = false

    var isStarted = false

    init {
        BitmapDescriptorFactoryImpl.initialize(mapContext.resources, context.resources)
        LibraryLoader.setLibraryLoader(MultiArchLoader(mapContext, context))
@@ -459,8 +461,15 @@ class GoogleMapImpl(context: Context, var options: GoogleMapOptions) : AbstractG
            Log.e(TAG, "snapshot could not be taken because map is null")
            runOnMainLooper { callback.onBitmapWrappedReady(ObjectWrapper.wrap(null)) }
        } else {
            Log.d(TAG, "taking snapshot")
            onStart() // else snapshot fails silently if client app, like Signal, forgot to call onStart()
            if (!isStarted) {
                Log.w(TAG, "Caller did not call onStart() before taking snapshot. Calling onStart() now, for snapshot not to fail.")
                // Snapshots fail silently if onStart had not been called. This is the case with Signal.
                onStart()
                isStarted = true
            }

            Log.d(TAG, "taking snapshot now")

            map.snapshot {
                runOnMainLooper {
                    Log.d(TAG, "snapshot ready, providing to application")
@@ -788,10 +797,12 @@ class GoogleMapImpl(context: Context, var options: GoogleMapOptions) : AbstractG
    }

    override fun onStart() {
        isStarted = true
        mapView?.onStart()
    }

    override fun onStop() {
        isStarted = false
        mapView?.onStop()
    }