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

Integrate value marshalling performance improvement #606

Merged
merged 2 commits into from
Sep 3, 2021
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.mapbox.maps.R
import com.mapbox.maps.extension.style.expressions.dsl.generated.literal
import com.mapbox.maps.plugin.LocationPuck2D
import com.mapbox.maps.plugin.LocationPuck3D
import com.mapbox.maps.toJson

/**
* Provides car location puck definitions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import com.mapbox.maps.plugin.locationcomponent.location
import com.mapbox.maps.testapp.R
import com.mapbox.maps.testapp.databinding.ActivityLocationComponentBinding
import com.mapbox.maps.testapp.utils.LocationPermissionHelper
import com.mapbox.maps.toJson

class LocationComponentActivity : AppCompatActivity() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import com.mapbox.maps.plugin.locationcomponent.OnIndicatorPositionChangedListen
import com.mapbox.maps.plugin.locationcomponent.location
import com.mapbox.maps.testapp.R
import com.mapbox.maps.testapp.utils.LocationPermissionHelper
import com.mapbox.maps.toJson

/**
* Tracks the user location on screen, simulates a navigation session.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package com.mapbox.maps.testapp.examples

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.mapbox.common.ValueConverter
import com.mapbox.bindgen.Value
import com.mapbox.maps.MapView
import com.mapbox.maps.MapboxMap
import com.mapbox.maps.Style
import java.lang.RuntimeException

/**
* Example showcasing raw expression support through the ValueConverter API.
* Example showcasing raw expression support through the Value API.
* This example manipulates the water fill layer of mapbox-streets to:
* ```
* {
Expand Down Expand Up @@ -46,7 +46,7 @@ class RawExpressionActivity : AppCompatActivity() {
}

private fun addExpressionToStyle(style: Style) {
val expression = ValueConverter.fromJson(
val expression = Value.fromJson(
"""
[
"interpolate",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ import android.graphics.Color
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.mapbox.bindgen.Value
import com.mapbox.common.ValueConverter
import com.mapbox.maps.MapView
import com.mapbox.maps.MapboxMap
import com.mapbox.maps.Style
import com.mapbox.maps.extension.style.layers.addLayer
import com.mapbox.maps.extension.style.layers.generated.circleLayer

/**
* Example showcasing raw geojson conversion support through the ValueConverter API.
* Example showcasing raw geojson conversion support through the Value API.
* This converts the following geojson to a value object:
* ```
* {
Expand Down Expand Up @@ -48,7 +47,7 @@ class RawGeoJsonActivity : AppCompatActivity() {
}

private fun addGeoJsonSource(style: Style) {
val geojson = ValueConverter.fromJson(
val geojson = Value.fromJson(
"""
{
"type": "FeatureCollection",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package com.mapbox.maps.testapp.examples

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.mapbox.common.ValueConverter
import com.mapbox.bindgen.Value
import com.mapbox.maps.MapView
import com.mapbox.maps.Style

/**
* Example showcasing raw source/layer json conversion support through the ValueConverter API.
* Example showcasing raw source/layer json conversion support through the Value API.
*
* Source:
* ```
Expand Down Expand Up @@ -51,7 +51,7 @@ class RawSourceLayerActivity : AppCompatActivity() {
}

private fun addGeoJsonSource(style: Style) {
val source = ValueConverter.fromJson(
val source = Value.fromJson(
"""
{
"type": "geojson",
Expand Down Expand Up @@ -79,7 +79,7 @@ class RawSourceLayerActivity : AppCompatActivity() {
throw RuntimeException("Invalid GeoJson:" + expected.error)
}

val layer = ValueConverter.fromJson(
val layer = Value.fromJson(
"""
{
"id": "custom",
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/example_descriptions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<string name="description_default_styles">Switch between custom and default Mapbox styles for the same map view.</string>
<string name="description_map_recycle">MapView integration inside a RecyclerView</string>
<string name="description_gestures">Manipulate gesture interaction with the map</string>
<string name="description_raw_geojson">Use a GeoJSON string as data for a GeoJSON source through ValueConverter API</string>
<string name="description_raw_geojson">Use a GeoJSON string as data for a GeoJSON source through Value API</string>
<string name="description_geojson_layer_in_stack">Insert a specific layer above or below other layers.</string>
<string name="description_raw_expression">Use a JSON string as an expression</string>
<string name="description_raw_source_layer">Use a JSON string as an Source/Layer</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import com.mapbox.maps.extension.style.layers.generated.SymbolLayer
import com.mapbox.maps.extension.style.layers.getLayerAs
import com.mapbox.maps.extension.style.sources.generated.VectorSource
import com.mapbox.maps.extension.style.sources.getSourceAs
import com.mapbox.maps.toJson
import java.util.*

/**
Expand Down

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

This file was deleted.

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 @@ -5,11 +5,9 @@ import com.google.gson.JsonObject
import com.google.gson.JsonPrimitive
import com.mapbox.bindgen.Expected
import com.mapbox.bindgen.Value
import com.mapbox.common.ValueConverter
import com.mapbox.geojson.Feature
import com.mapbox.maps.StylePropertyValue
import com.mapbox.maps.StylePropertyValueKind
import com.mapbox.maps.extension.style.ShadowValueConverter
import com.mapbox.maps.extension.style.expressions.dsl.generated.*
import com.mapbox.maps.extension.style.expressions.generated.Expression
import com.mapbox.maps.extension.style.layers.properties.generated.Visibility
Expand All @@ -18,24 +16,19 @@ import com.mapbox.maps.extension.style.types.formatted
import com.mapbox.maps.extension.style.types.transitionOptions
import io.mockk.every
import io.mockk.mockk
import io.mockk.mockkStatic
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config

@RunWith(RobolectricTestRunner::class)
@Config(shadows = [ShadowValueConverter::class])
class TypeUtilsTest {
private val expected = mockk<Expected<String, Value>>(relaxed = true)

@Before
fun prepare() {
mockkStatic(ValueConverter::class)
every { ValueConverter.fromJson(any()) } returns expected
every { expected.error } returns null
every { expected.value } returns Value(0)
}
Expand Down Expand Up @@ -178,7 +171,7 @@ class TypeUtilsTest {

@Test
fun wrapToValue_Json() {
// TODO add support of Json after introducing ValueConverter.
// TODO add support of Json after introducing Value.
Chaoba marked this conversation as resolved.
Show resolved Hide resolved
val innerObject = JsonObject()
innerObject.addProperty("name", "john")
val jsonObject = JsonObject()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config

@RunWith(RobolectricTestRunner::class)
@Config(shadows = [ShadowValueConverter::class, ShadowLogger::class])
@Config(shadows = [ShadowLogger::class])
class AnnotationPluginImplTest {
private val delegateProvider: MapDelegateProvider = mockk(relaxed = true)
private val style: StyleInterface = mockk(relaxed = true)
Expand Down

This file was deleted.

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.

Loading