summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Guardiola <guardiola31337@gmail.com>2017-04-12 17:45:33 +0200
committerGitHub <noreply@github.com>2017-04-12 17:45:33 +0200
commit7a66ec6c5e442f892e6b4ea5669dac8f25772719 (patch)
tree1c16750e72d2743f6f73c1c6b0b20176084e1eb1
parent12b6fdbe3b1caad95089150d5c3ab69af31fb725 (diff)
downloadqtlocation-mapboxgl-7a66ec6c5e442f892e6b4ea5669dac8f25772719.tar.gz
refactor signature from Hole to List<LatLng> (#8722)
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Hole.java53
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Polygon.java15
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/PolygonOptions.java28
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolygonActivity.java13
4 files changed, 28 insertions, 81 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Hole.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Hole.java
deleted file mode 100644
index cabe16cc5c..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Hole.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package com.mapbox.mapboxsdk.annotations;
-
-
-import android.os.Parcel;
-import android.os.Parcelable;
-
-import com.mapbox.mapboxsdk.geometry.LatLng;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Encapsulates a {@link List} of {@link LatLng} points defining a hole
- */
-public class Hole extends ArrayList<LatLng> implements Parcelable {
-
- public Hole() {
- super();
- }
-
- /**
- * Creates a Hole.
- *
- * @param holePoints {@link List} list of {@link LatLng} points defining a hole
- */
- public Hole(List<LatLng> holePoints) {
- super(holePoints);
- }
-
- protected Hole(Parcel in) {
- in.readTypedList(this, LatLng.CREATOR);
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel parcel, int i) {
- parcel.writeTypedList(this);
- }
-
- public static final Parcelable.Creator<Hole> CREATOR = new Parcelable.Creator<Hole>() {
- public Hole createFromParcel(Parcel in) {
- return new Hole(in);
- }
-
- public Hole[] newArray(int size) {
- return new Hole[size];
- }
- };
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Polygon.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Polygon.java
index 9245d9cdc8..dd2c37762a 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Polygon.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Polygon.java
@@ -2,6 +2,7 @@ package com.mapbox.mapboxsdk.annotations;
import android.graphics.Color;
+import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import java.util.ArrayList;
@@ -14,7 +15,7 @@ public final class Polygon extends BasePointCollection {
private int fillColor = Color.BLACK; // default fillColor is black
private int strokeColor = Color.BLACK; // default strokeColor is black
- private List<Hole> holes;
+ private List<List<LatLng>> holes;
Polygon() {
super();
@@ -42,9 +43,9 @@ public final class Polygon extends BasePointCollection {
/**
* Returns a copy of the holes.
*
- * @return A {@link List} of holes.
+ * @return A {@link List} of {@link List} of {@link LatLng} points making up the holes.
*/
- public List<Hole> getHoles() {
+ public List<List<LatLng>> getHoles() {
return new ArrayList<>(holes);
}
@@ -72,9 +73,9 @@ public final class Polygon extends BasePointCollection {
* Sets the holes of this polygon. This method will take a copy of the holes, so further
* mutations to holes will have no effect on this polygon.
*
- * @param holes A {@link List} of {@link Hole} points making up the holes.
+ * @param holes A {@link List} of {@link List} of {@link LatLng} points making up the holes.
*/
- public void setHoles(List<? extends Hole> holes) {
+ public void setHoles(List<? extends List<LatLng>> holes) {
this.holes = new ArrayList<>(holes);
update();
}
@@ -82,9 +83,9 @@ public final class Polygon extends BasePointCollection {
/**
* Add a hole to the polygon.
*
- * @param hole A {@link Hole} hole to be added.
+ * @param hole A {@link List} of {@link List} of {@link LatLng} points making up the hole to be added.
*/
- void addHole(Hole hole) {
+ void addHole(List<LatLng> hole) {
holes.add(hole);
update();
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/PolygonOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/PolygonOptions.java
index 7405ebfb4a..eaad25133e 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/PolygonOptions.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/PolygonOptions.java
@@ -27,11 +27,11 @@ public final class PolygonOptions implements Parcelable {
private PolygonOptions(Parcel in) {
polygon = new Polygon();
- ArrayList<LatLng> pointsList = new ArrayList<>();
+ List<LatLng> pointsList = new ArrayList<>();
in.readList(pointsList, LatLng.class.getClassLoader());
addAll(pointsList);
- ArrayList<Hole> holes = new ArrayList<>();
- in.readTypedList(holes, Hole.CREATOR);
+ List<List<LatLng>> holes = new ArrayList<>();
+ in.readList(holes, LatLng.class.getClassLoader());
addAllHoles(holes);
alpha(in.readFloat());
fillColor(in.readInt());
@@ -59,7 +59,7 @@ public final class PolygonOptions implements Parcelable {
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeList(getPoints());
- out.writeTypedList(getHoles());
+ out.writeList(getHoles());
out.writeFloat(getAlpha());
out.writeInt(getFillColor());
out.writeInt(getStrokeColor());
@@ -115,10 +115,10 @@ public final class PolygonOptions implements Parcelable {
/**
* Adds a hole to the outline of the polygon being built.
*
- * @param hole {@link Hole} list made up of {@link LatLng} points defining the hole
+ * @param hole {@link List} list made up of {@link LatLng} points defining the hole
* @return This {@link PolygonOptions} object with the given hole added to the outline.
*/
- public PolygonOptions addHole(Hole hole) {
+ public PolygonOptions addHole(List<LatLng> hole) {
polygon.addHole(hole);
return this;
}
@@ -126,11 +126,11 @@ public final class PolygonOptions implements Parcelable {
/**
* Adds holes to the outline of the polygon being built.
*
- * @param holes {@link Hole} holes to be added to polygon geometry.
+ * @param holes {@link List} list made up of {@link LatLng} holes to be added to polygon geometry
* @return This {@link PolygonOptions} object with the given holes added to the outline.
*/
- public PolygonOptions addHole(Hole... holes) {
- for (Hole hole : holes) {
+ public PolygonOptions addHole(List<LatLng>... holes) {
+ for (List<LatLng> hole : holes) {
addHole(hole);
}
return this;
@@ -139,11 +139,11 @@ public final class PolygonOptions implements Parcelable {
/**
* Adds holes to the outline of the polygon being built.
*
- * @param holes {@link Iterable} list made up of {@link Hole} holes defining the hole geometry
+ * @param holes {@link Iterable} list made up of {@link List} list of {@link LatLng} holes defining the hole geometry
* @return This {@link PolygonOptions} object with the given holes added to the outline.
*/
- public PolygonOptions addAllHoles(Iterable<Hole> holes) {
- for (Hole hole : holes) {
+ public PolygonOptions addAllHoles(Iterable<List<LatLng>> holes) {
+ for (List<LatLng> hole : holes) {
addHole(hole);
}
return this;
@@ -231,9 +231,9 @@ public final class PolygonOptions implements Parcelable {
/**
* Gets the holes set for this {@link PolygonOptions} object.
*
- * @return The list made up of {@link List} of {@link LatLng} points defining the holes.
+ * @return The list made up of {@link List} of {@link List} of {@link LatLng} points defining the holes.
*/
- public List<Hole> getHoles() {
+ public List<List<LatLng>> getHoles() {
return polygon.getHoles();
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolygonActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolygonActivity.java
index 429509e1d2..b51d717f33 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolygonActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolygonActivity.java
@@ -6,7 +6,6 @@ import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
-import com.mapbox.mapboxsdk.annotations.Hole;
import com.mapbox.mapboxsdk.annotations.Polygon;
import com.mapbox.mapboxsdk.annotations.PolygonOptions;
import com.mapbox.mapboxsdk.camera.CameraPosition;
@@ -46,8 +45,8 @@ public class PolygonActivity extends AppCompatActivity implements OnMapReadyCall
private boolean fullAlpha = true;
private boolean visible = true;
private boolean color = true;
- private boolean allPoints;
- private boolean holes;
+ private boolean allPoints = true;
+ private boolean holes = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -146,7 +145,7 @@ public class PolygonActivity extends AppCompatActivity implements OnMapReadyCall
return true;
case R.id.action_id_holes:
holes = !holes;
- polygon.setHoles(holes ? STAR_SHAPE_HOLES : Collections.<Hole>emptyList());
+ polygon.setHoles(holes ? STAR_SHAPE_HOLES : Collections.<List<LatLng>>emptyList());
return true;
default:
return super.onOptionsItemSelected(item);
@@ -188,9 +187,9 @@ public class PolygonActivity extends AppCompatActivity implements OnMapReadyCall
static final List<LatLng> BROKEN_SHAPE_POINTS =
STAR_SHAPE_POINTS.subList(0, STAR_SHAPE_POINTS.size() - 3);
- static final List<? extends Hole> STAR_SHAPE_HOLES = new ArrayList<Hole>() {
+ static final List<? extends List<LatLng>> STAR_SHAPE_HOLES = new ArrayList<List<LatLng>>() {
{
- add(new Hole(new ArrayList<LatLng>() {
+ add(new ArrayList<>(new ArrayList<LatLng>() {
{
add(new LatLng(45.521743, -122.669091));
add(new LatLng(45.530483, -122.676833));
@@ -198,7 +197,7 @@ public class PolygonActivity extends AppCompatActivity implements OnMapReadyCall
add(new LatLng(45.521743, -122.669091));
}
}));
- add(new Hole(new ArrayList<LatLng>() {
+ add(new ArrayList<>(new ArrayList<LatLng>() {
{
add(new LatLng(45.529743, -122.662791));
add(new LatLng(45.525543, -122.662791));