Skip to content

Commit fe7a268

Browse files
jushkiryldz
andauthored
Activity fixes (Tilestore crash, experimental line-trim properties) (#2800)
* Fix offline activity crash * PR fixes + line trim updates * Add missing changelog --------- Co-authored-by: kiryldz <[email protected]>
1 parent 0b95421 commit fe7a268

File tree

6 files changed

+15
-12
lines changed

6 files changed

+15
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Mapbox welcomes participation and contributions from everyone.
1212
## Features ✨ and improvements 🏁
1313
* Introduce `Style.STANDARD_EXPERIMENTAL` style supporting featuresets and map interactions. **Important: this style should not be used in production as the style definition on backend is a subject to change after v11.8.0 stable release!**
1414
* Introduce fully typed map click and long click interactions working with `Style.STANDARD_EXPERIMENTAL`: `standardPoi`, `standardPlaceLabels`, `standardBuildings`.
15+
* Use [Cronet](https://developer.android.com/develop/connectivity/cronet) as the default network stack. If Cronet is not available, network stack defaults to [OkHttp](https://square.github.io/okhttp/) used in previous versions.
1516
* Introduce `OnClusterClickListener` and `OnClusterLongClickListener` for `CircleAnnotationManager` and `PointAnnotationManager`. These callbacks receive the clicked cluster represented by a `ClusterFeature`.
1617
* Introduce experimental `getStyleGlyphURL` / `setStyleGlyphURL` functions for `MapboxMap` and `Style`.
1718
* Make `fill-extrusion-emissive-strength` property data-driven.

app/src/main/java/com/mapbox/maps/testapp/examples/MapViewCustomizationActivity.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class MapViewCustomizationActivity : AppCompatActivity() {
2727
override fun onCreate(savedInstanceState: Bundle?) {
2828
super.onCreate(savedInstanceState)
2929

30+
val initialTileStore = MapboxOptions.mapsOptions.tileStore
31+
val initialTileStoreUsageMode = MapboxOptions.mapsOptions.tileStoreUsageMode
3032
// Set tile store and tile store usage mode so that all MapViews created from now on will apply
3133
// these settings.
3234
MapboxOptions.mapsOptions.tileStore = tileStore
@@ -40,6 +42,10 @@ class MapViewCustomizationActivity : AppCompatActivity() {
4042
// But you can also add your style to the map layout with xml attribute `app:mapbox_styleUri="mapbox://styles/mapbox/dark-v11"`
4143
binding.mapView.mapboxMap.loadStyle(Style.DARK)
4244
configureMapViewFromCode()
45+
46+
// Reset to original state
47+
MapboxOptions.mapsOptions.tileStore = initialTileStore
48+
MapboxOptions.mapsOptions.tileStoreUsageMode = initialTileStoreUsageMode
4349
}
4450

4551
private fun configureMapViewFromCode() {

app/src/main/java/com/mapbox/maps/testapp/examples/OfflineActivity.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ import kotlinx.coroutines.launch
5151
*/
5252
class OfflineActivity : AppCompatActivity() {
5353
// We use the default tile store
54-
private val tileStore: TileStore by lazy {
55-
MapboxOptions.mapsOptions.tileStore!!
56-
}
54+
private val tileStore: TileStore = MapboxOptions.mapsOptions.tileStore!!
5755
private val offlineManager: OfflineManager = OfflineManager()
5856
private val offlineLogsAdapter: OfflineLogsAdapter = OfflineLogsAdapter()
5957
private lateinit var binding: ActivityOfflineBinding

app/src/main/java/com/mapbox/maps/testapp/examples/linesandpolygons/LineGradientActivity.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import androidx.appcompat.app.AppCompatActivity
55
import com.mapbox.geojson.Feature
66
import com.mapbox.geojson.LineString
77
import com.mapbox.geojson.Point
8+
import com.mapbox.maps.MapboxExperimental
89
import com.mapbox.maps.Style
910
import com.mapbox.maps.extension.style.expressions.dsl.generated.interpolate
1011
import com.mapbox.maps.extension.style.layers.generated.LineLayer
@@ -19,6 +20,7 @@ import com.mapbox.maps.testapp.databinding.ActivityLineGradientBinding
1920

2021
class LineGradientActivity : AppCompatActivity() {
2122

23+
@OptIn(MapboxExperimental::class)
2224
override fun onCreate(savedInstanceState: Bundle?) {
2325
super.onCreate(savedInstanceState)
2426
val binding = ActivityLineGradientBinding.inflate(layoutInflater)
@@ -29,7 +31,11 @@ class LineGradientActivity : AppCompatActivity() {
2931
binding.trimOffsetButton.setOnClickListener {
3032
val lineLayer = style.getLayerAs<LineLayer>(LAYER_ID)
3133
val lastTrimPosition = lineLayer?.lineTrimOffset?.last() ?: 0.0
32-
lineLayer?.lineTrimOffset(listOf(0.0, (lastTrimPosition + 0.05).coerceAtMost(1.0)))
34+
lineLayer?.let { layer ->
35+
layer.lineTrimOffset(listOf(0.0, (lastTrimPosition + 0.05).coerceAtMost(1.0)))
36+
layer.lineTrimColor("rgba(6, 1, 255, 0.2)")
37+
layer.lineTrimFadeRange(listOf(0.0, 0.0001))
38+
}
3339
}
3440
}
3541
}

app/src/main/java/com/mapbox/maps/testapp/utils/NavigationSimulator.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import com.mapbox.geojson.Point
77
import com.mapbox.maps.EdgeInsets
88
import com.mapbox.maps.ImageHolder
99
import com.mapbox.maps.MapView
10-
import com.mapbox.maps.MapboxExperimental
1110
import com.mapbox.maps.extension.style.expressions.dsl.generated.interpolate
1211
import com.mapbox.maps.extension.style.layers.addLayer
1312
import com.mapbox.maps.extension.style.layers.generated.LineLayer
@@ -74,7 +73,6 @@ class NavigationSimulator(
7473
initMapboxMap()
7574
}
7675

77-
@OptIn(MapboxExperimental::class)
7876
private fun initMapboxMap() {
7977
routeLayer = lineLayer(ROUTE_LINE_LAYER_ID, GEOJSON_SOURCE_ID) {
8078
lineWidth(
@@ -141,8 +139,6 @@ class NavigationSimulator(
141139
}
142140
}
143141
)
144-
lineTrimColor("rgba(6, 1, 255, 0.2)")
145-
lineTrimFadeRange(listOf(0.0, 0.0001))
146142
}
147143
casingLayer = lineLayer(ROUTE_CASING_LAYER_ID, GEOJSON_SOURCE_ID) {
148144
lineWidth(

compose-app/src/main/java/com/mapbox/maps/compose/testapp/examples/location/NavigationSimulationActivity.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import androidx.compose.runtime.remember
1818
import androidx.compose.runtime.setValue
1919
import androidx.compose.ui.Alignment
2020
import androidx.compose.ui.Modifier
21-
import androidx.compose.ui.graphics.Color
2221
import androidx.compose.ui.res.painterResource
2322
import androidx.compose.ui.unit.dp
2423
import com.mapbox.api.directions.v5.models.DirectionsResponse
@@ -38,7 +37,6 @@ import com.mapbox.maps.extension.compose.animation.viewport.rememberMapViewportS
3837
import com.mapbox.maps.extension.compose.style.BooleanValue
3938
import com.mapbox.maps.extension.compose.style.ColorValue
4039
import com.mapbox.maps.extension.compose.style.DoubleListValue
41-
import com.mapbox.maps.extension.compose.style.DoubleRangeValue
4240
import com.mapbox.maps.extension.compose.style.DoubleValue
4341
import com.mapbox.maps.extension.compose.style.MapboxStyleComposable
4442
import com.mapbox.maps.extension.compose.style.layers.generated.LineCapValue
@@ -260,8 +258,6 @@ public class NavigationSimulationActivity : ComponentActivity() {
260258
}
261259
}
262260
)
263-
lineTrimColor = ColorValue(Color(6, 1, 255, 51))
264-
lineTrimFadeRange = DoubleRangeValue(0.0, 0.0001)
265261
}
266262
LineLayer(
267263
sourceState = geoJsonSource

0 commit comments

Comments
 (0)