diff options
author | Ivo van Dongen <info@ivovandongen.nl> | 2016-11-10 13:19:18 +0100 |
---|---|---|
committer | Ivo van Dongen <ivovandongen@users.noreply.github.com> | 2016-11-11 13:46:10 +0100 |
commit | 1beb28e75bc70dba9c4a79d87da79cbb51ed19db (patch) | |
tree | 411d3cb8816fce1f4e7fd617cb4e8d913e286453 /platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/customlayer | |
parent | 185983f2f7be3d1624e057c04ef5310e84b6d27a (diff) | |
download | qtlocation-mapboxgl-1beb28e75bc70dba9c4a79d87da79cbb51ed19db.tar.gz |
[android] updated test activities for refactored layer/source ownership
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/customlayer')
-rw-r--r-- | platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/customlayer/CustomLayerActivity.java | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/customlayer/CustomLayerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/customlayer/CustomLayerActivity.java index ea8e39275f..be71133610 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/customlayer/CustomLayerActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/customlayer/CustomLayerActivity.java @@ -26,8 +26,8 @@ public class CustomLayerActivity extends AppCompatActivity { private MapboxMap mapboxMap; private MapView mapView; + private CustomLayer customLayer; - private boolean isShowingCustomLayer = false; private FloatingActionButton fab; @Override @@ -43,7 +43,6 @@ public class CustomLayerActivity extends AppCompatActivity { @Override public void onMapReady(MapboxMap map) { mapboxMap = map; - mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(39.91448, -243.60947), 10)); } @@ -62,30 +61,28 @@ public class CustomLayerActivity extends AppCompatActivity { } private void swapCustomLayer() { - - if (isShowingCustomLayer) { + if (customLayer != null) { try { - mapboxMap.removeLayer("custom"); + mapboxMap.removeLayer(customLayer.getId()); + customLayer = null; } catch (NoSuchLayerException noSuchLayerException) { Log.e(TAG, "No custom layer to remove"); } fab.setImageResource(R.drawable.ic_layers_24dp); } else { - mapboxMap.addLayer(new CustomLayer("custom", + customLayer = new CustomLayer("custom", ExampleCustomLayer.createContext(), ExampleCustomLayer.InitializeFunction, ExampleCustomLayer.RenderFunction, - ExampleCustomLayer.DeinitializeFunction), "building"); + ExampleCustomLayer.DeinitializeFunction); + mapboxMap.addLayer(customLayer, "building"); fab.setImageResource(R.drawable.ic_layers_clear_24dp); } - - isShowingCustomLayer = !isShowingCustomLayer; } private void updateLayer() { - CustomLayer custom = mapboxMap.getLayerAs("custom"); - if (custom != null) { - custom.update(); + if (customLayer != null) { + customLayer.update(); } } |