diff options
author | Tobrun <tobrun.van.nuland@gmail.com> | 2018-10-10 10:36:46 +0200 |
---|---|---|
committer | Tobrun <tobrun.van.nuland@gmail.com> | 2018-10-12 17:57:47 +0200 |
commit | 5ec60dc253dfaa8225d1ca40849b941f5b8196cf (patch) | |
tree | 5dbda0cc3bc6c0eb22eac350fcd954ab7606ea21 /platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations | |
parent | 66e4e972243437f4ce804144b457975aad436aeb (diff) | |
download | qtlocation-mapboxgl-upstream/tvn-kotlin-compability.tar.gz |
[android] - infer nullityupstream/tvn-kotlin-compability
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations')
15 files changed, 108 insertions, 40 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Annotation.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Annotation.java index a588ff6d23..2650664151 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Annotation.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Annotation.java @@ -2,6 +2,7 @@ package com.mapbox.mapboxsdk.annotations; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; @@ -121,11 +122,11 @@ public abstract class Annotation implements Comparable<Annotation> { * @return returns true both id's match else returns false. */ @Override - public boolean equals(Object object) { + public boolean equals(@Nullable Object object) { if (this == object) { return true; } - if (object == null || !(object instanceof Annotation)) { + if (!(object instanceof Annotation)) { return false; } Annotation that = (Annotation) object; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BasePointCollection.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BasePointCollection.java index 4fee9443d7..eeb9aa5017 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BasePointCollection.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BasePointCollection.java @@ -2,6 +2,7 @@ package com.mapbox.mapboxsdk.annotations; import android.support.annotation.Keep; +import android.support.annotation.NonNull; import com.mapbox.mapboxsdk.geometry.LatLng; import java.util.ArrayList; @@ -27,6 +28,7 @@ public abstract class BasePointCollection extends Annotation { * * @return A {@link List} of points. */ + @NonNull public List<LatLng> getPoints() { return new ArrayList<>(points); } @@ -37,7 +39,7 @@ public abstract class BasePointCollection extends Annotation { * * @param points A {@link List} of {@link LatLng} points making up the polyline. */ - public void setPoints(List<LatLng> points) { + public void setPoints(@NonNull List<LatLng> points) { this.points = new ArrayList<>(points); update(); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Bubble.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Bubble.java index 6fad249780..f024d6ebb4 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Bubble.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Bubble.java @@ -8,22 +8,26 @@ import android.graphics.PixelFormat; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.drawable.Drawable; +import android.support.annotation.NonNull; class Bubble extends Drawable { + @NonNull private RectF rect; private float arrowWidth; private float arrowHeight; private float arrowPosition; private float cornersRadius; + @NonNull private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); private float strokeWidth; private Paint strokePaint; private Path strokePath; + @NonNull private Path path = new Path(); - Bubble(RectF rect, ArrowDirection arrowDirection, float arrowWidth, float arrowHeight, float arrowPosition, - float cornersRadius, int bubbleColor, float strokeWidth, int strokeColor) { + Bubble(@NonNull RectF rect, @NonNull ArrowDirection arrowDirection, float arrowWidth, float arrowHeight, + float arrowPosition, float cornersRadius, int bubbleColor, float strokeWidth, int strokeColor) { this.rect = rect; this.arrowWidth = arrowWidth; this.arrowHeight = arrowHeight; @@ -49,7 +53,7 @@ class Bubble extends Drawable { } @Override - public void draw(Canvas canvas) { + public void draw(@NonNull Canvas canvas) { if (strokeWidth > 0) { canvas.drawPath(strokePath, strokePaint); } @@ -81,7 +85,7 @@ class Bubble extends Drawable { return (int) rect.height(); } - private void initPath(ArrowDirection arrowDirection, Path path, float strokeWidth) { + private void initPath(@NonNull ArrowDirection arrowDirection, @NonNull Path path, float strokeWidth) { switch (arrowDirection.getValue()) { case ArrowDirection.LEFT: if (cornersRadius <= 0) { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BubbleLayout.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BubbleLayout.java index c58cc310a8..b5bcf188ae 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BubbleLayout.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BubbleLayout.java @@ -5,6 +5,7 @@ import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.RectF; +import android.support.annotation.NonNull; import android.util.AttributeSet; import android.util.DisplayMetrics; import android.widget.LinearLayout; @@ -17,6 +18,7 @@ import com.mapbox.mapboxsdk.R; public class BubbleLayout extends LinearLayout { public static final float DEFAULT_STROKE_WIDTH = -1; + @NonNull private ArrowDirection arrowDirection; private float arrowWidth; private float arrowHeight; @@ -32,7 +34,7 @@ public class BubbleLayout extends LinearLayout { * * @param context The context used to inflate this bubble layout */ - public BubbleLayout(Context context) { + public BubbleLayout(@NonNull Context context) { this(context, null, 0); } @@ -42,7 +44,7 @@ public class BubbleLayout extends LinearLayout { * @param context The context used to inflate this bubble layout * @param attrs The attribute set to initialise this bubble layout from */ - public BubbleLayout(Context context, AttributeSet attrs) { + public BubbleLayout(@NonNull Context context, AttributeSet attrs) { this(context, attrs, 0); } @@ -53,7 +55,7 @@ public class BubbleLayout extends LinearLayout { * @param attrs The attribute set to initialise this bubble layout from * @param defStyleAttr The default style to apply this bubble layout with */ - public BubbleLayout(Context context, AttributeSet attrs, int defStyleAttr) { + public BubbleLayout(@NonNull Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.mapbox_BubbleLayout); @@ -84,7 +86,7 @@ public class BubbleLayout extends LinearLayout { } @Override - protected void dispatchDraw(Canvas canvas) { + protected void dispatchDraw(@NonNull Canvas canvas) { if (bubble != null) { bubble.draw(canvas); } @@ -111,7 +113,8 @@ public class BubbleLayout extends LinearLayout { * @param arrowDirection The direction of the arrow * @return this */ - public BubbleLayout setArrowDirection(ArrowDirection arrowDirection) { + @NonNull + public BubbleLayout setArrowDirection(@NonNull ArrowDirection arrowDirection) { resetPadding(); this.arrowDirection = arrowDirection; initPadding(); @@ -133,6 +136,7 @@ public class BubbleLayout extends LinearLayout { * @param arrowWidth The width of the arrow * @return this */ + @NonNull public BubbleLayout setArrowWidth(float arrowWidth) { resetPadding(); this.arrowWidth = arrowWidth; @@ -155,6 +159,7 @@ public class BubbleLayout extends LinearLayout { * @param arrowHeight The height of the arrow * @return this */ + @NonNull public BubbleLayout setArrowHeight(float arrowHeight) { resetPadding(); this.arrowHeight = arrowHeight; @@ -177,6 +182,7 @@ public class BubbleLayout extends LinearLayout { * @param arrowPosition The arrow position * @return this */ + @NonNull public BubbleLayout setArrowPosition(float arrowPosition) { resetPadding(); this.arrowPosition = arrowPosition; @@ -199,6 +205,7 @@ public class BubbleLayout extends LinearLayout { * @param cornersRadius The corner radius * @return this */ + @NonNull public BubbleLayout setCornersRadius(float cornersRadius) { this.cornersRadius = cornersRadius; requestLayout(); @@ -220,6 +227,7 @@ public class BubbleLayout extends LinearLayout { * @param bubbleColor The buble color * @return this */ + @NonNull public BubbleLayout setBubbleColor(int bubbleColor) { this.bubbleColor = bubbleColor; requestLayout(); @@ -241,6 +249,7 @@ public class BubbleLayout extends LinearLayout { * @param strokeWidth The stroke width * @return this */ + @NonNull public BubbleLayout setStrokeWidth(float strokeWidth) { resetPadding(); this.strokeWidth = strokeWidth; @@ -263,6 +272,7 @@ public class BubbleLayout extends LinearLayout { * @param strokeColor The stroke color * @return this */ + @NonNull public BubbleLayout setStrokeColor(int strokeColor) { this.strokeColor = strokeColor; requestLayout(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BubblePopupHelper.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BubblePopupHelper.java index 215445abaa..87b35bc7c2 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BubblePopupHelper.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BubblePopupHelper.java @@ -11,6 +11,7 @@ import com.mapbox.mapboxsdk.R; class BubblePopupHelper { + @NonNull static PopupWindow create(@NonNull Context context, @NonNull BubbleLayout bubbleLayout) { PopupWindow popupWindow = new PopupWindow(context); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Icon.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Icon.java index 8749656e35..752de76d5e 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Icon.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Icon.java @@ -1,6 +1,8 @@ package com.mapbox.mapboxsdk.annotations; import android.graphics.Bitmap; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.util.DisplayMetrics; import java.nio.ByteBuffer; @@ -69,6 +71,7 @@ public class Icon { * * @return the bytes of the bitmap */ + @NonNull public byte[] toBytes() { if (mBitmap == null) { throw new IllegalStateException("Required to set a Icon before calling toBytes"); @@ -85,7 +88,7 @@ public class Icon { * @return True if the icon being passed in matches this icon object. Else, false. */ @Override - public boolean equals(Object object) { + public boolean equals(@Nullable Object object) { if (this == object) { return true; } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java index f81922097e..4a3027fe97 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java @@ -4,6 +4,8 @@ import android.content.res.Resources; import android.graphics.PointF; import android.os.Build; import android.support.annotation.LayoutRes; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; @@ -47,17 +49,17 @@ public class InfoWindow { @LayoutRes private int layoutRes; - InfoWindow(MapView mapView, int layoutResId, MapboxMap mapboxMap) { + InfoWindow(@NonNull MapView mapView, int layoutResId, @NonNull MapboxMap mapboxMap) { layoutRes = layoutResId; View view = LayoutInflater.from(mapView.getContext()).inflate(layoutResId, mapView, false); initialize(view, mapboxMap); } - InfoWindow(View view, MapboxMap mapboxMap) { + InfoWindow(@NonNull View view, @NonNull MapboxMap mapboxMap) { initialize(view, mapboxMap); } - private void initialize(View view, MapboxMap mapboxMap) { + private void initialize(@NonNull View view, @NonNull MapboxMap mapboxMap) { this.mapboxMap = new WeakReference<>(mapboxMap); isVisible = false; this.view = new WeakReference<>(view); @@ -116,7 +118,8 @@ public class InfoWindow { * the view from the object position. * @return this {@link InfoWindow}. */ - InfoWindow open(MapView mapView, Marker boundMarker, LatLng position, int offsetX, int offsetY) { + @NonNull + InfoWindow open(@NonNull MapView mapView, Marker boundMarker, @NonNull LatLng position, int offsetX, int offsetY) { setBoundMarker(boundMarker); MapView.LayoutParams lp = new MapView.LayoutParams(MapView.LayoutParams.WRAP_CONTENT, @@ -213,6 +216,7 @@ public class InfoWindow { * * @return This {@link InfoWindow} */ + @NonNull InfoWindow close() { MapboxMap mapboxMap = this.mapboxMap.get(); if (isVisible && mapboxMap != null) { @@ -239,7 +243,7 @@ public class InfoWindow { * * @param overlayItem the tapped overlay item */ - void adaptDefaultMarker(Marker overlayItem, MapboxMap mapboxMap, MapView mapView) { + void adaptDefaultMarker(@NonNull Marker overlayItem, MapboxMap mapboxMap, @NonNull MapView mapView) { View view = this.view.get(); if (view == null) { view = LayoutInflater.from(mapView.getContext()).inflate(layoutRes, mapView, false); @@ -265,11 +269,13 @@ public class InfoWindow { } } + @NonNull InfoWindow setBoundMarker(Marker boundMarker) { this.boundMarker = new WeakReference<>(boundMarker); return this; } + @Nullable Marker getBoundMarker() { if (boundMarker == null) { return null; @@ -307,6 +313,7 @@ public class InfoWindow { } } + @Nullable private final ViewTreeObserver.OnGlobalLayoutListener contentUpdateListener = new ViewTreeObserver.OnGlobalLayoutListener() { @Override @@ -329,6 +336,7 @@ public class InfoWindow { * * @return This {@link InfoWindow}'s current View. */ + @Nullable public View getView() { return view != null ? view.get() : null; } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Marker.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Marker.java index d0e5777602..a99a7d08da 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Marker.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Marker.java @@ -31,12 +31,15 @@ public class Marker extends Annotation { @Keep private LatLng position; private String snippet; + @Nullable private Icon icon; //Redundantly stored for JNI access + @Nullable @Keep private String iconId; private String title; + @Nullable private InfoWindow infoWindow; private boolean infoWindowShown; @@ -161,6 +164,7 @@ public class Marker extends Annotation { * * @return The {@link Icon} the marker is using. */ + @Nullable public Icon getIcon() { return icon; } @@ -212,6 +216,7 @@ public class Marker extends Annotation { * @param mapView The hosting map view. * @return The info window that was shown. */ + @Nullable public InfoWindow showInfoWindow(@NonNull MapboxMap mapboxMap, @NonNull MapView mapView) { setMapboxMap(mapboxMap); setMapView(mapView); @@ -233,12 +238,14 @@ public class Marker extends Annotation { return showInfoWindow(infoWindow, mapView); } + @NonNull private InfoWindow showInfoWindow(InfoWindow iw, MapView mapView) { iw.open(mapView, this, getPosition(), rightOffsetPixels, topOffsetPixels); infoWindowShown = true; return iw; } + @Nullable private InfoWindow getInfoWindow(@NonNull MapView mapView) { if (infoWindow == null && mapView.getContext() != null) { infoWindow = new InfoWindow(mapView, R.layout.mapbox_infowindow_content, getMapboxMap()); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerOptions.java index 49d4867801..f65c87d258 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerOptions.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerOptions.java @@ -4,6 +4,8 @@ import android.graphics.Bitmap; import android.os.Parcel; import android.os.Parcelable; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import com.mapbox.mapboxsdk.exceptions.InvalidMarkerPositionException; import com.mapbox.mapboxsdk.geometry.LatLng; @@ -40,6 +42,7 @@ public final class MarkerOptions extends BaseMarkerOptions<Marker, MarkerOptions } } + @NonNull @Override public MarkerOptions getThis() { return this; @@ -128,7 +131,7 @@ public final class MarkerOptions extends BaseMarkerOptions<Marker, MarkerOptions public static final Parcelable.Creator<MarkerOptions> CREATOR = new Parcelable.Creator<MarkerOptions>() { - public MarkerOptions createFromParcel(Parcel in) { + public MarkerOptions createFromParcel(@NonNull Parcel in) { return new MarkerOptions(in); } @@ -146,7 +149,7 @@ public final class MarkerOptions extends BaseMarkerOptions<Marker, MarkerOptions * Else, false. */ @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerView.java index eb82c7bf53..9021ffbab4 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerView.java @@ -1,6 +1,7 @@ package com.mapbox.mapboxsdk.annotations; import android.support.annotation.FloatRange; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import com.mapbox.mapboxsdk.Mapbox; @@ -67,7 +68,7 @@ public class MarkerView extends Marker { * * @param baseMarkerViewOptions the builder used to construct the MarkerView */ - public MarkerView(BaseMarkerViewOptions baseMarkerViewOptions) { + public MarkerView(@NonNull BaseMarkerViewOptions baseMarkerViewOptions) { super(baseMarkerViewOptions); this.alpha = baseMarkerViewOptions.getAlpha(); this.anchorU = baseMarkerViewOptions.getAnchorU(); @@ -384,7 +385,7 @@ public class MarkerView extends Marker { * @param mapboxMap the MapboxMap instances. */ @Override - public void setMapboxMap(MapboxMap mapboxMap) { + public void setMapboxMap(@Nullable MapboxMap mapboxMap) { super.setMapboxMap(mapboxMap); if (mapboxMap != null) { if (isFlat()) { @@ -410,6 +411,7 @@ public class MarkerView extends Marker { * * @return the String representation. */ + @NonNull @Override public String toString() { return "MarkerView [position[" + getPosition() + "]]"; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java index 8baec7879c..2875002ab0 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java @@ -36,6 +36,7 @@ import java.util.Map; @Deprecated public class MarkerViewManager implements MapView.OnMapChangedListener { + @NonNull private final ViewGroup markerViewContainer; private final ViewTreeObserver.OnPreDrawListener markerViewPreDrawObserver = new ViewTreeObserver.OnPreDrawListener() { @@ -56,6 +57,7 @@ public class MarkerViewManager implements MapView.OnMapChangedListener { private boolean enabled; private long updateTime; + @Nullable private MapboxMap.OnMarkerViewClickListener onMarkerViewClickListener; private boolean isWaitingForRenderInvoke; @@ -330,7 +332,7 @@ public class MarkerViewManager implements MapView.OnMapChangedListener { * @param convertView the View presentation of the MarkerView. * @param adapter the adapter used to adapt the marker to the convertView. */ - public void select(@NonNull MarkerView marker, View convertView, MapboxMap.MarkerViewAdapter adapter) { + public void select(@NonNull MarkerView marker, View convertView, @NonNull MapboxMap.MarkerViewAdapter adapter) { select(marker, convertView, adapter, true); } @@ -347,8 +349,8 @@ public class MarkerViewManager implements MapView.OnMapChangedListener { * @param adapter the adapter used to adapt the marker to the convertView. * @param callbackToMap indicates if select marker must be called on MapboxMap. */ - public void select(@NonNull MarkerView marker, View convertView, MapboxMap.MarkerViewAdapter adapter, - boolean callbackToMap) { + public void select(@NonNull MarkerView marker, @Nullable View convertView, + @NonNull MapboxMap.MarkerViewAdapter adapter, boolean callbackToMap) { if (convertView != null) { if (adapter.onSelect(marker, convertView, false)) { if (callbackToMap) { @@ -379,7 +381,7 @@ public class MarkerViewManager implements MapView.OnMapChangedListener { * @return the MarkerView adapter. */ @Nullable - public MapboxMap.MarkerViewAdapter getViewAdapter(MarkerView markerView) { + public MapboxMap.MarkerViewAdapter getViewAdapter(@NonNull MarkerView markerView) { MapboxMap.MarkerViewAdapter adapter = null; for (MapboxMap.MarkerViewAdapter a : markerViewAdapters) { if (a.getMarkerClass().equals(markerView.getClass())) { @@ -400,7 +402,7 @@ public class MarkerViewManager implements MapView.OnMapChangedListener { * * @param marker the MarkerView to remove. */ - public void removeMarkerView(MarkerView marker) { + public void removeMarkerView(@Nullable MarkerView marker) { final View viewHolder = markerViewMap.get(marker); if (viewHolder != null && marker != null) { for (final MapboxMap.MarkerViewAdapter<?> adapter : markerViewAdapters) { @@ -425,7 +427,7 @@ public class MarkerViewManager implements MapView.OnMapChangedListener { * * @param markerViewAdapter the MarkerViewAdapter to add. */ - public void addMarkerViewAdapter(MapboxMap.MarkerViewAdapter markerViewAdapter) { + public void addMarkerViewAdapter(@NonNull MapboxMap.MarkerViewAdapter markerViewAdapter) { if (markerViewAdapter.getMarkerClass().equals(MarkerView.class)) { throw new RuntimeException("Providing a custom MarkerViewAdapter requires subclassing MarkerView"); } @@ -441,6 +443,7 @@ public class MarkerViewManager implements MapView.OnMapChangedListener { * * @return a List of MarkerViewAdapters. */ + @NonNull public List<MapboxMap.MarkerViewAdapter> getMarkerViewAdapters() { return markerViewAdapters; } @@ -559,7 +562,7 @@ public class MarkerViewManager implements MapView.OnMapChangedListener { * @param markerView that the click event occurred * @return true if the marker view click has been handled, false if not */ - public boolean onClickMarkerView(MarkerView markerView) { + public boolean onClickMarkerView(@NonNull MarkerView markerView) { boolean clickHandled = false; MapboxMap.MarkerViewAdapter adapter = getViewAdapter(markerView); @@ -581,7 +584,7 @@ public class MarkerViewManager implements MapView.OnMapChangedListener { * * @param marker that we are ensuring info window offset */ - public void ensureInfoWindowOffset(MarkerView marker) { + public void ensureInfoWindowOffset(@NonNull MarkerView marker) { View view = null; if (markerViewMap.containsKey(marker)) { view = markerViewMap.get(marker); @@ -620,12 +623,13 @@ public class MarkerViewManager implements MapView.OnMapChangedListener { } } + @NonNull public ViewGroup getMarkerViewContainer() { return markerViewContainer; } - public void addOnMarkerViewAddedListener(MarkerView markerView, OnMarkerViewAddedListener onMarkerViewAddedListener) { - markerViewAddedListenerMap.put(markerView.getId(), onMarkerViewAddedListener); + public void addOnMarkerViewAddedListener(@NonNull MarkerView markerView, OnMarkerViewAddedListener listener) { + markerViewAddedListenerMap.put(markerView.getId(), listener); } /** diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewOptions.java index 79c72e5f70..af56f126e3 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewOptions.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewOptions.java @@ -4,6 +4,8 @@ import android.graphics.Bitmap; import android.os.Parcel; import android.os.Parcelable; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import com.mapbox.mapboxsdk.exceptions.InvalidMarkerPositionException; import com.mapbox.mapboxsdk.geometry.LatLng; @@ -53,6 +55,7 @@ public class MarkerViewOptions extends BaseMarkerViewOptions<MarkerView, MarkerV * * @return the object for which this method was called. */ + @NonNull @Override public MarkerViewOptions getThis() { return this; @@ -77,7 +80,7 @@ public class MarkerViewOptions extends BaseMarkerViewOptions<MarkerView, MarkerV * {@link #PARCELABLE_WRITE_RETURN_VALUE}. */ @Override - public void writeToParcel(Parcel out, int flags) { + public void writeToParcel(@NonNull Parcel out, int flags) { out.writeParcelable(getPosition(), flags); out.writeString(getSnippet()); out.writeString(getTitle()); @@ -123,7 +126,7 @@ public class MarkerViewOptions extends BaseMarkerViewOptions<MarkerView, MarkerV public static final Parcelable.Creator<MarkerViewOptions> CREATOR = new Parcelable.Creator<MarkerViewOptions>() { - public MarkerViewOptions createFromParcel(Parcel in) { + public MarkerViewOptions createFromParcel(@NonNull Parcel in) { return new MarkerViewOptions(in); } @@ -141,7 +144,7 @@ public class MarkerViewOptions extends BaseMarkerViewOptions<MarkerView, MarkerV * {@link PolylineOptions} object. Else, false. */ @Override - public boolean equals(Object object) { + public boolean equals(@Nullable Object object) { if (this == object) { return true; } 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 b45c32cdae..fa6a087f7c 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 @@ -3,6 +3,7 @@ package com.mapbox.mapboxsdk.annotations; import android.graphics.Color; import android.support.annotation.Keep; +import android.support.annotation.NonNull; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.maps.MapboxMap; @@ -79,7 +80,7 @@ public final class Polygon extends BasePointCollection { * * @param holes A {@link List} of {@link List} of {@link LatLng} points making up the holes. */ - public void setHoles(List<? extends List<LatLng>> holes) { + public void setHoles(@NonNull List<? extends List<LatLng>> holes) { this.holes = new ArrayList<>(holes); 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 eaad25133e..d6810d5a61 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 @@ -4,6 +4,8 @@ package com.mapbox.mapboxsdk.annotations; import android.os.Parcel; import android.os.Parcelable; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import com.mapbox.mapboxsdk.geometry.LatLng; import java.util.ArrayList; @@ -16,7 +18,7 @@ public final class PolygonOptions implements Parcelable { public static final Parcelable.Creator<PolygonOptions> CREATOR = new Parcelable.Creator<PolygonOptions>() { - public PolygonOptions createFromParcel(Parcel in) { + public PolygonOptions createFromParcel(@NonNull Parcel in) { return new PolygonOptions(in); } @@ -80,6 +82,7 @@ public final class PolygonOptions implements Parcelable { * @param point {@link LatLng} point to be added to polygon geometry. * @return This {@link PolygonOptions} object with the given point added to the outline. */ + @NonNull public PolygonOptions add(LatLng point) { polygon.addPoint(point); return this; @@ -91,6 +94,7 @@ public final class PolygonOptions implements Parcelable { * @param points {@link LatLng} points to be added to polygon geometry. * @return This {@link PolygonOptions} object with the given points added to the outline. */ + @NonNull public PolygonOptions add(LatLng... points) { for (LatLng point : points) { add(point); @@ -105,6 +109,7 @@ public final class PolygonOptions implements Parcelable { * geometry * @return This {@link PolygonOptions} object with the given points added to the outline. */ + @NonNull public PolygonOptions addAll(Iterable<LatLng> points) { for (LatLng point : points) { add(point); @@ -118,6 +123,7 @@ public final class PolygonOptions implements Parcelable { * @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. */ + @NonNull public PolygonOptions addHole(List<LatLng> hole) { polygon.addHole(hole); return this; @@ -129,6 +135,7 @@ public final class PolygonOptions implements Parcelable { * @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. */ + @NonNull public PolygonOptions addHole(List<LatLng>... holes) { for (List<LatLng> hole : holes) { addHole(hole); @@ -142,6 +149,7 @@ public final class PolygonOptions implements Parcelable { * @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. */ + @NonNull public PolygonOptions addAllHoles(Iterable<List<LatLng>> holes) { for (List<LatLng> hole : holes) { addHole(hole); @@ -155,6 +163,7 @@ public final class PolygonOptions implements Parcelable { * @param alpha float value between 0 (not visible) and 1. * @return This {@link PolygonOptions} object with the given polygon alpha value. */ + @NonNull public PolygonOptions alpha(float alpha) { polygon.setAlpha(alpha); return this; @@ -175,6 +184,7 @@ public final class PolygonOptions implements Parcelable { * @param color 32-bit ARGB color. * @return This {@link PolylineOptions} object with a new color set. */ + @NonNull public PolygonOptions fillColor(int color) { polygon.setFillColor(color); return this; @@ -204,6 +214,7 @@ public final class PolygonOptions implements Parcelable { * @param color 32-bit ARGB color. * @return This {@link PolygonOptions} object with a new stroke color set. */ + @NonNull public PolygonOptions strokeColor(int color) { polygon.setStrokeColor(color); return this; @@ -247,7 +258,7 @@ public final class PolygonOptions implements Parcelable { * {@link PolygonOptions} object. Else, false. */ @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/PolylineOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/PolylineOptions.java index ab22109a4e..343dddcbc7 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/PolylineOptions.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/PolylineOptions.java @@ -3,6 +3,8 @@ package com.mapbox.mapboxsdk.annotations; import android.os.Parcel; import android.os.Parcelable; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import com.mapbox.mapboxsdk.geometry.LatLng; import java.util.ArrayList; @@ -16,7 +18,7 @@ public final class PolylineOptions implements Parcelable { public static final Parcelable.Creator<PolylineOptions> CREATOR = new Parcelable.Creator<PolylineOptions>() { - public PolylineOptions createFromParcel(Parcel in) { + public PolylineOptions createFromParcel(@NonNull Parcel in) { return new PolylineOptions(in); } @@ -76,6 +78,7 @@ public final class PolylineOptions implements Parcelable { * @param point {@link LatLng} point to be added to polyline geometry. * @return This {@link PolylineOptions} object with the given point on the end. */ + @NonNull public PolylineOptions add(LatLng point) { polyline.addPoint(point); return this; @@ -87,6 +90,7 @@ public final class PolylineOptions implements Parcelable { * @param points {@link LatLng} points defining the polyline geometry. * @return This {@link PolylineOptions} object with the given point on the end. */ + @NonNull public PolylineOptions add(LatLng... points) { for (LatLng point : points) { add(point); @@ -101,6 +105,7 @@ public final class PolylineOptions implements Parcelable { * geometry * @return This {@link PolylineOptions} object with the given points on the end. */ + @NonNull public PolylineOptions addAll(Iterable<LatLng> points) { for (LatLng point : points) { add(point); @@ -114,6 +119,7 @@ public final class PolylineOptions implements Parcelable { * @param alpha float value between 0 (not visible) and 1. * @return This {@link PolylineOptions} object with the given polyline alpha value. */ + @NonNull public PolylineOptions alpha(float alpha) { polyline.setAlpha(alpha); return this; @@ -134,6 +140,7 @@ public final class PolylineOptions implements Parcelable { * @param color 32-bit ARGB color. * @return This {@link PolylineOptions} object with a new color set. */ + @NonNull public PolylineOptions color(int color) { polyline.setColor(color); return this; @@ -172,6 +179,7 @@ public final class PolylineOptions implements Parcelable { * @param width float value defining width of polyline using unit pixels. * @return This {@link PolylineOptions} object with a new width set. */ + @NonNull public PolylineOptions width(float width) { polyline.setWidth(width); return this; @@ -196,7 +204,7 @@ public final class PolylineOptions implements Parcelable { * Else, false. */ @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } |