[android] - make style part of location component activation, add tests for non existing style and multiple style loading, revisit code comments

This commit is contained in:
Tobrun
2018-12-07 17:00:36 +02:00
committed by Tobrun
parent 648f34aadc
commit 8eaff9ce13
17 changed files with 351 additions and 204 deletions

View File

@@ -93,7 +93,6 @@ class LocationFragmentActivity : AppCompatActivity() {
private lateinit var mapView: MapView
private lateinit var mapboxMap: MapboxMap
private var component: LocationComponent? = null
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
mapView = MapView(inflater.context)
@@ -105,11 +104,11 @@ class LocationFragmentActivity : AppCompatActivity() {
mapView.onCreate(savedInstanceState)
mapView.getMapAsync {
mapboxMap = it
it.setStyle(Style.MAPBOX_STREETS) { _ ->
component = mapboxMap.locationComponent
component?.activateLocationComponent(activity)
component?.isLocationComponentEnabled = true
component?.locationEngine?.getLastLocation(this)
it.setStyle(Style.MAPBOX_STREETS) { style ->
val component = mapboxMap.locationComponent
component.activateLocationComponent(activity, style)
component.isLocationComponentEnabled = true
component.locationEngine?.getLastLocation(this)
}
}
}

View File

@@ -74,14 +74,14 @@ public class LocationMapChangeActivity extends AppCompatActivity implements OnMa
public void onMapReady(@NonNull MapboxMap mapboxMap) {
this.mapboxMap = mapboxMap;
mapboxMap.setStyle(new Style.Builder().fromUrl(Utils.getNextStyle()),
style -> activateLocationComponent());
style -> activateLocationComponent(style));
}
@SuppressLint("MissingPermission")
private void activateLocationComponent() {
private void activateLocationComponent(@NonNull Style style) {
LocationComponent locationComponent = mapboxMap.getLocationComponent();
locationComponent.onStart();
locationComponent.activateLocationComponent(this);
locationComponent.activateLocationComponent(this, style);
locationComponent.setLocationComponentEnabled(true);
locationComponent.setRenderMode(RenderMode.COMPASS);

View File

@@ -137,7 +137,7 @@ public class LocationModesActivity extends AppCompatActivity implements OnMapRea
.build();
locationComponent = mapboxMap.getLocationComponent();
locationComponent.activateLocationComponent(this, true,
locationComponent.activateLocationComponent(this, style, true,
new LocationEngineRequest.Builder(750)
.setFastestInterval(750)
.setPriority(LocationEngineRequest.PRIORITY_HIGH_ACCURACY)

View File

@@ -111,6 +111,7 @@ public class ManualLocationUpdatesActivity extends AppCompatActivity implements
locationComponent = mapboxMap.getLocationComponent();
locationComponent.activateLocationComponent(
this,
style,
locationEngine,
new LocationEngineRequest.Builder(500)
.setFastestInterval(500)