Skip to content

Commit d003da0

Browse files
committed
[annotation] - make options generic, improve basic crud definition on annotation manager
1 parent 014aa04 commit d003da0

26 files changed

Lines changed: 111 additions & 248 deletions

app/src/androidTest/java/com/mapbox/mapboxsdk/plugins/annotation/CircleTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ private void setupAnnotation() {
3636
Timber.i("Retrieving layer");
3737
invoke(mapboxMap, (uiController, mapboxMap) -> {
3838
CircleManager circleManager = new CircleManager(mapboxMap);
39-
circle = circleManager.createCircle(new CircleOptions().withLatLng(new LatLng()));
39+
circle = circleManager.create(new CircleOptions().withLatLng(new LatLng()));
4040
});
4141
}
4242

app/src/androidTest/java/com/mapbox/mapboxsdk/plugins/annotation/FillTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ private void setupAnnotation() {
4242
innerLatLngs.add(new LatLng(-1,-1));
4343
List<List<LatLng>>latLngs = new ArrayList<>();
4444
latLngs.add(innerLatLngs);
45-
fill = fillManager.createFill(new FillOptions().withLatLngs(latLngs));
45+
fill = fillManager.create(new FillOptions().withLatLngs(latLngs));
4646
});
4747
}
4848

app/src/androidTest/java/com/mapbox/mapboxsdk/plugins/annotation/LineTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ private void setupAnnotation() {
3939
List<LatLng>latLngs = new ArrayList<>();
4040
latLngs.add(new LatLng());
4141
latLngs.add(new LatLng(1,1));
42-
line = lineManager.createLine(new LineOptions().withLatLngs(latLngs));
42+
line = lineManager.create(new LineOptions().withLatLngs(latLngs));
4343
});
4444
}
4545

app/src/androidTest/java/com/mapbox/mapboxsdk/plugins/annotation/SymbolTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ private void setupAnnotation() {
3636
Timber.i("Retrieving layer");
3737
invoke(mapboxMap, (uiController, mapboxMap) -> {
3838
SymbolManager symbolManager = new SymbolManager(mapboxMap);
39-
symbol = symbolManager.createSymbol(new SymbolOptions().withLatLng(new LatLng()));
39+
symbol = symbolManager.create(new SymbolOptions().withLatLng(new LatLng()));
4040
});
4141
}
4242

app/src/main/java/com/mapbox/mapboxsdk/plugins/testapp/activity/annotation/CircleActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected void onCreate(Bundle savedInstanceState) {
5050
.withLatLng(new LatLng(6.687337, 0.381457))
5151
.withCircleColor(PropertyFactory.colorToRgbaString(Color.YELLOW))
5252
.withCircleRadius(12f);
53-
circleManager.createCircle(circleOptions);
53+
circleManager.create(circleOptions);
5454

5555
// random add circles across the globe
5656
List<CircleOptions> circleOptionsList = new ArrayList<>();
@@ -62,7 +62,7 @@ protected void onCreate(Bundle savedInstanceState) {
6262
.withCircleRadius(8f)
6363
);
6464
}
65-
circleManager.createCircles(circleOptionsList);
65+
circleManager.create(circleOptionsList);
6666
});
6767
}
6868

app/src/main/java/com/mapbox/mapboxsdk/plugins/testapp/activity/annotation/FillActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ protected void onCreate(Bundle savedInstanceState) {
5555
FillOptions fillOptions = new FillOptions()
5656
.withLatLngs(latLngs)
5757
.withFillColor(PropertyFactory.colorToRgbaString(Color.RED));
58-
fillManager.createFill(fillOptions);
58+
fillManager.create(fillOptions);
5959

6060
// random add fills across the globe
6161
List<FillOptions> fillOptionsList = new ArrayList<>();
@@ -66,7 +66,7 @@ protected void onCreate(Bundle savedInstanceState) {
6666
.withFillColor(PropertyFactory.colorToRgbaString(color))
6767
);
6868
}
69-
fillManager.createFills(fillOptionsList);
69+
fillManager.create(fillOptionsList);
7070
});
7171
}
7272

app/src/main/java/com/mapbox/mapboxsdk/plugins/testapp/activity/annotation/LineActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protected void onCreate(Bundle savedInstanceState) {
5353
.withLatLngs(latLngs)
5454
.withLineColor(PropertyFactory.colorToRgbaString(Color.RED))
5555
.withLineWidth(5.0f);
56-
lineManager.createLine(lineOptions);
56+
lineManager.create(lineOptions);
5757

5858
// random add lines across the globe
5959
List<List<LatLng>> lists = new ArrayList<>();
@@ -66,7 +66,7 @@ protected void onCreate(Bundle savedInstanceState) {
6666
int color = Color.argb(255, random.nextInt(256), random.nextInt(256), random.nextInt(256));
6767
lineOptionsList.add(new LineOptions().withLatLngs(list).withLineColor(PropertyFactory.colorToRgbaString(color)));
6868
}
69-
lineManager.createLines(lineOptionsList);
69+
lineManager.create(lineOptionsList);
7070
});
7171
}
7272

app/src/main/java/com/mapbox/mapboxsdk/plugins/testapp/activity/annotation/SymbolActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ protected void onCreate(Bundle savedInstanceState) {
6464
.withLatLng(new LatLng(6.687337, 0.381457))
6565
.withIconImage(MAKI_ICON_AIRPORT)
6666
.withIconSize(1.3f);
67-
symbol = symbolManager.createSymbol(symbolOptions);
67+
symbol = symbolManager.create(symbolOptions);
6868

6969
// random add symbols across the globe
7070
List<SymbolOptions> symbolOptionsList = new ArrayList<>();
7171
for (int i = 0; i < 20; i++) {
7272
symbolOptionsList.add(new SymbolOptions().withLatLng(createRandomLatLng()).withIconImage(MAKI_ICON_CAR));
7373
}
74-
symbolManager.createSymbols(symbolOptionsList);
74+
symbolManager.create(symbolOptionsList);
7575
});
7676
}
7777

plugin-annotation/scripts/annotation_instrumentation_test.junit.ejs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,20 @@ public class <%- camelize(type) %>Test extends BaseActivityTest {
4141
invoke(mapboxMap, (uiController, mapboxMap) -> {
4242
<%- camelize(type) %>Manager <%- type %>Manager = new <%- camelize(type) %>Manager(mapboxMap);
4343
<% if (type === "circle" || type === "symbol") { -%>
44-
<%- type %> = <%- type %>Manager.create<%- camelize(type) %>(new <%- camelize(type) %>Options().withLatLng(new LatLng()));
44+
<%- type %> = <%- type %>Manager.create(new <%- camelize(type) %>Options().withLatLng(new LatLng()));
4545
<% } else if (type === "line") { -%>
4646
List<LatLng>latLngs = new ArrayList<>();
4747
latLngs.add(new LatLng());
4848
latLngs.add(new LatLng(1,1));
49-
<%- type %> = <%- type %>Manager.create<%- camelize(type) %>(new <%- camelize(type) %>Options().withLatLngs(latLngs));
49+
<%- type %> = <%- type %>Manager.create(new <%- camelize(type) %>Options().withLatLngs(latLngs));
5050
<% } else { -%>
5151
List<LatLng>innerLatLngs = new ArrayList<>();
5252
innerLatLngs.add(new LatLng());
5353
innerLatLngs.add(new LatLng(1,1));
5454
innerLatLngs.add(new LatLng(-1,-1));
5555
List<List<LatLng>>latLngs = new ArrayList<>();
5656
latLngs.add(innerLatLngs);
57-
<%- type %> = <%- type %>Manager.create<%- camelize(type) %>(new <%- camelize(type) %>Options().withLatLngs(latLngs));
57+
<%- type %> = <%- type %>Manager.create(new <%- camelize(type) %>Options().withLatLngs(latLngs));
5858
<% } -%>
5959
});
6060
}

plugin-annotation/scripts/annotation_manager.java.ejs

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
3434
/**
3535
* The <%- type %> manager allows to add <%- type %>s to a map.
3636
*/
37-
public class <%- camelize(type) %>Manager extends AnnotationManager<<%- camelize(type) %>, On<%- camelize(type) %>ClickListener, On<%- camelize(type) %>LongClickListener> {
37+
public class <%- camelize(type) %>Manager extends AnnotationManager<<%- camelize(type) %>, <%- camelize(type) %>Options, On<%- camelize(type) %>ClickListener, On<%- camelize(type) %>LongClickListener> {
3838

3939
public static final String ID_GEOJSON_SOURCE = "mapbox-android-<%- type %>-source";
4040
public static final String ID_GEOJSON_LAYER = "mapbox-android-<%- type %>-layer";
@@ -116,39 +116,6 @@ public class <%- camelize(type) %>Manager extends AnnotationManager<<%- camelize
116116
return <%- camelize(type) %>.ID_KEY;
117117
}
118118

119-
/**
120-
* Create a <%- type %> on the map from a <%- type %> options.
121-
*
122-
* @param options the <%- type %> options to add to the map
123-
* @return the newly created <%- type %>
124-
*/
125-
@UiThread
126-
public <%- camelize(type) %> create<%- camelize(type) %>(@NonNull <%- camelize(type) %>Options options) {
127-
<%- camelize(type) %> <%- type %> = options.build(currentId);
128-
add(<%- type %>);
129-
updateSource();
130-
return <%- type %>;
131-
}
132-
133-
/**
134-
* Create <%- type %>s on the map from a list of option instances.
135-
*
136-
* @param options the list of <%- type %> options to add to the map
137-
* @return a list of the newly created <%- type %>s
138-
*/
139-
@UiThread
140-
public List<<%- camelize(type) %>> create<%- camelize(type) %>s(@NonNull List<<%- camelize(type) %>Options> options) {
141-
List<<%- camelize(type) %>> <%- type %>s = new ArrayList<>();
142-
<%- camelize(type) %> <%- type %>;
143-
for (<%- camelize(type) %>Options option : options) {
144-
<%- type %> = option.build(currentId);
145-
<%- type %>s.add(<%- type %>);
146-
add(<%- type %>);
147-
}
148-
updateSource();
149-
return <%- type %>s;
150-
}
151-
152119
private static PropertyValue<?>[] getLayerDefinition() {
153120
return new PropertyValue[]{
154121
<% for (const property of properties) { -%>

0 commit comments

Comments
 (0)