diff options
author | tobrun <tobrun.van.nuland@gmail.com> | 2019-05-09 22:47:08 +0200 |
---|---|---|
committer | Tobrun <tobrun.van.nuland@gmail.com> | 2019-05-10 12:11:49 +0200 |
commit | fd527b1d232c6f9f0d898349ce702355d31d0fea (patch) | |
tree | 094ca6a48bb13f25beaa9ff8c7d1594b609ec93f | |
parent | b41f39d545908dfb9a348aa786620d745d929225 (diff) | |
download | qtlocation-mapboxgl-fd527b1d232c6f9f0d898349ce702355d31d0fea.tar.gz |
[android] - remove/readd listener to avoid recursion
-rw-r--r-- | platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.kt | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.kt index a432996723..d01c8eb508 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.kt +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.kt @@ -18,11 +18,15 @@ class SnapshotActivity : AppCompatActivity(), OnMapReadyCallback { private lateinit var mapboxMap: MapboxMap - private val idleListener = MapView.OnDidFinishRenderingFrameListener { fully -> - if (fully) { - Logger.v(TAG, LOG_MESSAGE) - mapboxMap.snapshot { snapshot -> - imageView.setImageBitmap(snapshot) + private val idleListener = object : MapView.OnDidFinishRenderingFrameListener { + override fun onDidFinishRenderingFrame(fully: Boolean) { + if (fully) { + mapView.removeOnDidFinishRenderingFrameListener(this) + Logger.v(TAG, LOG_MESSAGE) + mapboxMap.snapshot { snapshot -> + imageView.setImageBitmap(snapshot) + mapView.addOnDidFinishRenderingFrameListener(this) + } } } } |