[android] source list accessor + example
This commit is contained in:
committed by
Ivo van Dongen
parent
ec1dc2622b
commit
f0de56cffa
@@ -85,6 +85,26 @@ public class RuntimeStyleTests {
|
||||
onView(withId(R.id.mapView)).perform(new AddRemoveLayerAction());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListSources() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
onView(withId(R.id.mapView)).perform(new BaseViewAction() {
|
||||
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
List<Source> sources = mapboxMap.getSources();
|
||||
assertNotNull(sources);
|
||||
assertTrue(sources.size() > 0);
|
||||
for (Source source: sources) {
|
||||
assertNotNull(source);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddRemoveSource() {
|
||||
ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
@@ -154,6 +154,9 @@ public class RuntimeStyleActivity extends AppCompatActivity {
|
||||
case R.id.action_list_layers:
|
||||
listLayers();
|
||||
return true;
|
||||
case R.id.action_list_sources:
|
||||
listSources();
|
||||
return true;
|
||||
case R.id.action_water_color:
|
||||
setWaterColor();
|
||||
return true;
|
||||
@@ -211,6 +214,16 @@ public class RuntimeStyleActivity extends AppCompatActivity {
|
||||
Toast.makeText(this, builder.toString(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
private void listSources() {
|
||||
List<Source> sources = mapboxMap.getSources();
|
||||
StringBuilder builder = new StringBuilder("Sources:");
|
||||
for (Source source : sources) {
|
||||
builder.append("\n");
|
||||
builder.append(source.getId());
|
||||
}
|
||||
Toast.makeText(this, builder.toString(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
private void setLayerInvisible() {
|
||||
String[] roadLayers = new String[] {"water"};
|
||||
for (String roadLayer : roadLayers) {
|
||||
|
||||
@@ -6,6 +6,10 @@
|
||||
android:id="@+id/action_list_layers"
|
||||
android:title="List all layers in the style"
|
||||
mapbox:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/action_list_sources"
|
||||
android:title="List all sources in the style"
|
||||
mapbox:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/action_water_color"
|
||||
android:title="Color the water"
|
||||
|
||||
Reference in New Issue
Block a user