diff options
author | Łukasz Paczos <lukasz.paczos@mapbox.com> | 2018-08-28 17:06:21 +0200 |
---|---|---|
committer | Łukasz Paczos <lukasz.paczos@mapbox.com> | 2018-09-12 13:59:11 +0200 |
commit | 5d000d090fd1d69fb902fd5b477d3bb996e3c955 (patch) | |
tree | 95c94ac5e599ac3426fd702c93723c3025578724 /platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/utils/PluginGenerationUtil.kt | |
parent | e70fe057566104b2e845533c6e58f3a8572159f9 (diff) | |
download | qtlocation-mapboxgl-5d000d090fd1d69fb902fd5b477d3bb996e3c955.tar.gz |
[android] merge LocationLayerPlugin to Maps SDK
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/utils/PluginGenerationUtil.kt')
-rw-r--r-- | platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/utils/PluginGenerationUtil.kt | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/utils/PluginGenerationUtil.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/utils/PluginGenerationUtil.kt new file mode 100644 index 0000000000..9049a28298 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/utils/PluginGenerationUtil.kt @@ -0,0 +1,51 @@ +package com.mapbox.mapboxsdk.plugins.utils + +import android.content.Context +import android.support.v7.app.AppCompatActivity +import com.mapbox.android.core.location.LocationEngine +import com.mapbox.mapboxsdk.maps.MapView +import com.mapbox.mapboxsdk.maps.MapboxMap +import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerOptions +import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin + +class PluginGenerationUtil { + companion object { + fun getLocationLayerPluginProvider(activity: AppCompatActivity, + useDefaultEngine: Boolean = false, + engine: LocationEngine? = null, + options: LocationLayerOptions? = null, + registerLifecycleObserver: Boolean = true) + : GenericPluginAction.PluginProvider<LocationLayerPlugin> { + return object : GenericPluginAction.PluginProvider<LocationLayerPlugin> { + override fun providePlugin(mapView: MapView, mapboxMap: MapboxMap, context: Context): LocationLayerPlugin { + val plugin = if (useDefaultEngine) { + if (options != null) { + LocationLayerPlugin(mapView, mapboxMap, options) + } else { + LocationLayerPlugin(mapView, mapboxMap) + } + } else { + if (options != null) { + LocationLayerPlugin(mapView, mapboxMap, engine, options) + } else { + LocationLayerPlugin(mapView, mapboxMap, engine) + } + } + + if (registerLifecycleObserver) { + activity.lifecycle.addObserver(plugin) + } + + return plugin + } + + override fun isPluginDataReady(plugin: LocationLayerPlugin, mapboxMap: MapboxMap): Boolean { + return mapboxMap.getSource("mapbox-location-source") != null + } + } + } + + const val MAP_RENDER_DELAY = 250L + const val MAP_CONNECTION_DELAY = 1000L + } +}
\ No newline at end of file |