Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove MapStyleStateDelegate, use native isStyleLoaded. #94

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions buildSrc/src/main/kotlin/Project.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ object Plugins {
const val license = "com.jaredsburrows:gradle-license-plugin:${Versions.pluginLicense}"
const val androidPublish = "digital.wup:android-maven-publish:${Versions.pluginMavenPublish}"
const val mapboxAccessToken = "com.mapbox.gradle.plugins:access-token:${Versions.mapboxAccessToken}"
const val mapboxBindgen = "com.mapbox.gradle.plugins:bindgen:${Versions.mapboxBindgen}"
const val mapboxNative = "com.mapbox.gradle.plugins:native-build:${Versions.mapboxNative}"
const val mapboxSdkRegistry = "com.mapbox.gradle.plugins:sdk-registry:${Versions.mapboxSdkRegistry}"
// for building from source
const val bintray = "com.jfrog.bintray.gradle:gradle-bintray-plugin:${Versions.pluginBintray}"
}

object Dependencies {
Expand Down Expand Up @@ -56,30 +52,16 @@ object Dependencies {
const val mockk = "io.mockk:mockk:${Versions.mockk}"
const val robolectric = "org.robolectric:robolectric:${Versions.robolectric}"
const val robolectricEgl = "org.khronos:opengl-api:${Versions.robolectricEgl}"
// for building maps from source
const val annotations = androidxAnnotations
// for building common from source
const val mapboxLogger = "com.mapbox.common:logger:${Versions.mapboxBase}"
const val mapboxLoader = "com.mapbox.common:loader:${Versions.mapboxBase}"
const val androidXTestRunner = androidxTestRunner
const val androidTestOrchestrator = androidxOrchestrator
const val mapboxBaseAndroid = mapboxBase
const val kotlinLib = kotlin
const val androidXTestCore = androidxTestCore
const val androidXStartupRuntime = "androidx.startup:startup-runtime:1.0.0"
}

object Versions {
const val pluginAndroidGradle = "4.0.1"
const val pluginKotlin = "1.4.0"
const val pluginLicense = "0.8.5"
const val pluginDokka = "1.4.10"
const val pluginBintray = "1.8.4"
const val pluginJacoco = "0.2"
const val pluginMavenPublish = "3.6.2"
const val mapboxAccessToken="0.2.1"
const val mapboxBindgen="0.2.1"
const val mapboxNative="0.2.1"
const val mapboxSdkRegistry="0.4.0"
const val mapboxGestures = "0.7.0"
const val mapboxJavaServices = "5.4.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import com.mapbox.maps.plugin.annotation.generated.Symbol
import com.mapbox.maps.plugin.delegates.MapDelegateProvider
import com.mapbox.maps.plugin.delegates.MapFeatureQueryDelegate
import com.mapbox.maps.plugin.delegates.MapProjectionDelegate
import com.mapbox.maps.plugin.delegates.MapStyleStateDelegate
import com.mapbox.maps.plugin.gestures.GesturesPlugin
import com.mapbox.maps.plugin.gestures.OnMapClickListener
import com.mapbox.maps.plugin.gestures.OnMapLongClickListener
Expand All @@ -47,7 +46,6 @@ abstract class AnnotationManagerImpl<G : Geometry, T : Annotation<G>, S : Annota
private var mapProjectionDelegate: MapProjectionDelegate = delegateProvider.mapProjectionDelegate
private var mapFeatureQueryDelegate: MapFeatureQueryDelegate =
delegateProvider.mapFeatureQueryDelegate
private var styleStateDelegate: MapStyleStateDelegate = delegateProvider.styleStateDelegate
protected val dataDrivenPropertyUsageMap: MutableMap<String, Boolean> = HashMap()
protected val constantPropertyUsageMap = mutableListOf<PropertyValue<*>>()
private var currentId = 0L
Expand Down Expand Up @@ -214,7 +212,7 @@ abstract class AnnotationManagerImpl<G : Geometry, T : Annotation<G>, S : Annota
* Trigger an update to the underlying source
*/
private fun updateSource() {
if (!styleStateDelegate.isFullyLoaded()) {
if (!style.isStyleFullyLoaded) {
Logger.e(TAG, "Can't update source: style is not fully loaded.")
return
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.mapbox.bindgen.Value
import com.mapbox.geojson.Point
import com.mapbox.maps.StyleManagerInterface
import com.mapbox.maps.extension.style.addStyleImage
import com.mapbox.maps.plugin.delegates.MapStyleStateDelegate
import com.mapbox.maps.plugin.location.LocationComponentConstants.*
import com.mapbox.maps.plugin.location.modes.RenderMode
import com.mapbox.maps.plugin.location.utils.BitmapUtils
Expand All @@ -17,16 +16,14 @@ import java.util.Locale
internal class IndicatorLocationLayerRenderer(layerSourceProvider: LayerSourceProvider) :
LocationLayerRenderer {
private var style: StyleManagerInterface? = null
private var styleStateDelegate: MapStyleStateDelegate? = null
private var layer = layerSourceProvider.getIndicatorLocationLayer()
private var lastLatLng: Point? = null
private var lastBearing = 0.0
private var lastAccuracy = 0f
private lateinit var locationComponentOptions: LocationComponentOptions

override fun initializeComponents(style: StyleManagerInterface, styleStateDelegate: MapStyleStateDelegate) {
override fun initializeComponents(style: StyleManagerInterface) {
this.style = style
this.styleStateDelegate = styleStateDelegate
lastLatLng?.let {
setLatLng(it)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ package com.mapbox.maps.plugin.location

import com.mapbox.maps.LayerPosition
import com.mapbox.maps.StyleManagerInterface
import com.mapbox.maps.plugin.delegates.MapStyleStateDelegate

internal class LocationComponentPositionManager(
private val style: StyleManagerInterface,
private val styleState: MapStyleStateDelegate,
private var layerAbove: String?,
private var layerBelow: String?
) {
Expand All @@ -26,9 +24,9 @@ internal class LocationComponentPositionManager(

fun addLayerToMap(layer: LocationLayerWrapper) {
when {
layerAbove != null -> layer.bindTo(style, styleState, LayerPosition(layerAbove, null, null))
layerBelow != null -> layer.bindTo(style, styleState, LayerPosition(null, layerBelow, null))
else -> layer.bindTo(style, styleState, null)
layerAbove != null -> layer.bindTo(style, LayerPosition(layerAbove, null, null))
layerBelow != null -> layer.bindTo(style, LayerPosition(null, layerBelow, null))
else -> layer.bindTo(style, null)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal class LocationLayerController(
private set
private var isStale = options.enableStaleState()
private var positionManager: LocationComponentPositionManager =
LocationComponentPositionManager(style, delegateProvider.styleStateDelegate, options.layerAbove(), options.layerBelow())
LocationComponentPositionManager(style, options.layerAbove(), options.layerBelow())
private var locationLayerRenderer =
if (locationModelLayerOptions != null) {
layerSourceProvider.getModelLocationLayerRenderer(locationModelLayerOptions)
Expand All @@ -41,7 +41,7 @@ internal class LocationLayerController(

fun initializeComponents(style: StyleManagerInterface, options: LocationComponentOptions) {
locationLayerRenderer.addLayers(positionManager)
locationLayerRenderer.initializeComponents(style, delegateProvider.styleStateDelegate)
locationLayerRenderer.initializeComponents(style)
applyStyle(options)
if (isHidden) {
hide()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import android.graphics.Bitmap
import com.mapbox.bindgen.Value
import com.mapbox.geojson.Point
import com.mapbox.maps.StyleManagerInterface
import com.mapbox.maps.plugin.delegates.MapStyleStateDelegate
import com.mapbox.maps.plugin.location.modes.RenderMode

internal interface LocationLayerRenderer {
fun initializeComponents(style: StyleManagerInterface, styleStateDelegate: MapStyleStateDelegate)
fun initializeComponents(style: StyleManagerInterface)

fun addLayers(positionManager: LocationComponentPositionManager)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,26 @@ package com.mapbox.maps.plugin.location
import com.mapbox.bindgen.Value
import com.mapbox.maps.LayerPosition
import com.mapbox.maps.StyleManagerInterface
import com.mapbox.maps.plugin.delegates.MapStyleStateDelegate

internal open class LocationLayerWrapper(val layerId: String) {

protected var layerProperties = HashMap<String, Value>()
private var mapStyleDelegate: StyleManagerInterface? = null
private var stateDelegate: MapStyleStateDelegate? = null

fun bindTo(
mapStyleDelegate: StyleManagerInterface,
styleStateDelegate: MapStyleStateDelegate,
position: LayerPosition? = null
) {
this.mapStyleDelegate = mapStyleDelegate
this.stateDelegate = styleStateDelegate
val expected = mapStyleDelegate.addStyleLayer(toValue(), position)
expected.error?.let {
throw RuntimeException("Add layer failed: $it")
}
}

protected fun updateProperty(propertyName: String, value: Value) {
stateDelegate?.let {
if (!it.isFullyLoaded()) {
mapStyleDelegate?.let {
if (!it.isStyleFullyLoaded) {
return
}
}
Expand Down
Loading