refactor signature from Hole to List<LatLng> (#8722)

This commit is contained in:
Pablo Guardiola
2017-04-12 17:45:33 +02:00
committed by GitHub
parent 12b6fdbe3b
commit 7a66ec6c5e
4 changed files with 28 additions and 81 deletions

View File

@@ -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];
}
};
}

View File

@@ -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();
}

View File

@@ -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();
}