diff options
Diffstat (limited to 'platform')
131 files changed, 1375 insertions, 415 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/Mapbox.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/Mapbox.java index 3959d2cf3c..9d813586fa 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/Mapbox.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/Mapbox.java @@ -33,8 +33,10 @@ public final class Mapbox { private static Mapbox INSTANCE; private Context context; + @Nullable private String accessToken; private Boolean connected; + @Nullable private TelemetryDefinition telemetry; /** @@ -47,6 +49,7 @@ public final class Mapbox { * @param accessToken Mapbox access token * @return the single instance of Mapbox */ + @NonNull @UiThread public static synchronized Mapbox getInstance(@NonNull Context context, @Nullable String accessToken) { ThreadUtils.checkThread("Mapbox"); @@ -171,7 +174,7 @@ public final class Mapbox { * @param accessToken the access token to validate * @return true is valid, false otherwise */ - static boolean isAccessTokenValid(String accessToken) { + static boolean isAccessTokenValid(@Nullable String accessToken) { if (accessToken == null) { return false; } 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; } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/attribution/Attribution.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/attribution/Attribution.java index 0877b3ab97..561ce5bf1a 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/attribution/Attribution.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/attribution/Attribution.java @@ -1,5 +1,7 @@ package com.mapbox.mapboxsdk.attribution; +import android.support.annotation.Nullable; + public class Attribution { private static final String OPENSTREETMAP = "OpenStreetMap"; @@ -34,7 +36,7 @@ public class Attribution { } @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/attribution/AttributionLayout.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/attribution/AttributionLayout.java index b08a8353be..25d5de7ea6 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/attribution/AttributionLayout.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/attribution/AttributionLayout.java @@ -2,11 +2,14 @@ package com.mapbox.mapboxsdk.attribution; import android.graphics.Bitmap; import android.graphics.PointF; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; public class AttributionLayout { + @Nullable private Bitmap logo; + @Nullable private PointF anchorPoint; private boolean shortText; @@ -16,10 +19,12 @@ public class AttributionLayout { this.shortText = shortText; } + @Nullable public Bitmap getLogo() { return logo; } + @Nullable public PointF getAnchorPoint() { return anchorPoint; } @@ -29,7 +34,7 @@ public class AttributionLayout { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } @@ -52,6 +57,7 @@ public class AttributionLayout { return result; } + @NonNull @Override public String toString() { return "AttributionLayout{" diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/attribution/AttributionMeasure.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/attribution/AttributionMeasure.java index c2408ca718..b40a7be24c 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/attribution/AttributionMeasure.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/attribution/AttributionMeasure.java @@ -2,6 +2,8 @@ package com.mapbox.mapboxsdk.attribution; import android.graphics.Bitmap; import android.graphics.PointF; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.widget.TextView; import java.util.Arrays; @@ -27,6 +29,7 @@ public class AttributionMeasure { this.margin = margin; } + @Nullable public AttributionLayout measure() { Chain chain = new Chain( new FullLogoLongTextCommand(), @@ -45,7 +48,8 @@ public class AttributionMeasure { private static class FullLogoLongTextCommand implements Command { - public AttributionLayout execute(AttributionMeasure measure) { + @Nullable + public AttributionLayout execute(@NonNull AttributionMeasure measure) { float width = measure.getLogoContainerWidth() + measure.getTextViewContainerWidth(); boolean fitBounds = width <= measure.getMaxSize(); if (fitBounds) { @@ -57,8 +61,9 @@ public class AttributionMeasure { } private static class FullLogoShortTextCommand implements Command { + @Nullable @Override - public AttributionLayout execute(AttributionMeasure measure) { + public AttributionLayout execute(@NonNull AttributionMeasure measure) { float width = measure.getLogoContainerWidth() + measure.getTextViewShortContainerWidth(); boolean fitBounds = width <= measure.getMaxSizeShort(); if (fitBounds) { @@ -70,8 +75,9 @@ public class AttributionMeasure { } private static class SmallLogoLongTextCommand implements Command { + @Nullable @Override - public AttributionLayout execute(AttributionMeasure measure) { + public AttributionLayout execute(@NonNull AttributionMeasure measure) { float width = measure.getLogoSmallContainerWidth() + measure.getTextViewContainerWidth(); boolean fitBounds = width <= measure.getMaxSize(); if (fitBounds) { @@ -83,8 +89,9 @@ public class AttributionMeasure { } private static class SmallLogoShortTextCommand implements Command { + @Nullable @Override - public AttributionLayout execute(AttributionMeasure measure) { + public AttributionLayout execute(@NonNull AttributionMeasure measure) { float width = measure.getLogoContainerWidth() + measure.getTextViewShortContainerWidth(); boolean fitBounds = width <= measure.getMaxSizeShort(); if (fitBounds) { @@ -96,8 +103,9 @@ public class AttributionMeasure { } private static class LongTextCommand implements Command { + @Nullable @Override - public AttributionLayout execute(AttributionMeasure measure) { + public AttributionLayout execute(@NonNull AttributionMeasure measure) { float width = measure.getTextViewContainerWidth() + measure.margin; boolean fitBounds = width <= measure.getMaxSize(); if (fitBounds) { @@ -108,8 +116,9 @@ public class AttributionMeasure { } private static class ShortTextCommand implements Command { + @Nullable @Override - public AttributionLayout execute(AttributionMeasure measure) { + public AttributionLayout execute(@NonNull AttributionMeasure measure) { float width = measure.getTextViewShortContainerWidth() + measure.margin; boolean fitBounds = width <= measure.getMaxSizeShort(); if (fitBounds) { @@ -121,6 +130,7 @@ public class AttributionMeasure { } private static class NoTextCommand implements Command { + @NonNull @Override public AttributionLayout execute(AttributionMeasure measure) { return new AttributionLayout(null, null, false); @@ -145,6 +155,7 @@ public class AttributionMeasure { this.commands = Arrays.asList(commands); } + @Nullable public AttributionLayout start(AttributionMeasure measure) { AttributionLayout attributionLayout = null; for (Command command : commands) { @@ -158,6 +169,7 @@ public class AttributionMeasure { } public interface Command { + @Nullable AttributionLayout execute(AttributionMeasure measure); } @@ -193,36 +205,43 @@ public class AttributionMeasure { private TextView textViewShort; private float marginPadding; + @NonNull public Builder setSnapshot(Bitmap snapshot) { this.snapshot = snapshot; return this; } + @NonNull public Builder setLogo(Bitmap logo) { this.logo = logo; return this; } + @NonNull public Builder setLogoSmall(Bitmap logoSmall) { this.logoSmall = logoSmall; return this; } + @NonNull public Builder setTextView(TextView textView) { this.textView = textView; return this; } + @NonNull public Builder setTextViewShort(TextView textViewShort) { this.textViewShort = textViewShort; return this; } + @NonNull public Builder setMarginPadding(float marginPadding) { this.marginPadding = marginPadding; return this; } + @NonNull public AttributionMeasure build() { return new AttributionMeasure(snapshot, logo, logoSmall, textView, textViewShort, marginPadding); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/attribution/AttributionParser.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/attribution/AttributionParser.java index ccba0f9300..db45f8b569 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/attribution/AttributionParser.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/attribution/AttributionParser.java @@ -1,6 +1,7 @@ package com.mapbox.mapboxsdk.attribution; import android.content.Context; +import android.support.annotation.NonNull; import android.text.Html; import android.text.SpannableStringBuilder; import android.text.Spanned; @@ -44,6 +45,7 @@ public class AttributionParser { * * @return the attributions */ + @NonNull public Set<Attribution> getAttributions() { return attributions; } @@ -53,6 +55,7 @@ public class AttributionParser { * * @return the parsed attribution string */ + @NonNull public String createAttributionString() { return createAttributionString(false); } @@ -63,6 +66,7 @@ public class AttributionParser { * @param shortenedOutput if attribution string should contain shortened output * @return the parsed attribution string */ + @NonNull public String createAttributionString(boolean shortenedOutput) { StringBuilder stringBuilder = new StringBuilder(withCopyrightSign ? "" : "© "); int counter = 0; @@ -101,7 +105,7 @@ public class AttributionParser { * @param htmlBuilder the html builder * @param urlSpan the url span to be parsed */ - private void parseUrlSpan(SpannableStringBuilder htmlBuilder, URLSpan urlSpan) { + private void parseUrlSpan(@NonNull SpannableStringBuilder htmlBuilder, URLSpan urlSpan) { String url = urlSpan.getURL(); if (isUrlValid(url)) { String anchor = parseAnchorValue(htmlBuilder, urlSpan); @@ -118,7 +122,7 @@ public class AttributionParser { * @param url the url to be validated * @return if the url is valid */ - private boolean isUrlValid(String url) { + private boolean isUrlValid(@NonNull String url) { return isValidForImproveThisMap(url) && isValidForMapbox(url); } @@ -152,7 +156,7 @@ public class AttributionParser { * @param url the url to be validated * @return if the url is valid for improve this map */ - private boolean isValidForImproveThisMap(String url) { + private boolean isValidForImproveThisMap(@NonNull String url) { return withImproveMap || !url.equals(Attribution.IMPROVE_MAP_URL); } @@ -162,7 +166,7 @@ public class AttributionParser { * @param url the url to be validated * @return if the url is valid for Mapbox */ - private boolean isValidForMapbox(String url) { + private boolean isValidForMapbox(@NonNull String url) { return withMapboxAttribution || !url.equals(Attribution.MAPBOX_URL); } @@ -173,6 +177,7 @@ public class AttributionParser { * @param urlSpan the current urlSpan * @return the parsed anchor value */ + @NonNull private String parseAnchorValue(SpannableStringBuilder htmlBuilder, URLSpan urlSpan) { int start = htmlBuilder.getSpanStart(urlSpan); int end = htmlBuilder.getSpanEnd(urlSpan); @@ -188,7 +193,8 @@ public class AttributionParser { * @param anchor the attribution string to strip * @return the stripped attribution string without the copyright sign */ - private String stripCopyright(String anchor) { + @NonNull + private String stripCopyright(@NonNull String anchor) { if (!withCopyrightSign && anchor.startsWith("© ")) { anchor = anchor.substring(2, anchor.length()); } @@ -242,36 +248,43 @@ public class AttributionParser { private boolean withMapboxAttribution = true; private String[] attributionDataStringArray; + @NonNull public Options withAttributionData(String... attributionData) { this.attributionDataStringArray = attributionData; return this; } + @NonNull public Options withImproveMap(boolean withImproveMap) { this.withImproveMap = withImproveMap; return this; } + @NonNull public Options withCopyrightSign(boolean withCopyrightSign) { this.withCopyrightSign = withCopyrightSign; return this; } + @NonNull public Options withTelemetryAttribution(boolean withTelemetryAttribution) { this.withTelemetryAttribution = withTelemetryAttribution; return this; } + @NonNull public Options withMapboxAttribution(boolean withMapboxAttribution) { this.withMapboxAttribution = withMapboxAttribution; return this; } + @NonNull public Options withContext(Context context) { this.context = new WeakReference<>(context); return this; } + @NonNull public AttributionParser build() { if (attributionDataStringArray == null) { throw new IllegalStateException("Using builder without providing attribution data"); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraPosition.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraPosition.java index 7375abc359..f44c0f1904 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraPosition.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraPosition.java @@ -6,6 +6,8 @@ import android.os.Parcelable; import android.support.annotation.FloatRange; import android.support.annotation.Keep; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import com.mapbox.mapboxsdk.R; import com.mapbox.mapboxsdk.constants.MapboxConstants; import com.mapbox.mapboxsdk.geometry.LatLng; @@ -125,7 +127,7 @@ public final class CameraPosition implements Parcelable { * Else, false. */ @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } @@ -168,6 +170,7 @@ public final class CameraPosition implements Parcelable { public static final class Builder { private double bearing = -1; + @Nullable private LatLng target = null; private double tilt = -1; private double zoom = -1; @@ -184,7 +187,7 @@ public final class CameraPosition implements Parcelable { * * @param previous Existing CameraPosition values to use */ - public Builder(CameraPosition previous) { + public Builder(@Nullable CameraPosition previous) { super(); if (previous != null) { this.bearing = previous.bearing; @@ -199,7 +202,7 @@ public final class CameraPosition implements Parcelable { * * @param typedArray TypedArray containing attribute values */ - public Builder(TypedArray typedArray) { + public Builder(@Nullable TypedArray typedArray) { super(); if (typedArray != null) { this.bearing = typedArray.getFloat(R.styleable.mapbox_MapView_mapbox_cameraBearing, 0.0f); @@ -216,7 +219,7 @@ public final class CameraPosition implements Parcelable { * * @param update Update containing camera options */ - public Builder(CameraUpdateFactory.CameraPositionUpdate update) { + public Builder(@Nullable CameraUpdateFactory.CameraPositionUpdate update) { super(); if (update != null) { bearing = update.getBearing(); @@ -231,7 +234,7 @@ public final class CameraPosition implements Parcelable { * * @param update Update containing camera options */ - public Builder(CameraUpdateFactory.ZoomUpdate update) { + public Builder(@Nullable CameraUpdateFactory.ZoomUpdate update) { super(); if (update != null) { this.zoom = update.getZoom(); @@ -244,6 +247,7 @@ public final class CameraPosition implements Parcelable { * @param bearing Bearing * @return this */ + @NonNull public Builder bearing(double bearing) { double direction = bearing; @@ -264,6 +268,7 @@ public final class CameraPosition implements Parcelable { * @param location target of the camera * @return this */ + @NonNull public Builder target(LatLng location) { this.target = location; return this; @@ -278,6 +283,7 @@ public final class CameraPosition implements Parcelable { * @param tilt Tilt value of the camera * @return this */ + @NonNull public Builder tilt(@FloatRange(from = MapboxConstants.MINIMUM_TILT, to = MapboxConstants.MAXIMUM_TILT) double tilt) { this.tilt = MathUtils.clamp(tilt, MapboxConstants.MINIMUM_TILT, MapboxConstants.MAXIMUM_TILT); @@ -293,6 +299,7 @@ public final class CameraPosition implements Parcelable { * @param zoom Zoom value of the camera * @return this */ + @NonNull public Builder zoom(@FloatRange(from = MapboxConstants.MINIMUM_ZOOM, to = MapboxConstants.MAXIMUM_ZOOM) double zoom) { this.zoom = zoom; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLng.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLng.java index 57c83daf18..2ea8ef6030 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLng.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLng.java @@ -6,6 +6,8 @@ import android.os.Parcelable; import android.support.annotation.FloatRange; import android.support.annotation.Keep; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import com.mapbox.mapboxsdk.constants.GeometryConstants; @@ -27,7 +29,7 @@ public class LatLng implements ILatLng, Parcelable { * Inner class responsible for recreating Parcels into objects. */ public static final Parcelable.Creator<LatLng> CREATOR = new Parcelable.Creator<LatLng>() { - public LatLng createFromParcel(Parcel in) { + public LatLng createFromParcel(@NonNull Parcel in) { return new LatLng(in); } @@ -207,6 +209,7 @@ public class LatLng implements ILatLng, Parcelable { * * @return new LatLng object with wrapped Longitude */ + @NonNull public LatLng wrap() { return new LatLng(latitude, wrap(longitude, GeometryConstants.MIN_LONGITUDE, GeometryConstants.MAX_LONGITUDE)); } @@ -244,7 +247,7 @@ public class LatLng implements ILatLng, Parcelable { * @return True if equal, false if not */ @Override - public boolean equals(Object object) { + public boolean equals(@Nullable Object object) { if (this == object) { return true; } @@ -281,6 +284,7 @@ public class LatLng implements ILatLng, Parcelable { * * @return the string representation */ + @NonNull @Override public String toString() { return "LatLng [latitude=" + latitude + ", longitude=" + longitude + ", altitude=" + altitude + "]"; @@ -303,7 +307,7 @@ public class LatLng implements ILatLng, Parcelable { * @param flags Additional flags about how the object should be written */ @Override - public void writeToParcel(Parcel out, int flags) { + public void writeToParcel(@NonNull Parcel out, int flags) { out.writeDouble(latitude); out.writeDouble(longitude); out.writeDouble(altitude); @@ -315,7 +319,7 @@ public class LatLng implements ILatLng, Parcelable { * @param other Other LatLng to compare to * @return distance in meters */ - public double distanceTo(LatLng other) { + public double distanceTo(@NonNull LatLng other) { if (latitude == other.latitude && longitude == other.longitude) { // return 0.0 to avoid a NaN return 0.0; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java index 8d016131f2..563d6078cb 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java @@ -68,6 +68,7 @@ public class LatLngBounds implements Parcelable { * * @return LatLng center of this LatLngBounds */ + @NonNull public LatLng getCenter() { double latCenter = (this.latitudeNorth + this.latitudeSouth) / 2.0; double longCenter; @@ -126,6 +127,7 @@ public class LatLngBounds implements Parcelable { * * @return LatLng of the south west corner */ + @NonNull public LatLng getSouthWest() { return new LatLng(latitudeSouth, longitudeWest); } @@ -135,6 +137,7 @@ public class LatLngBounds implements Parcelable { * * @return LatLng of the north east corner */ + @NonNull public LatLng getNorthEast() { return new LatLng(latitudeNorth, longitudeEast); } @@ -144,6 +147,7 @@ public class LatLngBounds implements Parcelable { * * @return LatLng of the south east corner */ + @NonNull public LatLng getSouthEast() { return new LatLng(latitudeSouth, longitudeEast); } @@ -153,6 +157,7 @@ public class LatLngBounds implements Parcelable { * * @return LatLng of the north west corner */ + @NonNull public LatLng getNorthWest() { return new LatLng(latitudeNorth, longitudeWest); } @@ -162,6 +167,7 @@ public class LatLngBounds implements Parcelable { * * @return LatLngSpan area */ + @NonNull public LatLngSpan getSpan() { return new LatLngSpan(getLatitudeSpan(), getLongitudeSpan()); } @@ -216,6 +222,7 @@ public class LatLngBounds implements Parcelable { * * @return the string representation */ + @NonNull @Override public String toString() { return "N:" + this.latitudeNorth + "; E:" + this.longitudeEast + "; S:" + this.latitudeSouth @@ -276,6 +283,7 @@ public class LatLngBounds implements Parcelable { * * @return an array of 2 LatLng objects. */ + @NonNull public LatLng[] toLatLngs() { return new LatLng[] {getNorthEast(), getSouthWest()}; } @@ -365,7 +373,8 @@ public class LatLngBounds implements Parcelable { * @param latLng the latitude lognitude pair to include in the bounds. * @return the newly constructed bounds */ - public LatLngBounds include(LatLng latLng) { + @NonNull + public LatLngBounds include(@NonNull LatLng latLng) { return new LatLngBounds.Builder() .include(getNorthEast()) .include(getSouthWest()) @@ -418,7 +427,7 @@ public class LatLngBounds implements Parcelable { * @param latLng the point which may be contained * @return true, if the point is contained within the bounds */ - public boolean contains(final ILatLng latLng) { + public boolean contains(@NonNull final ILatLng latLng) { return containsLatitude(latLng.getLatitude()) && containsLongitude(latLng.getLongitude()); } @@ -429,7 +438,7 @@ public class LatLngBounds implements Parcelable { * @param other the bounds which may be contained * @return true, if the bounds is contained within the bounds */ - public boolean contains(final LatLngBounds other) { + public boolean contains(@NonNull final LatLngBounds other) { return contains(other.getNorthEast()) && contains(other.getSouthWest()); } @@ -629,7 +638,7 @@ public class LatLngBounds implements Parcelable { public static final Parcelable.Creator<LatLngBounds> CREATOR = new Parcelable.Creator<LatLngBounds>() { @Override - public LatLngBounds createFromParcel(final Parcel in) { + public LatLngBounds createFromParcel(@NonNull final Parcel in) { return readFromParcel(in); } @@ -669,7 +678,7 @@ public class LatLngBounds implements Parcelable { * @param flags Additional flags about how the object should be written */ @Override - public void writeToParcel(final Parcel out, final int flags) { + public void writeToParcel(@NonNull final Parcel out, final int flags) { out.writeDouble(this.latitudeNorth); out.writeDouble(this.longitudeEast); out.writeDouble(this.latitudeSouth); @@ -712,7 +721,8 @@ public class LatLngBounds implements Parcelable { * @param latLngs the List of LatLng objects to be added * @return this */ - public Builder includes(List<LatLng> latLngs) { + @NonNull + public Builder includes(@NonNull List<LatLng> latLngs) { latLngList.addAll(latLngs); return this; } @@ -723,6 +733,7 @@ public class LatLngBounds implements Parcelable { * @param latLng the LatLng to be added * @return this */ + @NonNull public Builder include(@NonNull LatLng latLng) { latLngList.add(latLng); return this; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngQuad.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngQuad.java index 9f65ee636b..d17d0d6fe6 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngQuad.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngQuad.java @@ -3,6 +3,7 @@ package com.mapbox.mapboxsdk.geometry; import android.os.Parcel; import android.os.Parcelable; import android.support.annotation.Keep; +import android.support.annotation.NonNull; /** * A geographical area representing a non-aligned quadrilateral @@ -51,7 +52,7 @@ public class LatLngQuad implements Parcelable { public static final Parcelable.Creator<LatLngQuad> CREATOR = new Parcelable.Creator<LatLngQuad>() { @Override - public LatLngQuad createFromParcel(final Parcel in) { + public LatLngQuad createFromParcel(@NonNull final Parcel in) { return readFromParcel(in); } @@ -76,14 +77,14 @@ public class LatLngQuad implements Parcelable { } @Override - public void writeToParcel(final Parcel out, final int arg1) { + public void writeToParcel(@NonNull final Parcel out, final int arg1) { topLeft.writeToParcel(out, arg1); topRight.writeToParcel(out, arg1); bottomRight.writeToParcel(out, arg1); bottomLeft.writeToParcel(out, arg1); } - private static LatLngQuad readFromParcel(final Parcel in) { + private static LatLngQuad readFromParcel(@NonNull final Parcel in) { final LatLng topLeft = new LatLng(in); final LatLng topRight = new LatLng(in); final LatLng bottomRight = new LatLng(in); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngSpan.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngSpan.java index 133949f743..f069d7807f 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngSpan.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngSpan.java @@ -91,7 +91,7 @@ public class LatLngSpan implements Parcelable { public static final Parcelable.Creator<LatLngSpan> CREATOR = new Parcelable.Creator<LatLngSpan>() { @Override - public LatLngSpan createFromParcel(Parcel in) { + public LatLngSpan createFromParcel(@NonNull Parcel in) { return new LatLngSpan(in); } @@ -118,7 +118,7 @@ public class LatLngSpan implements Parcelable { * @param flags Additional flags about how the object should be written */ @Override - public void writeToParcel(Parcel out, int flags) { + public void writeToParcel(@NonNull Parcel out, int flags) { out.writeDouble(mLatitudeSpan); out.writeDouble(mLongitudeSpan); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ProjectedMeters.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ProjectedMeters.java index 7251fd360b..e0db9fbb5d 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ProjectedMeters.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ProjectedMeters.java @@ -3,6 +3,8 @@ package com.mapbox.mapboxsdk.geometry; import android.os.Parcel; import android.os.Parcelable; import android.support.annotation.Keep; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; /** * ProjectedMeters is a projection of longitude, latitude points in Mercator meters. @@ -18,7 +20,7 @@ public class ProjectedMeters implements IProjectedMeters, Parcelable { * Inner class responsible for recreating Parcels into objects. */ public static final Creator<ProjectedMeters> CREATOR = new Creator<ProjectedMeters>() { - public ProjectedMeters createFromParcel(Parcel in) { + public ProjectedMeters createFromParcel(@NonNull Parcel in) { return new ProjectedMeters(in); } @@ -90,7 +92,7 @@ public class ProjectedMeters implements IProjectedMeters, Parcelable { * @return true if equal, false if not */ @Override - public boolean equals(Object other) { + public boolean equals(@Nullable Object other) { if (this == other) { return true; } @@ -125,6 +127,7 @@ public class ProjectedMeters implements IProjectedMeters, Parcelable { * * @return the string representation of this */ + @NonNull @Override public String toString() { return "ProjectedMeters [northing=" + northing + ", easting=" + easting + "]"; @@ -147,7 +150,7 @@ public class ProjectedMeters implements IProjectedMeters, Parcelable { * @param flags Additional flags about how the object should be written */ @Override - public void writeToParcel(Parcel out, int flags) { + public void writeToParcel(@NonNull Parcel out, int flags) { out.writeDouble(northing); out.writeDouble(easting); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/VisibleRegion.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/VisibleRegion.java index c09c00fced..a8b4421eec 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/VisibleRegion.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/VisibleRegion.java @@ -2,6 +2,7 @@ package com.mapbox.mapboxsdk.geometry; import android.os.Parcel; import android.os.Parcelable; +import android.support.annotation.NonNull; /** * Contains the four points defining the four-sided polygon that is visible in a map's camera. @@ -98,6 +99,7 @@ public class VisibleRegion implements Parcelable { * * @return the string representation of this */ + @NonNull @Override public String toString() { return "[farLeft [" + farLeft + "], farRight [" + farRight + "], nearLeft [" + nearLeft + "], nearRight [" @@ -134,7 +136,7 @@ public class VisibleRegion implements Parcelable { * @param flags Additional flags about how the object should be written */ @Override - public void writeToParcel(Parcel out, int flags) { + public void writeToParcel(@NonNull Parcel out, int flags) { out.writeParcelable(farLeft, flags); out.writeParcelable(farRight, flags); out.writeParcelable(nearLeft, flags); @@ -147,7 +149,7 @@ public class VisibleRegion implements Parcelable { */ public static final Parcelable.Creator<VisibleRegion> CREATOR = new Parcelable.Creator<VisibleRegion>() { - public VisibleRegion createFromParcel(Parcel in) { + public VisibleRegion createFromParcel(@NonNull Parcel in) { return new VisibleRegion(in); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HttpRequestUrl.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HttpRequestUrl.java index fde8ae4a5d..37e3869692 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HttpRequestUrl.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HttpRequestUrl.java @@ -1,5 +1,7 @@ package com.mapbox.mapboxsdk.http; +import android.support.annotation.NonNull; + public class HttpRequestUrl { private HttpRequestUrl() { @@ -13,7 +15,7 @@ public class HttpRequestUrl { * @param querySize the query size of the resource request * @return the adapted resource url */ - public static String buildResourceUrl(String host, String resourceUrl, int querySize) { + public static String buildResourceUrl(@NonNull String host, String resourceUrl, int querySize) { if (isValidMapboxEndpoint(host)) { if (querySize == 0) { resourceUrl = resourceUrl + "?"; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/LocalRequestTask.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/LocalRequestTask.java index 7884033de7..fc98a38319 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/LocalRequestTask.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/LocalRequestTask.java @@ -3,6 +3,8 @@ package com.mapbox.mapboxsdk.http; import android.content.res.AssetManager; import android.os.AsyncTask; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import com.mapbox.mapboxsdk.MapStrictMode; import com.mapbox.mapboxsdk.Mapbox; import com.mapbox.mapboxsdk.log.Logger; @@ -20,6 +22,7 @@ class LocalRequestTask extends AsyncTask<String, Void, byte[]> { this.requestResponse = requestResponse; } + @Nullable @Override protected byte[] doInBackground(String... strings) { return loadFile(Mapbox.getApplicationContext().getAssets(), @@ -30,14 +33,15 @@ class LocalRequestTask extends AsyncTask<String, Void, byte[]> { } @Override - protected void onPostExecute(byte[] bytes) { + protected void onPostExecute(@Nullable byte[] bytes) { super.onPostExecute(bytes); if (bytes != null && requestResponse != null) { requestResponse.onResponse(bytes); } } - private static byte[] loadFile(AssetManager assets, String path) { + @Nullable + private static byte[] loadFile(AssetManager assets, @NonNull String path) { byte[] buffer = null; try (InputStream input = assets.open(path)) { int size = input.available(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/CameraCompassBearingAnimator.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/CameraCompassBearingAnimator.java index ea1817ab5e..4bb20ba5a0 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/CameraCompassBearingAnimator.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/CameraCompassBearingAnimator.java @@ -1,6 +1,7 @@ package com.mapbox.mapboxsdk.location; import android.animation.ValueAnimator; +import android.support.annotation.NonNull; import java.util.List; @@ -16,7 +17,7 @@ class CameraCompassBearingAnimator extends MapboxFloatAnimator<MapboxAnimator.On } @Override - public void onAnimationUpdate(ValueAnimator animation) { + public void onAnimationUpdate(@NonNull ValueAnimator animation) { for (OnCameraAnimationsValuesChangeListener listener : updateListeners) { listener.onNewCompassBearingValue((Float) animation.getAnimatedValue()); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/CameraGpsBearingAnimator.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/CameraGpsBearingAnimator.java index f46cf805ff..bd8e153d6e 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/CameraGpsBearingAnimator.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/CameraGpsBearingAnimator.java @@ -1,6 +1,7 @@ package com.mapbox.mapboxsdk.location; import android.animation.ValueAnimator; +import android.support.annotation.NonNull; import java.util.List; @@ -15,7 +16,7 @@ class CameraGpsBearingAnimator extends MapboxFloatAnimator<MapboxAnimator.OnCame } @Override - public void onAnimationUpdate(ValueAnimator animation) { + public void onAnimationUpdate(@NonNull ValueAnimator animation) { for (OnCameraAnimationsValuesChangeListener listener : updateListeners) { listener.onNewGpsBearingValue((Float) animation.getAnimatedValue()); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/CameraLatLngAnimator.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/CameraLatLngAnimator.java index 533abfc335..8e515b85c8 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/CameraLatLngAnimator.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/CameraLatLngAnimator.java @@ -2,6 +2,7 @@ package com.mapbox.mapboxsdk.location; import android.animation.ValueAnimator; +import android.support.annotation.NonNull; import com.mapbox.mapboxsdk.geometry.LatLng; import java.util.List; @@ -17,7 +18,7 @@ class CameraLatLngAnimator extends MapboxLatLngAnimator<MapboxAnimator.OnCameraA } @Override - public void onAnimationUpdate(ValueAnimator animation) { + public void onAnimationUpdate(@NonNull ValueAnimator animation) { for (OnCameraAnimationsValuesChangeListener listener : updateListeners) { listener.onNewLatLngValue((LatLng) animation.getAnimatedValue()); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LatLngEvaluator.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LatLngEvaluator.java index fa966641fd..c631b1b75d 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LatLngEvaluator.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LatLngEvaluator.java @@ -2,14 +2,16 @@ package com.mapbox.mapboxsdk.location; import android.animation.TypeEvaluator; +import android.support.annotation.NonNull; import com.mapbox.mapboxsdk.geometry.LatLng; class LatLngEvaluator implements TypeEvaluator<LatLng> { private final LatLng latLng = new LatLng(); + @NonNull @Override - public LatLng evaluate(float fraction, LatLng startValue, LatLng endValue) { + public LatLng evaluate(float fraction, @NonNull LatLng startValue, @NonNull LatLng endValue) { latLng.setLatitude(startValue.getLatitude() + ((endValue.getLatitude() - startValue.getLatitude()) * fraction)); latLng.setLongitude(startValue.getLongitude() diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LayerAccuracyAnimator.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LayerAccuracyAnimator.java index e893f0fee9..90ed9a0603 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LayerAccuracyAnimator.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LayerAccuracyAnimator.java @@ -1,6 +1,7 @@ package com.mapbox.mapboxsdk.location; import android.animation.ValueAnimator; +import android.support.annotation.NonNull; import java.util.List; @@ -16,7 +17,7 @@ class LayerAccuracyAnimator extends MapboxFloatAnimator<MapboxAnimator.OnLayerAn } @Override - public void onAnimationUpdate(ValueAnimator animation) { + public void onAnimationUpdate(@NonNull ValueAnimator animation) { for (OnLayerAnimationsValuesChangeListener listener : updateListeners) { listener.onNewAccuracyRadiusValue((Float) animation.getAnimatedValue()); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LayerBitmapProvider.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LayerBitmapProvider.java index 6c9f063c18..4e25a082b9 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LayerBitmapProvider.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LayerBitmapProvider.java @@ -5,6 +5,7 @@ import android.graphics.Bitmap; import android.graphics.drawable.Drawable; import android.support.annotation.ColorInt; import android.support.annotation.DrawableRes; +import android.support.annotation.NonNull; import android.support.v4.content.ContextCompat; import com.mapbox.mapboxsdk.R; @@ -26,7 +27,7 @@ class LayerBitmapProvider { return getBitmapFromDrawable(drawable); } - Bitmap generateShadowBitmap(LocationComponentOptions options) { + Bitmap generateShadowBitmap(@NonNull LocationComponentOptions options) { Drawable shadowDrawable = ContextCompat.getDrawable(context, R.drawable.mapbox_user_icon_shadow); return generateShadow(shadowDrawable, options.elevation()); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LayerCompassBearingAnimator.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LayerCompassBearingAnimator.java index e75eaca2b5..3b06e0e174 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LayerCompassBearingAnimator.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LayerCompassBearingAnimator.java @@ -1,6 +1,7 @@ package com.mapbox.mapboxsdk.location; import android.animation.ValueAnimator; +import android.support.annotation.NonNull; import java.util.List; @@ -16,7 +17,7 @@ class LayerCompassBearingAnimator extends MapboxFloatAnimator<MapboxAnimator.OnL } @Override - public void onAnimationUpdate(ValueAnimator animation) { + public void onAnimationUpdate(@NonNull ValueAnimator animation) { for (OnLayerAnimationsValuesChangeListener listener : updateListeners) { listener.onNewCompassBearingValue((Float) animation.getAnimatedValue()); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LayerFeatureProvider.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LayerFeatureProvider.java index 0be38dc4db..faa83ea0e9 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LayerFeatureProvider.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LayerFeatureProvider.java @@ -13,7 +13,7 @@ import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_ class LayerFeatureProvider { @NonNull - Feature generateLocationFeature(@Nullable Feature locationFeature, LocationComponentOptions options) { + Feature generateLocationFeature(@Nullable Feature locationFeature, @NonNull LocationComponentOptions options) { if (locationFeature != null) { return locationFeature; } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LayerGpsBearingAnimator.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LayerGpsBearingAnimator.java index 75cea13750..6301f31ee5 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LayerGpsBearingAnimator.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LayerGpsBearingAnimator.java @@ -1,6 +1,7 @@ package com.mapbox.mapboxsdk.location; import android.animation.ValueAnimator; +import android.support.annotation.NonNull; import java.util.List; @@ -15,7 +16,7 @@ class LayerGpsBearingAnimator extends MapboxFloatAnimator<MapboxAnimator.OnLayer } @Override - public void onAnimationUpdate(ValueAnimator animation) { + public void onAnimationUpdate(@NonNull ValueAnimator animation) { for (OnLayerAnimationsValuesChangeListener listener : updateListeners) { listener.onNewGpsBearingValue((Float) animation.getAnimatedValue()); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LayerLatLngAnimator.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LayerLatLngAnimator.java index f4dc2861cf..6bfec87430 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LayerLatLngAnimator.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LayerLatLngAnimator.java @@ -2,6 +2,7 @@ package com.mapbox.mapboxsdk.location; import android.animation.ValueAnimator; +import android.support.annotation.NonNull; import com.mapbox.mapboxsdk.geometry.LatLng; import java.util.List; @@ -17,7 +18,7 @@ class LayerLatLngAnimator extends MapboxLatLngAnimator<MapboxAnimator.OnLayerAni } @Override - public void onAnimationUpdate(ValueAnimator animation) { + public void onAnimationUpdate(@NonNull ValueAnimator animation) { for (OnLayerAnimationsValuesChangeListener listener : updateListeners) { listener.onNewLatLngValue((LatLng) animation.getAnimatedValue()); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LayerSourceProvider.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LayerSourceProvider.java index d6198a7da8..cac513c2f9 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LayerSourceProvider.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LayerSourceProvider.java @@ -1,5 +1,6 @@ package com.mapbox.mapboxsdk.location; +import android.support.annotation.NonNull; import com.mapbox.geojson.Feature; import com.mapbox.mapboxsdk.style.layers.CircleLayer; import com.mapbox.mapboxsdk.style.layers.Layer; @@ -50,6 +51,7 @@ class LayerSourceProvider { private static final String EMPTY_STRING = ""; + @NonNull GeoJsonSource generateSource(Feature locationFeature) { return new GeoJsonSource( LOCATION_SOURCE, @@ -58,7 +60,8 @@ class LayerSourceProvider { ); } - Layer generateLayer(String layerId) { + @NonNull + Layer generateLayer(@NonNull String layerId) { SymbolLayer layer = new SymbolLayer(layerId, LOCATION_SOURCE); layer.setProperties( iconAllowOverlap(true), @@ -94,6 +97,7 @@ class LayerSourceProvider { return layer; } + @NonNull Layer generateAccuracyLayer() { return new CircleLayer(ACCURACY_LAYER, LOCATION_SOURCE) .withProperties( diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationAnimatorCoordinator.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationAnimatorCoordinator.java index 0a6c9b5ddc..fd8537f23f 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationAnimatorCoordinator.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationAnimatorCoordinator.java @@ -295,18 +295,18 @@ final class LocationAnimatorCoordinator { locationAnimatorSet.start(); } - void resetAllCameraAnimations(CameraPosition currentCameraPosition, boolean isGpsNorth) { + void resetAllCameraAnimations(@NonNull CameraPosition currentCameraPosition, boolean isGpsNorth) { resetCameraCompassAnimation(currentCameraPosition); boolean snap = resetCameraLocationAnimations(currentCameraPosition, isGpsNorth); playCameraLocationAnimators(snap ? 0 : TRANSITION_ANIMATION_DURATION_MS); } - private boolean resetCameraLocationAnimations(CameraPosition currentCameraPosition, boolean isGpsNorth) { + private boolean resetCameraLocationAnimations(@NonNull CameraPosition currentCameraPosition, boolean isGpsNorth) { resetCameraGpsBearingAnimation(currentCameraPosition, isGpsNorth); return resetCameraLatLngAnimation(currentCameraPosition); } - private boolean resetCameraLatLngAnimation(CameraPosition currentCameraPosition) { + private boolean resetCameraLatLngAnimation(@NonNull CameraPosition currentCameraPosition) { CameraLatLngAnimator animator = (CameraLatLngAnimator) animatorArray.get(ANIMATOR_CAMERA_LATLNG); if (animator == null) { return false; @@ -320,7 +320,7 @@ final class LocationAnimatorCoordinator { return immediateAnimation(previousCameraTarget, currentTarget, currentCameraPosition.zoom); } - private void resetCameraGpsBearingAnimation(CameraPosition currentCameraPosition, boolean isGpsNorth) { + private void resetCameraGpsBearingAnimation(@NonNull CameraPosition currentCameraPosition, boolean isGpsNorth) { CameraGpsBearingAnimator animator = (CameraGpsBearingAnimator) animatorArray.get(ANIMATOR_CAMERA_GPS_BEARING); if (animator == null) { return; @@ -334,7 +334,7 @@ final class LocationAnimatorCoordinator { new CameraGpsBearingAnimator(previousCameraBearing, normalizedCameraBearing, cameraListeners)); } - private void resetCameraCompassAnimation(CameraPosition currentCameraPosition) { + private void resetCameraCompassAnimation(@NonNull CameraPosition currentCameraPosition) { CameraCompassBearingAnimator animator = (CameraCompassBearingAnimator) animatorArray.get(ANIMATOR_CAMERA_COMPASS_BEARING); if (animator == null) { @@ -382,7 +382,7 @@ final class LocationAnimatorCoordinator { this.durationMultiplier = trackingAnimationDurationMultiplier; } - private boolean immediateAnimation(LatLng current, LatLng target, double zoom) { + private boolean immediateAnimation(LatLng current, @NonNull LatLng target, double zoom) { // TODO: calculate the value based on the projection double distance = current.distanceTo(target); if (zoom > 10) { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationCameraController.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationCameraController.java index e3194df009..7a20ca8177 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationCameraController.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationCameraController.java @@ -3,6 +3,7 @@ package com.mapbox.mapboxsdk.location; import android.content.Context; import android.graphics.PointF; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import android.view.MotionEvent; @@ -34,7 +35,7 @@ final class LocationCameraController implements MapboxAnimator.OnCameraAnimation Context context, MapboxMap mapboxMap, OnCameraTrackingChangedListener internalCameraTrackingChangedListener, - LocationComponentOptions options, + @NonNull LocationComponentOptions options, OnCameraMoveInvalidateListener onCameraMoveInvalidateListener) { this.mapboxMap = mapboxMap; @@ -92,7 +93,7 @@ final class LocationCameraController implements MapboxAnimator.OnCameraAnimation onCameraMoveInvalidateListener.onInvalidateCameraMove(); } - private void setLatLng(LatLng latLng) { + private void setLatLng(@NonNull LatLng latLng) { mapboxMap.moveCamera(CameraUpdateFactory.newLatLng(latLng)); onCameraMoveInvalidateListener.onInvalidateCameraMove(); } @@ -108,7 +109,7 @@ final class LocationCameraController implements MapboxAnimator.OnCameraAnimation } @Override - public void onNewLatLngValue(LatLng latLng) { + public void onNewLatLngValue(@NonNull LatLng latLng) { if (cameraMode == CameraMode.TRACKING || cameraMode == CameraMode.TRACKING_COMPASS || cameraMode == CameraMode.TRACKING_GPS @@ -187,6 +188,7 @@ final class LocationCameraController implements MapboxAnimator.OnCameraAnimation } } + @NonNull @VisibleForTesting MapboxMap.OnMoveListener onMoveListener = new MapboxMap.OnMoveListener() { private boolean interrupt; @@ -226,6 +228,7 @@ final class LocationCameraController implements MapboxAnimator.OnCameraAnimation } }; + @NonNull private MapboxMap.OnRotateListener onRotateListener = new MapboxMap.OnRotateListener() { @Override public void onRotateBegin(@NonNull RotateGestureDetector detector) { @@ -245,6 +248,7 @@ final class LocationCameraController implements MapboxAnimator.OnCameraAnimation } }; + @NonNull private MapboxMap.OnFlingListener onFlingListener = new MapboxMap.OnFlingListener() { @Override public void onFling() { @@ -259,7 +263,7 @@ final class LocationCameraController implements MapboxAnimator.OnCameraAnimation } @Override - public boolean onTouchEvent(MotionEvent motionEvent) { + public boolean onTouchEvent(@Nullable MotionEvent motionEvent) { if (motionEvent != null) { int action = motionEvent.getActionMasked(); if (action == MotionEvent.ACTION_UP) { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponent.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponent.java index af48b5c4d4..d8ebf1b510 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponent.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponent.java @@ -75,9 +75,12 @@ import static com.mapbox.mapboxsdk.location.LocationComponentConstants.DEFAULT_T public final class LocationComponent { private static final String TAG = "Mbgl-LocationComponent"; + @NonNull private final MapboxMap mapboxMap; private LocationComponentOptions options; + @Nullable private LocationEngine locationEngine; + @Nullable private CompassEngine compassEngine; private boolean usingInternalLocationEngine; @@ -90,6 +93,7 @@ public final class LocationComponent { * Holds last location which is being returned in the {@link #getLastKnownLocation()} * when there is no {@link #locationEngine} set or when the last location returned by the engine is null. */ + @Nullable private Location lastLocation; private CameraPosition lastCameraPosition; @@ -339,7 +343,7 @@ public final class LocationComponent { * * @param options to update the current style */ - public void applyStyle(LocationComponentOptions options) { + public void applyStyle(@NonNull LocationComponentOptions options) { this.options = options; locationLayerController.applyStyle(options); locationCameraController.initializeOptions(options); @@ -831,7 +835,7 @@ public final class LocationComponent { * * @param location the latest user location */ - private void updateLocation(final Location location, boolean fromLastLocation) { + private void updateLocation(@Nullable final Location location, boolean fromLastLocation) { if (location == null) { return; } else if (!isLayerReady) { @@ -902,6 +906,7 @@ public final class LocationComponent { locationAnimatorCoordinator.feedNewAccuracyRadius(Utils.calculateZoomLevelRadius(mapboxMap, location), noAnimation); } + @NonNull private OnCameraMoveListener onCameraMoveListener = new OnCameraMoveListener() { @Override public void onCameraMove() { @@ -909,6 +914,7 @@ public final class LocationComponent { } }; + @NonNull private OnCameraIdleListener onCameraIdleListener = new OnCameraIdleListener() { @Override public void onCameraIdle() { @@ -916,6 +922,7 @@ public final class LocationComponent { } }; + @NonNull private OnMapClickListener onMapClickListener = new OnMapClickListener() { @Override public void onMapClick(@NonNull LatLng point) { @@ -927,6 +934,7 @@ public final class LocationComponent { } }; + @NonNull private MapboxMap.OnMapLongClickListener onMapLongClickListener = new MapboxMap.OnMapLongClickListener() { @Override public void onMapLongClick(@NonNull LatLng point) { @@ -938,6 +946,7 @@ public final class LocationComponent { } }; + @NonNull private OnLocationStaleListener onLocationStaleListener = new OnLocationStaleListener() { @Override public void onStaleStateChange(boolean isStale) { @@ -949,6 +958,7 @@ public final class LocationComponent { } }; + @NonNull private OnCameraMoveInvalidateListener onCameraMoveInvalidateListener = new OnCameraMoveInvalidateListener() { @Override public void onInvalidateCameraMove() { @@ -956,6 +966,7 @@ public final class LocationComponent { } }; + @NonNull private CompassListener compassListener = new CompassListener() { @Override public void onCompassChanged(float userHeading) { @@ -968,6 +979,7 @@ public final class LocationComponent { } }; + @NonNull private LocationEngineListener locationEngineListener = new LocationEngineListener() { @Override @SuppressWarnings( {"MissingPermission"}) @@ -983,6 +995,7 @@ public final class LocationComponent { } }; + @NonNull private OnCameraTrackingChangedListener cameraTrackingChangedListener = new OnCameraTrackingChangedListener() { @Override public void onCameraTrackingDismissed() { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponentCompassEngine.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponentCompassEngine.java index b53d909de3..b47f8d7afb 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponentCompassEngine.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponentCompassEngine.java @@ -31,6 +31,7 @@ class LocationComponentCompassEngine implements CompassEngine, SensorEventListen private static final float ALPHA = 0.45f; private final WindowManager windowManager; + @NonNull private final SensorManager sensorManager; private final List<CompassListener> compassListeners = new ArrayList<>(); @@ -42,14 +43,18 @@ class LocationComponentCompassEngine implements CompassEngine, SensorEventListen @Nullable private Sensor magneticFieldSensor; + @NonNull private float[] truncatedRotationVectorValue = new float[4]; + @NonNull private float[] rotationMatrix = new float[9]; private float[] rotationVectorValue; private float lastHeading; private int lastAccuracySensorStatus; private long compassUpdateNextTimestamp; + @Nullable private float[] gravityValues = new float[3]; + @Nullable private float[] magneticValues = new float[3]; /** @@ -109,7 +114,7 @@ class LocationComponentCompassEngine implements CompassEngine, SensorEventListen } @Override - public void onSensorChanged(SensorEvent event) { + public void onSensorChanged(@NonNull SensorEvent event) { // check when the last time the compass was updated, return if too soon. long currentTime = SystemClock.elapsedRealtime(); if (currentTime < compassUpdateNextTimestamp) { @@ -233,7 +238,8 @@ class LocationComponentCompassEngine implements CompassEngine, SensorEventListen * @param smoothedValues array of float, that contains previous state * @return float filtered array of float */ - private float[] lowPassFilter(float[] newValues, float[] smoothedValues) { + @Nullable + private float[] lowPassFilter(@NonNull float[] newValues, @Nullable float[] smoothedValues) { if (smoothedValues == null) { return newValues; } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponentOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponentOptions.java index 10dfff8694..f202d6267d 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponentOptions.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponentOptions.java @@ -82,25 +82,37 @@ public class LocationComponentOptions implements Parcelable { private float accuracyAlpha; private int accuracyColor; private int backgroundDrawableStale; + @Nullable private String backgroundStaleName; private int foregroundDrawableStale; + @Nullable private String foregroundStaleName; private int gpsDrawable; + @Nullable private String gpsName; private int foregroundDrawable; + @Nullable private String foregroundName; private int backgroundDrawable; + @Nullable private String backgroundName; private int bearingDrawable; + @Nullable private String bearingName; + @Nullable private Integer bearingTintColor; + @Nullable private Integer foregroundTintColor; + @Nullable private Integer backgroundTintColor; + @Nullable private Integer foregroundStaleTintColor; + @Nullable private Integer backgroundStaleTintColor; private float elevation; private boolean enableStaleState; private long staleStateTimeout; + @Nullable private int[] padding; private double maxZoom; private double minZoom; @@ -135,7 +147,7 @@ public class LocationComponentOptions implements Parcelable { float elevation, boolean enableStaleState, long staleStateTimeout, - int[] padding, + @Nullable int[] padding, double maxZoom, double minZoom, float maxZoomIconScale, @@ -192,6 +204,7 @@ public class LocationComponentOptions implements Parcelable { * @return a new {@link LocationComponentOptions} object with the settings you defined in your style * resource */ + @Nullable public static LocationComponentOptions createFromAttributes(@NonNull Context context, @StyleRes int styleRes) { @@ -316,6 +329,7 @@ public class LocationComponentOptions implements Parcelable { * * @return the builder which contains the values defined in this current instance as defaults. */ + @NonNull public Builder toBuilder() { return new Builder(this); } @@ -328,7 +342,8 @@ public class LocationComponentOptions implements Parcelable { * @param context your activities context used to acquire the style resource * @return the builder which contains the default values defined by the style resource */ - public static Builder builder(Context context) { + @NonNull + public static Builder builder(@NonNull Context context) { return LocationComponentOptions.createFromAttributes(context, R.style.mapbox_LocationComponent).toBuilder(); } @@ -626,6 +641,7 @@ public class LocationComponentOptions implements Parcelable { * * @return integer array of padding values */ + @Nullable @SuppressWarnings("mutable") public int[] padding() { return padding; @@ -723,6 +739,7 @@ public class LocationComponentOptions implements Parcelable { return trackingAnimationDurationMultiplier; } + @NonNull @Override public String toString() { return "LocationComponentOptions{" @@ -932,7 +949,7 @@ public class LocationComponentOptions implements Parcelable { }; @Override - public void writeToParcel(Parcel dest, int flags) { + public void writeToParcel(@NonNull Parcel dest, int flags) { dest.writeFloat(accuracyAlpha()); dest.writeInt(accuracyColor()); dest.writeInt(backgroundDrawableStale()); @@ -1055,25 +1072,37 @@ public class LocationComponentOptions implements Parcelable { private Float accuracyAlpha; private Integer accuracyColor; private Integer backgroundDrawableStale; + @Nullable private String backgroundStaleName; private Integer foregroundDrawableStale; + @Nullable private String foregroundStaleName; private Integer gpsDrawable; + @Nullable private String gpsName; private Integer foregroundDrawable; + @Nullable private String foregroundName; private Integer backgroundDrawable; + @Nullable private String backgroundName; private Integer bearingDrawable; + @Nullable private String bearingName; + @Nullable private Integer bearingTintColor; + @Nullable private Integer foregroundTintColor; + @Nullable private Integer backgroundTintColor; + @Nullable private Integer foregroundStaleTintColor; + @Nullable private Integer backgroundStaleTintColor; private Float elevation; private Boolean enableStaleState; private Long staleStateTimeout; + @Nullable private int[] padding; private Double maxZoom; private Double minZoom; @@ -1131,6 +1160,7 @@ public class LocationComponentOptions implements Parcelable { * @return this builder for chaining options together * @attr ref R.styleable#LocationComponent_accuracyAlpha */ + @NonNull public LocationComponentOptions.Builder accuracyAlpha(float accuracyAlpha) { this.accuracyAlpha = accuracyAlpha; return this; @@ -1143,6 +1173,7 @@ public class LocationComponentOptions implements Parcelable { * @return this builder for chaining options together * @attr ref R.styleable#LocationComponent_accuracyColor */ + @NonNull public LocationComponentOptions.Builder accuracyColor(int accuracyColor) { this.accuracyColor = accuracyColor; return this; @@ -1155,6 +1186,7 @@ public class LocationComponentOptions implements Parcelable { * @return this builder for chaining options together * @attr ref R.styleable#LocationComponent_backgroundDrawableStale */ + @NonNull public LocationComponentOptions.Builder backgroundDrawableStale(int backgroundDrawableStale) { this.backgroundDrawableStale = backgroundDrawableStale; return this; @@ -1172,6 +1204,7 @@ public class LocationComponentOptions implements Parcelable { * @param backgroundStaleName String icon or maki-icon name * @return this builder for chaining options together */ + @NonNull public LocationComponentOptions.Builder backgroundStaleName(@Nullable String backgroundStaleName) { this.backgroundStaleName = backgroundStaleName; return this; @@ -1184,6 +1217,7 @@ public class LocationComponentOptions implements Parcelable { * @return this builder for chaining options together * @attr ref R.styleable#LocationComponent_foregroundDrawableStale */ + @NonNull public LocationComponentOptions.Builder foregroundDrawableStale(int foregroundDrawableStale) { this.foregroundDrawableStale = foregroundDrawableStale; return this; @@ -1201,6 +1235,7 @@ public class LocationComponentOptions implements Parcelable { * @param foregroundStaleName String icon or maki-icon name * @return this builder for chaining options together */ + @NonNull public LocationComponentOptions.Builder foregroundStaleName(@Nullable String foregroundStaleName) { this.foregroundStaleName = foregroundStaleName; return this; @@ -1213,6 +1248,7 @@ public class LocationComponentOptions implements Parcelable { * @return this builder for chaining options together * @attr ref R.styleable#LocationComponent_gpsDrawable */ + @NonNull public LocationComponentOptions.Builder gpsDrawable(int gpsDrawable) { this.gpsDrawable = gpsDrawable; return this; @@ -1230,6 +1266,7 @@ public class LocationComponentOptions implements Parcelable { * @param gpsName String icon or maki-icon name * @return this builder for chaining options together */ + @NonNull public LocationComponentOptions.Builder gpsName(@Nullable String gpsName) { this.gpsName = gpsName; return this; @@ -1242,6 +1279,7 @@ public class LocationComponentOptions implements Parcelable { * @return this builder for chaining options together * @attr ref R.styleable#LocationComponent_foregroundDrawable */ + @NonNull public LocationComponentOptions.Builder foregroundDrawable(int foregroundDrawable) { this.foregroundDrawable = foregroundDrawable; return this; @@ -1259,6 +1297,7 @@ public class LocationComponentOptions implements Parcelable { * @param foregroundName String icon or maki-icon name * @return this builder for chaining options together */ + @NonNull public LocationComponentOptions.Builder foregroundName(@Nullable String foregroundName) { this.foregroundName = foregroundName; return this; @@ -1271,6 +1310,7 @@ public class LocationComponentOptions implements Parcelable { * @return this builder for chaining options together * @attr ref R.styleable#LocationComponent_backgroundDrawable */ + @NonNull public LocationComponentOptions.Builder backgroundDrawable(int backgroundDrawable) { this.backgroundDrawable = backgroundDrawable; return this; @@ -1288,6 +1328,7 @@ public class LocationComponentOptions implements Parcelable { * @param backgroundName String icon or maki-icon name * @return this builder for chaining options together */ + @NonNull public LocationComponentOptions.Builder backgroundName(@Nullable String backgroundName) { this.backgroundName = backgroundName; return this; @@ -1300,6 +1341,7 @@ public class LocationComponentOptions implements Parcelable { * @return this builder for chaining options together * @attr ref R.styleable#LocationComponent_bearingDrawable */ + @NonNull public LocationComponentOptions.Builder bearingDrawable(int bearingDrawable) { this.bearingDrawable = bearingDrawable; return this; @@ -1317,6 +1359,7 @@ public class LocationComponentOptions implements Parcelable { * @param bearingName String icon or maki-icon name * @return this builder for chaining options together */ + @NonNull public LocationComponentOptions.Builder bearingName(@Nullable String bearingName) { this.bearingName = bearingName; return this; @@ -1329,6 +1372,7 @@ public class LocationComponentOptions implements Parcelable { * @return this builder for chaining options together * @attr ref R.styleable#LocationComponent_bearingTintColor */ + @NonNull public LocationComponentOptions.Builder bearingTintColor(@Nullable Integer bearingTintColor) { this.bearingTintColor = bearingTintColor; return this; @@ -1341,6 +1385,7 @@ public class LocationComponentOptions implements Parcelable { * @return this builder for chaining options together * @attr ref R.styleable#LocationComponent_foregroundTintColor */ + @NonNull public LocationComponentOptions.Builder foregroundTintColor(@Nullable Integer foregroundTintColor) { this.foregroundTintColor = foregroundTintColor; return this; @@ -1353,6 +1398,7 @@ public class LocationComponentOptions implements Parcelable { * @return this builder for chaining options together * @attr ref R.styleable#LocationComponent_backgroundTintColor */ + @NonNull public LocationComponentOptions.Builder backgroundTintColor(@Nullable Integer backgroundTintColor) { this.backgroundTintColor = backgroundTintColor; return this; @@ -1365,6 +1411,7 @@ public class LocationComponentOptions implements Parcelable { * @return this builder for chaining options together * @attr ref R.styleable#LocationComponent_foregroundStaleTintColor */ + @NonNull public LocationComponentOptions.Builder foregroundStaleTintColor(@Nullable Integer foregroundStaleTintColor) { this.foregroundStaleTintColor = foregroundStaleTintColor; return this; @@ -1377,6 +1424,7 @@ public class LocationComponentOptions implements Parcelable { * @return this builder for chaining options together * @attr ref R.styleable#LocationComponent_backgroundStaleTintColor */ + @NonNull public LocationComponentOptions.Builder backgroundStaleTintColor(@Nullable Integer backgroundStaleTintColor) { this.backgroundStaleTintColor = backgroundStaleTintColor; return this; @@ -1389,6 +1437,7 @@ public class LocationComponentOptions implements Parcelable { * @return this builder for chaining options together * @attr ref R.styleable#LocationComponent_elevation */ + @NonNull public LocationComponentOptions.Builder elevation(float elevation) { this.elevation = elevation; return this; @@ -1402,6 +1451,7 @@ public class LocationComponentOptions implements Parcelable { * @return this builder for chaining options together * @attr ref R.styleable#LocationComponent_enableStaleState */ + @NonNull public LocationComponentOptions.Builder enableStaleState(boolean enabled) { this.enableStaleState = enabled; return this; @@ -1417,6 +1467,7 @@ public class LocationComponentOptions implements Parcelable { * @return this builder for chaining options together * @attr ref R.styleable#LocationComponent_staleStateTimeout */ + @NonNull public LocationComponentOptions.Builder staleStateTimeout(long timeout) { this.staleStateTimeout = timeout; return this; @@ -1436,7 +1487,8 @@ public class LocationComponentOptions implements Parcelable { * * @param padding The margins for the map in pixels (left, top, right, bottom). */ - public LocationComponentOptions.Builder padding(int[] padding) { + @NonNull + public LocationComponentOptions.Builder padding(@Nullable int[] padding) { if (padding == null) { throw new NullPointerException("Null padding"); } @@ -1451,6 +1503,7 @@ public class LocationComponentOptions implements Parcelable { * * @param maxZoom The new maximum zoom level. */ + @NonNull public LocationComponentOptions.Builder maxZoom(double maxZoom) { this.maxZoom = maxZoom; return this; @@ -1461,6 +1514,7 @@ public class LocationComponentOptions implements Parcelable { * * @param minZoom The new minimum zoom level. */ + @NonNull public LocationComponentOptions.Builder minZoom(double minZoom) { this.minZoom = minZoom; return this; @@ -1475,6 +1529,7 @@ public class LocationComponentOptions implements Parcelable { * * @param maxZoomIconScale icon scale factor */ + @NonNull public LocationComponentOptions.Builder maxZoomIconScale(float maxZoomIconScale) { this.maxZoomIconScale = maxZoomIconScale; return this; @@ -1489,6 +1544,7 @@ public class LocationComponentOptions implements Parcelable { * * @param minZoomIconScale icon scale factor */ + @NonNull public LocationComponentOptions.Builder minZoomIconScale(float minZoomIconScale) { this.minZoomIconScale = minZoomIconScale; return this; @@ -1508,6 +1564,7 @@ public class LocationComponentOptions implements Parcelable { * @see Builder#trackingInitialMoveThreshold(float) * @see Builder#trackingMultiFingerMoveThreshold(float) */ + @NonNull public LocationComponentOptions.Builder trackingGesturesManagement(boolean trackingGesturesManagement) { this.trackingGesturesManagement = trackingGesturesManagement; return this; @@ -1518,6 +1575,7 @@ public class LocationComponentOptions implements Parcelable { * * @param moveThreshold the minimum movement */ + @NonNull public LocationComponentOptions.Builder trackingInitialMoveThreshold(float moveThreshold) { this.trackingInitialMoveThreshold = moveThreshold; return this; @@ -1529,6 +1587,7 @@ public class LocationComponentOptions implements Parcelable { * * @param moveThreshold the minimum movement */ + @NonNull public LocationComponentOptions.Builder trackingMultiFingerMoveThreshold(float moveThreshold) { this.trackingMultiFingerMoveThreshold = moveThreshold; return this; @@ -1539,6 +1598,7 @@ public class LocationComponentOptions implements Parcelable { * * @param layerBelow the id to set the location component below to. */ + @NonNull public LocationComponentOptions.Builder layerBelow(String layerBelow) { this.layerBelow = layerBelow; return this; @@ -1550,6 +1610,7 @@ public class LocationComponentOptions implements Parcelable { * @param trackingAnimationDurationMultiplier the tracking animation duration multiplier * @since 0.9.0 */ + @NonNull public LocationComponentOptions.Builder trackingAnimationDurationMultiplier( float trackingAnimationDurationMultiplier) { this.trackingAnimationDurationMultiplier = trackingAnimationDurationMultiplier; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationLayerController.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationLayerController.java index da3144eea1..88a29b3927 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationLayerController.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationLayerController.java @@ -73,7 +73,7 @@ final class LocationLayerController implements MapboxAnimator.OnLayerAnimationsV LocationLayerController(MapboxMap mapboxMap, LayerSourceProvider layerSourceProvider, LayerFeatureProvider featureProvider, LayerBitmapProvider bitmapProvider, - LocationComponentOptions options) { + @NonNull LocationComponentOptions options) { this.mapboxMap = mapboxMap; this.layerSourceProvider = layerSourceProvider; this.bitmapProvider = bitmapProvider; @@ -192,7 +192,7 @@ final class LocationLayerController implements MapboxAnimator.OnLayerAnimationsV return isHidden; } - private void setLayerVisibility(String layerId, boolean visible) { + private void setLayerVisibility(@NonNull String layerId, boolean visible) { Layer layer = mapboxMap.getLayer(layerId); if (layer != null) { String targetVisibility = visible ? VISIBLE : NONE; @@ -202,7 +202,7 @@ final class LocationLayerController implements MapboxAnimator.OnLayerAnimationsV } } - private void addLayers(String idBelowLayer) { + private void addLayers(@NonNull String idBelowLayer) { addSymbolLayer(BEARING_LAYER, idBelowLayer); addSymbolLayer(FOREGROUND_LAYER, BEARING_LAYER); addSymbolLayer(BACKGROUND_LAYER, FOREGROUND_LAYER); @@ -210,7 +210,7 @@ final class LocationLayerController implements MapboxAnimator.OnLayerAnimationsV addAccuracyLayer(); } - private void addSymbolLayer(String layerId, String beforeLayerId) { + private void addSymbolLayer(@NonNull String layerId, @NonNull String beforeLayerId) { Layer layer = layerSourceProvider.generateLayer(layerId); addLayerToMap(layer, beforeLayerId); } @@ -220,12 +220,12 @@ final class LocationLayerController implements MapboxAnimator.OnLayerAnimationsV addLayerToMap(accuracyLayer, BACKGROUND_LAYER); } - private void addLayerToMap(Layer layer, @NonNull String idBelowLayer) { + private void addLayerToMap(@NonNull Layer layer, @NonNull String idBelowLayer) { mapboxMap.addLayerBelow(layer, idBelowLayer); layerMap.add(layer.getId()); } - private void setBearingProperty(String propertyId, float bearing) { + private void setBearingProperty(@NonNull String propertyId, float bearing) { locationFeature.addNumberProperty(propertyId, bearing); refreshSource(); } @@ -276,7 +276,7 @@ final class LocationLayerController implements MapboxAnimator.OnLayerAnimationsV mapboxMap.addImage(BACKGROUND_STALE_ICON, backgroundStaleBitmap); } - private void styleShadow(LocationComponentOptions options) { + private void styleShadow(@NonNull LocationComponentOptions options) { mapboxMap.addImage(SHADOW_ICON, bitmapProvider.generateShadowBitmap(options)); } @@ -310,7 +310,7 @@ final class LocationLayerController implements MapboxAnimator.OnLayerAnimationsV mapboxMap.addImage(FOREGROUND_STALE_ICON, foregroundBitmapStale); } - private void styleScaling(LocationComponentOptions options) { + private void styleScaling(@NonNull LocationComponentOptions options) { for (String layerId : layerMap) { Layer layer = mapboxMap.getLayer(layerId); if (layer != null && layer instanceof SymbolLayer) { @@ -342,6 +342,7 @@ final class LocationLayerController implements MapboxAnimator.OnLayerAnimationsV refreshSource(); } + @Nullable private String buildIconString(@Nullable String bitmapName, @NonNull String drawableName) { if (bitmapName != null) { return bitmapName; @@ -361,7 +362,7 @@ final class LocationLayerController implements MapboxAnimator.OnLayerAnimationsV // Map click event // - boolean onMapClick(LatLng point) { + boolean onMapClick(@NonNull LatLng point) { PointF screenLoc = mapboxMap.getProjection().toScreenLocation(point); List<Feature> features = mapboxMap.queryRenderedFeatures(screenLoc, BACKGROUND_LAYER, diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/MapboxCameraAnimatorAdapter.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/MapboxCameraAnimatorAdapter.java index 89d27a38fa..b4f9051af8 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/MapboxCameraAnimatorAdapter.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/MapboxCameraAnimatorAdapter.java @@ -10,6 +10,7 @@ import java.util.List; abstract class MapboxCameraAnimatorAdapter extends MapboxFloatAnimator<MapboxAnimator.OnCameraAnimationsValuesChangeListener> { + @Nullable private final MapboxMap.CancelableCallback cancelableCallback; MapboxCameraAnimatorAdapter(Float previous, Float target, diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/MapboxFloatAnimator.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/MapboxFloatAnimator.java index 4a6d8c3b73..d12e80a69d 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/MapboxFloatAnimator.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/MapboxFloatAnimator.java @@ -2,6 +2,7 @@ package com.mapbox.mapboxsdk.location; import android.animation.FloatEvaluator; import android.animation.TypeEvaluator; +import android.support.annotation.NonNull; import java.util.List; @@ -10,6 +11,7 @@ abstract class MapboxFloatAnimator<L> extends MapboxAnimator<Float, L> { super(previous, target, updateListeners); } + @NonNull @Override TypeEvaluator provideEvaluator() { return new FloatEvaluator(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/MapboxLatLngAnimator.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/MapboxLatLngAnimator.java index b2f1b61a2d..f2c5f9a239 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/MapboxLatLngAnimator.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/MapboxLatLngAnimator.java @@ -2,6 +2,7 @@ package com.mapbox.mapboxsdk.location; import android.animation.TypeEvaluator; +import android.support.annotation.NonNull; import com.mapbox.mapboxsdk.geometry.LatLng; import java.util.List; @@ -12,6 +13,7 @@ abstract class MapboxLatLngAnimator<L> extends MapboxAnimator<LatLng, L> { super(previous, target, updateListeners); } + @NonNull @Override TypeEvaluator provideEvaluator() { return new LatLngEvaluator(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/StaleStateManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/StaleStateManager.java index c8f6ed58b9..c7447796e0 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/StaleStateManager.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/StaleStateManager.java @@ -1,6 +1,7 @@ package com.mapbox.mapboxsdk.location; import android.os.Handler; +import android.support.annotation.NonNull; /** * Class controls the location stale state when the {@link android.location.Location} hasn't @@ -12,6 +13,7 @@ class StaleStateManager { private boolean isEnabled; private final OnLocationStaleListener innerOnLocationStaleListeners; + @NonNull private final Handler handler; private boolean isStale = true; private long delayTime; @@ -23,6 +25,7 @@ class StaleStateManager { delayTime = options.staleStateTimeout(); } + @NonNull private Runnable staleStateRunnable = new Runnable() { @Override public void run() { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/TiltAnimator.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/TiltAnimator.java index 8ff0f97a70..640ce0a678 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/TiltAnimator.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/TiltAnimator.java @@ -1,6 +1,7 @@ package com.mapbox.mapboxsdk.location; import android.animation.ValueAnimator; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import com.mapbox.mapboxsdk.maps.MapboxMap; @@ -19,7 +20,7 @@ class TiltAnimator extends MapboxCameraAnimatorAdapter { } @Override - public void onAnimationUpdate(ValueAnimator animation) { + public void onAnimationUpdate(@NonNull ValueAnimator animation) { for (OnCameraAnimationsValuesChangeListener listener : updateListeners) { listener.onNewTiltValue((Float) animation.getAnimatedValue()); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/Utils.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/Utils.java index 553678709e..8907b93b5f 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/Utils.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/Utils.java @@ -65,8 +65,9 @@ public final class Utils { return bitmap; } + @Nullable static Drawable getDrawable(@NonNull Context context, @DrawableRes int drawableRes, - @ColorInt Integer tintColor) { + @Nullable @ColorInt Integer tintColor) { Drawable drawable = ContextCompat.getDrawable(context, drawableRes); if (tintColor == null) { return drawable; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/ZoomAnimator.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/ZoomAnimator.java index 323b51fa88..e37dfc1113 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/ZoomAnimator.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/ZoomAnimator.java @@ -1,6 +1,7 @@ package com.mapbox.mapboxsdk.location; import android.animation.ValueAnimator; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import com.mapbox.mapboxsdk.maps.MapboxMap; @@ -20,7 +21,7 @@ class ZoomAnimator extends MapboxCameraAnimatorAdapter { } @Override - public void onAnimationUpdate(ValueAnimator animation) { + public void onAnimationUpdate(@NonNull ValueAnimator animation) { for (OnCameraAnimationsValuesChangeListener listener : updateListeners) { listener.onNewZoomValue((Float) animation.getAnimatedValue()); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AnnotationContainer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AnnotationContainer.java index 939fadc9c2..4612d7d941 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AnnotationContainer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AnnotationContainer.java @@ -27,6 +27,7 @@ class AnnotationContainer implements Annotations { return annotations.get(id); } + @NonNull @Override public List<Annotation> obtainAll() { List<Annotation> annotations = new ArrayList<>(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AnnotationManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AnnotationManager.java index 95795f6bb9..86eb0b10e6 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AnnotationManager.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AnnotationManager.java @@ -45,13 +45,17 @@ class AnnotationManager { private final MapView mapView; private final IconManager iconManager; private final InfoWindowManager infoWindowManager = new InfoWindowManager(); + @NonNull private final MarkerViewManager markerViewManager; private final LongSparseArray<Annotation> annotationsArray; private final List<Marker> selectedMarkers = new ArrayList<>(); private MapboxMap mapboxMap; + @Nullable private MapboxMap.OnMarkerClickListener onMarkerClickListener; + @Nullable private MapboxMap.OnPolygonClickListener onPolygonClickListener; + @Nullable private MapboxMap.OnPolylineClickListener onPolylineClickListener; private Annotations annotations; @@ -60,8 +64,8 @@ class AnnotationManager { private Polygons polygons; private Polylines polylines; - AnnotationManager(NativeMapView view, MapView mapView, LongSparseArray<Annotation> annotationsArray, - MarkerViewManager markerViewManager, IconManager iconManager, Annotations annotations, + AnnotationManager(@Nullable NativeMapView view, MapView mapView, LongSparseArray<Annotation> annotationsArray, + @NonNull MarkerViewManager markerViewManager, IconManager iconManager, Annotations annotations, Markers markers, Polygons polygons, Polylines polylines, ShapeAnnotations shapeAnnotations) { this.mapView = mapView; this.annotationsArray = annotationsArray; @@ -80,6 +84,7 @@ class AnnotationManager { // TODO refactor MapboxMap out for Projection and Transform // Requires removing MapboxMap from Annotations by using Peer model from #6912 + @NonNull AnnotationManager bind(MapboxMap mapboxMap) { this.mapboxMap = mapboxMap; this.markerViewManager.bind(mapboxMap); @@ -224,7 +229,7 @@ class AnnotationManager { return polygons.addBy(polygonOptionsList, mapboxMap); } - void updatePolygon(Polygon polygon) { + void updatePolygon(@NonNull Polygon polygon) { if (!isAddedToMap(polygon)) { logNonAdded(polygon); return; @@ -248,7 +253,7 @@ class AnnotationManager { return polylines.addBy(polylineOptionsList, mapboxMap); } - void updatePolyline(Polyline polyline) { + void updatePolyline(@NonNull Polyline polyline) { if (!isAddedToMap(polyline)) { logNonAdded(polyline); return; @@ -333,19 +338,22 @@ class AnnotationManager { selectedMarkers.remove(marker); } + @NonNull List<Marker> getSelectedMarkers() { return selectedMarkers; } + @NonNull InfoWindowManager getInfoWindowManager() { return infoWindowManager; } + @NonNull MarkerViewManager getMarkerViewManager() { return markerViewManager; } - void adjustTopOffsetPixels(MapboxMap mapboxMap) { + void adjustTopOffsetPixels(@NonNull MapboxMap mapboxMap) { int count = annotationsArray.size(); for (int i = 0; i < count; i++) { Annotation annotation = annotationsArray.get(i); @@ -364,11 +372,11 @@ class AnnotationManager { } } - private boolean isAddedToMap(Annotation annotation) { + private boolean isAddedToMap(@Nullable Annotation annotation) { return annotation != null && annotation.getId() != -1 && annotationsArray.indexOfKey(annotation.getId()) > -1; } - private void logNonAdded(Annotation annotation) { + private void logNonAdded(@NonNull Annotation annotation) { Logger.w(TAG, String.format( "Attempting to update non-added %s with value %s", annotation.getClass().getCanonicalName(), annotation) ); @@ -378,7 +386,7 @@ class AnnotationManager { // Click event // - boolean onTap(PointF tapPoint) { + boolean onTap(@NonNull PointF tapPoint) { MarkerHit markerHit = getMarkerHitFromTouchArea(tapPoint); long markerId = new MarkerHitResolver(mapboxMap).execute(markerHit); if (markerId != NO_ANNOTATION_ID) { @@ -440,11 +448,11 @@ class AnnotationManager { return true; } - private boolean onClickMarker(Marker marker) { + private boolean onClickMarker(@NonNull Marker marker) { return onMarkerClickListener != null && onMarkerClickListener.onMarkerClick(marker); } - private void toggleMarkerSelectionState(Marker marker) { + private void toggleMarkerSelectionState(@NonNull Marker marker) { if (!selectedMarkers.contains(marker)) { selectMarker(marker); } else { @@ -460,7 +468,8 @@ class AnnotationManager { this.shapeAnnotations = shapeAnnotations; } - public Annotation execute(ShapeAnnotationHit shapeHit) { + @Nullable + public Annotation execute(@NonNull ShapeAnnotationHit shapeHit) { Annotation foundAnnotation = null; List<Annotation> annotations = shapeAnnotations.obtainAllIn(shapeHit.tapPoint); if (annotations.size() > 0) { @@ -472,18 +481,24 @@ class AnnotationManager { private static class MarkerHitResolver { + @NonNull private final MarkerViewManager markerViewManager; + @NonNull private final Projection projection; private final int minimalTouchSize; + @Nullable private View view; private Bitmap bitmap; private int bitmapWidth; private int bitmapHeight; private PointF markerLocation; + @NonNull private Rect hitRectView = new Rect(); + @NonNull private RectF hitRectMarker = new RectF(); + @NonNull private RectF highestSurfaceIntersection = new RectF(); private long closestMarkerId = NO_ANNOTATION_ID; @@ -494,7 +509,7 @@ class AnnotationManager { this.minimalTouchSize = (int) (32 * Mapbox.getApplicationContext().getResources().getDisplayMetrics().density); } - public long execute(MarkerHit markerHit) { + public long execute(@NonNull MarkerHit markerHit) { resolveForMarkers(markerHit); return closestMarkerId; } @@ -509,7 +524,7 @@ class AnnotationManager { } } - private void resolveForMarkerView(MarkerHit markerHit, MarkerView markerView) { + private void resolveForMarkerView(@NonNull MarkerHit markerHit, @NonNull MarkerView markerView) { view = markerViewManager.getView(markerView); if (view != null) { view.getHitRect(hitRectView); @@ -518,7 +533,7 @@ class AnnotationManager { } } - private void resolveForMarker(MarkerHit markerHit, Marker marker) { + private void resolveForMarker(@NonNull MarkerHit markerHit, Marker marker) { markerLocation = projection.toScreenLocation(marker.getPosition()); bitmap = marker.getIcon().getBitmap(); @@ -540,7 +555,7 @@ class AnnotationManager { hitTestMarker(markerHit, marker, hitRectMarker); } - private void hitTestMarker(MarkerHit markerHit, Marker marker, RectF hitRectMarker) { + private void hitTestMarker(@NonNull MarkerHit markerHit, @NonNull Marker marker, @NonNull RectF hitRectMarker) { if (hitRectMarker.contains(markerHit.getTapPointX(), markerHit.getTapPointY())) { hitRectMarker.intersect(markerHit.tapRect); if (isRectangleHighestSurfaceIntersection(hitRectMarker)) { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AttributionDialogManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AttributionDialogManager.java index 5cba2109e2..f849dc7f15 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AttributionDialogManager.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AttributionDialogManager.java @@ -8,6 +8,7 @@ import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.view.View; import android.widget.ArrayAdapter; import android.widget.Toast; @@ -40,7 +41,9 @@ public class AttributionDialogManager implements View.OnClickListener, DialogInt private static final String MAP_FEEDBACK_URL = "https://www.mapbox.com/map-feedback"; private static final String MAP_FEEDBACK_LOCATION_FORMAT = MAP_FEEDBACK_URL + "/#/%f/%f/%d"; + @NonNull private final Context context; + @NonNull private final MapboxMap mapboxMap; private Set<Attribution> attributionSet; @@ -51,7 +54,7 @@ public class AttributionDialogManager implements View.OnClickListener, DialogInt // Called when someone presses the attribution icon on the map @Override - public void onClick(View view) { + public void onClick(@NonNull View view) { attributionSet = new AttributionBuilder(mapboxMap, view.getContext()).build(); boolean isActivityFinishing = false; @@ -66,7 +69,7 @@ public class AttributionDialogManager implements View.OnClickListener, DialogInt } } - protected void showAttributionDialog(String[] attributionTitles) { + protected void showAttributionDialog(@NonNull String[] attributionTitles) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(R.string.mapbox_attributionsDialogTitle); builder.setAdapter(new ArrayAdapter<>(context, R.layout.mapbox_attribution_list_item, attributionTitles), this); @@ -101,7 +104,7 @@ public class AttributionDialogManager implements View.OnClickListener, DialogInt builder.setMessage(R.string.mapbox_attributionTelemetryMessage); builder.setPositiveButton(R.string.mapbox_attributionTelemetryPositive, new DialogInterface.OnClickListener() { @Override - public void onClick(DialogInterface dialog, int which) { + public void onClick(@NonNull DialogInterface dialog, int which) { TelemetryDefinition telemetry = Mapbox.getTelemetry(); if (telemetry != null) { telemetry.setUserTelemetryRequestState(true); @@ -111,14 +114,14 @@ public class AttributionDialogManager implements View.OnClickListener, DialogInt }); builder.setNeutralButton(R.string.mapbox_attributionTelemetryNeutral, new DialogInterface.OnClickListener() { @Override - public void onClick(DialogInterface dialog, int which) { + public void onClick(@NonNull DialogInterface dialog, int which) { showWebPage(context.getResources().getString(R.string.mapbox_telemetryLink)); dialog.cancel(); } }); builder.setNegativeButton(R.string.mapbox_attributionTelemetryNegative, new DialogInterface.OnClickListener() { @Override - public void onClick(DialogInterface dialog, int which) { + public void onClick(@NonNull DialogInterface dialog, int which) { TelemetryDefinition telemetry = Mapbox.getTelemetry(); if (telemetry != null) { telemetry.setUserTelemetryRequestState(false); @@ -138,7 +141,8 @@ public class AttributionDialogManager implements View.OnClickListener, DialogInt showWebPage(url); } - private String buildMapFeedbackMapUrl(CameraPosition cameraPosition) { + @NonNull + private String buildMapFeedbackMapUrl(@Nullable CameraPosition cameraPosition) { // appends current location to the map feedback url if available return cameraPosition != null ? String.format(Locale.getDefault(), MAP_FEEDBACK_LOCATION_FORMAT, cameraPosition.target.getLongitude(), cameraPosition.target.getLatitude(), @@ -160,6 +164,7 @@ public class AttributionDialogManager implements View.OnClickListener, DialogInt private static class AttributionBuilder { private final MapboxMap mapboxMap; + @NonNull private final WeakReference<Context> context; AttributionBuilder(MapboxMap mapboxMap, Context context) { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java index a87a290fd7..3f969df022 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java @@ -203,7 +203,7 @@ class CameraChangeDispatcher implements MapboxMap.OnCameraMoveStartedListener, M } @Override - public void handleMessage(Message msg) { + public void handleMessage(@NonNull Message msg) { CameraChangeDispatcher dispatcher = dispatcherWeakReference.get(); if (dispatcher != null) { switch (msg.what) { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/FocalPointChangeListener.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/FocalPointChangeListener.java index aec9a848b7..c5c0a15ac6 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/FocalPointChangeListener.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/FocalPointChangeListener.java @@ -1,11 +1,12 @@ package com.mapbox.mapboxsdk.maps; import android.graphics.PointF; +import android.support.annotation.NonNull; /** * Interface definition of a callback that is invoked when the focal point will change. */ public interface FocalPointChangeListener { - void onFocalPointChanged(PointF pointF); + void onFocalPointChanged(@NonNull PointF pointF); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/IconManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/IconManager.java index 80ffa973e7..7aca93fe2e 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/IconManager.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/IconManager.java @@ -2,6 +2,7 @@ package com.mapbox.mapboxsdk.maps; import android.graphics.Bitmap; +import android.support.annotation.NonNull; import com.mapbox.mapboxsdk.Mapbox; import com.mapbox.mapboxsdk.annotations.Icon; import com.mapbox.mapboxsdk.annotations.IconFactory; @@ -37,7 +38,7 @@ class IconManager { loadIcon(IconFactory.recreate(IconFactory.ICON_MARKERVIEW_ID, IconFactory.ICON_MARKERVIEW_BITMAP)); } - Icon loadIconForMarker(Marker marker) { + Icon loadIconForMarker(@NonNull Marker marker) { Icon icon = marker.getIcon(); if (icon == null) { // TODO replace with anchor implementation, we are faking an anchor by adding extra pixels and diving height by 2 @@ -50,14 +51,14 @@ class IconManager { return icon; } - void loadIconForMarkerView(MarkerView marker) { + void loadIconForMarkerView(@NonNull MarkerView marker) { Icon icon = marker.getIcon(); Bitmap bitmap = icon.getBitmap(); updateHighestIconSize(bitmap); addIcon(icon, false); } - int getTopOffsetPixelsForIcon(Icon icon) { + int getTopOffsetPixelsForIcon(@NonNull Icon icon) { return (int) (nativeMapView.getTopOffsetPixelsForAnnotationSymbol(icon.getId()) * nativeMapView.getPixelRatio()); } @@ -77,11 +78,11 @@ class IconManager { return icon; } - private void addIcon(Icon icon) { + private void addIcon(@NonNull Icon icon) { addIcon(icon, true); } - private void addIcon(Icon icon, boolean addIconToMap) { + private void addIcon(@NonNull Icon icon, boolean addIconToMap) { if (!iconMap.keySet().contains(icon)) { iconMap.put(icon, 1); if (addIconToMap) { @@ -125,7 +126,7 @@ class IconManager { } } - void ensureIconLoaded(Marker marker, MapboxMap mapboxMap) { + void ensureIconLoaded(@NonNull Marker marker, @NonNull MapboxMap mapboxMap) { Icon icon = marker.getIcon(); if (icon == null) { icon = loadDefaultIconForMarker(marker); @@ -134,7 +135,7 @@ class IconManager { setTopOffsetPixels(marker, mapboxMap, icon); } - private void setTopOffsetPixels(Marker marker, MapboxMap mapboxMap, Icon icon) { + private void setTopOffsetPixels(Marker marker, @NonNull MapboxMap mapboxMap, @NonNull Icon icon) { // this seems to be a costly operation according to the profiler so I'm trying to save some calls Marker previousMarker = marker.getId() != -1 ? (Marker) mapboxMap.getAnnotation(marker.getId()) : null; if (previousMarker == null || previousMarker.getIcon() == null || previousMarker.getIcon() != marker.getIcon()) { @@ -142,7 +143,7 @@ class IconManager { } } - void iconCleanup(Icon icon) { + void iconCleanup(@NonNull Icon icon) { Integer refCounter = iconMap.get(icon); if (refCounter != null) { refCounter--; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/InfoWindowManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/InfoWindowManager.java index af207204d9..434244a7c1 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/InfoWindowManager.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/InfoWindowManager.java @@ -23,11 +23,15 @@ class InfoWindowManager { private final List<InfoWindow> infoWindows = new ArrayList<>(); + @Nullable private MapboxMap.InfoWindowAdapter infoWindowAdapter; private boolean allowConcurrentMultipleInfoWindows; + @Nullable private MapboxMap.OnInfoWindowClickListener onInfoWindowClickListener; + @Nullable private MapboxMap.OnInfoWindowLongClickListener onInfoWindowLongClickListener; + @Nullable private MapboxMap.OnInfoWindowCloseListener onInfoWindowCloseListener; void update() { @@ -42,6 +46,7 @@ class InfoWindowManager { this.infoWindowAdapter = infoWindowAdapter; } + @Nullable MapboxMap.InfoWindowAdapter getInfoWindowAdapter() { return infoWindowAdapter; } @@ -54,7 +59,7 @@ class InfoWindowManager { return allowConcurrentMultipleInfoWindows; } - boolean isInfoWindowValidForMarker(Marker marker) { + boolean isInfoWindowValidForMarker(@Nullable Marker marker) { return marker != null && (!TextUtils.isEmpty(marker.getTitle()) || !TextUtils.isEmpty(marker.getSnippet())); } @@ -62,6 +67,7 @@ class InfoWindowManager { onInfoWindowClickListener = listener; } + @Nullable MapboxMap.OnInfoWindowClickListener getOnInfoWindowClickListener() { return onInfoWindowClickListener; } @@ -70,6 +76,7 @@ class InfoWindowManager { onInfoWindowLongClickListener = listener; } + @Nullable MapboxMap.OnInfoWindowLongClickListener getOnInfoWindowLongClickListener() { return onInfoWindowLongClickListener; } @@ -78,6 +85,7 @@ class InfoWindowManager { onInfoWindowCloseListener = listener; } + @Nullable MapboxMap.OnInfoWindowCloseListener getOnInfoWindowCloseListener() { return onInfoWindowCloseListener; } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapFragment.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapFragment.java index d6057e28f8..f89b280c4c 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapFragment.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapFragment.java @@ -51,6 +51,7 @@ public final class MapFragment extends Fragment implements OnMapReadyCallback { * @param mapboxMapOptions The configuration options to be used. * @return MapFragment instantiated. */ + @NonNull public static MapFragment newInstance(@Nullable MapboxMapOptions mapboxMapOptions) { MapFragment mapFragment = new MapFragment(); mapFragment.setArguments(MapFragmentUtils.createFragmentArgs(mapboxMapOptions)); @@ -65,7 +66,7 @@ public final class MapFragment extends Fragment implements OnMapReadyCallback { * @param savedInstanceState The saved instance state for the map fragment. */ @Override - public void onInflate(Context context, AttributeSet attrs, Bundle savedInstanceState) { + public void onInflate(@NonNull Context context, AttributeSet attrs, Bundle savedInstanceState) { super.onInflate(context, attrs, savedInstanceState); setArguments(MapFragmentUtils.createFragmentArgs(MapboxMapOptions.createFromAttributes(context, attrs))); } @@ -92,7 +93,7 @@ public final class MapFragment extends Fragment implements OnMapReadyCallback { * @return The view created */ @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); Context context = inflater.getContext(); map = new MapView(context, MapFragmentUtils.resolveArgs(context, getArguments())); @@ -227,6 +228,6 @@ public final class MapFragment extends Fragment implements OnMapReadyCallback { * * @param mapView The created mapview */ - void onMapViewReady(MapView mapView); + void onMapViewReady(@NonNull MapView mapView); } } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java index 711896e45e..ea211e7246 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java @@ -6,6 +6,7 @@ import android.animation.ValueAnimator; import android.content.Context; import android.graphics.PointF; import android.os.Handler; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.InputDevice; import android.view.MotionEvent; @@ -81,6 +82,7 @@ final class MapGestureDetector { /** * User-set focal point. */ + @Nullable private PointF focalPoint; private AndroidGesturesManager gesturesManager; @@ -94,9 +96,10 @@ final class MapGestureDetector { * Cancels scheduled velocity animations if user doesn't lift fingers within * {@link MapboxConstants#SCHEDULED_ANIMATION_TIMEOUT} */ + @NonNull private Handler animationsTimeoutHandler = new Handler(); - MapGestureDetector(Context context, Transform transform, Projection projection, UiSettings uiSettings, + MapGestureDetector(@Nullable Context context, Transform transform, Projection projection, UiSettings uiSettings, AnnotationManager annotationManager, CameraChangeDispatcher cameraChangeDispatcher) { this.annotationManager = annotationManager; this.transform = transform; @@ -115,7 +118,7 @@ final class MapGestureDetector { } } - private void initializeGestureListeners(Context context, boolean attachDefaultListeners) { + private void initializeGestureListeners(@NonNull Context context, boolean attachDefaultListeners) { if (attachDefaultListeners) { StandardGestureListener standardGestureListener = new StandardGestureListener(); MoveGestureListener moveGestureListener = new MoveGestureListener(); @@ -137,7 +140,7 @@ final class MapGestureDetector { } } - private void initializeGesturesManager(AndroidGesturesManager androidGesturesManager, + private void initializeGesturesManager(@NonNull AndroidGesturesManager androidGesturesManager, boolean setDefaultMutuallyExclusives) { if (setDefaultMutuallyExclusives) { Set<Integer> shoveScaleSet = new HashSet<>(); @@ -167,7 +170,7 @@ final class MapGestureDetector { * * @param focalPoint the center point for gestures */ - void setFocalPoint(PointF focalPoint) { + void setFocalPoint(@Nullable PointF focalPoint) { if (focalPoint == null) { // resetting focal point, if (uiSettings.getFocalPoint() != null) { @@ -202,7 +205,7 @@ final class MapGestureDetector { * @param motionEvent the MotionEvent * @return True if touch event is handled */ - boolean onTouchEvent(MotionEvent motionEvent) { + boolean onTouchEvent(@Nullable MotionEvent motionEvent) { // Framework can return null motion events in edge cases #9432 if (motionEvent == null) { return false; @@ -253,7 +256,7 @@ final class MapGestureDetector { dispatchCameraIdle(); } - private void cancelAnimator(Animator animator) { + private void cancelAnimator(@Nullable Animator animator) { if (animator != null && animator.isStarted()) { animator.cancel(); } @@ -262,6 +265,7 @@ final class MapGestureDetector { /** * Posted on main thread with {@link #animationsTimeoutHandler}. Cancels all scheduled animators if needed. */ + @NonNull private Runnable cancelAnimatorsRunnable = new Runnable() { @Override public void run() { @@ -436,7 +440,7 @@ final class MapGestureDetector { private final class MoveGestureListener extends MoveGestureDetector.SimpleOnMoveGestureListener { @Override - public boolean onMoveBegin(MoveGestureDetector detector) { + public boolean onMoveBegin(@NonNull MoveGestureDetector detector) { if (!uiSettings.isScrollGesturesEnabled()) { return false; } @@ -448,7 +452,7 @@ final class MapGestureDetector { } @Override - public boolean onMove(MoveGestureDetector detector, float distanceX, float distanceY) { + public boolean onMove(@NonNull MoveGestureDetector detector, float distanceX, float distanceY) { // first move event is often delivered with no displacement if (distanceX != 0 || distanceY != 0) { // dispatching camera start event only when the movement actually occurred @@ -464,7 +468,7 @@ final class MapGestureDetector { } @Override - public void onMoveEnd(MoveGestureDetector detector, float velocityX, float velocityY) { + public void onMoveEnd(@NonNull MoveGestureDetector detector, float velocityX, float velocityY) { dispatchCameraIdle(); notifyOnMoveEndListeners(detector); } @@ -474,6 +478,7 @@ final class MapGestureDetector { private final float minimumVelocity; + @Nullable private PointF scaleFocalPoint; private boolean quickZoom; @@ -482,7 +487,7 @@ final class MapGestureDetector { } @Override - public boolean onScaleBegin(StandardScaleGestureDetector detector) { + public boolean onScaleBegin(@NonNull StandardScaleGestureDetector detector) { if (!uiSettings.isZoomGesturesEnabled()) { return false; } @@ -515,7 +520,7 @@ final class MapGestureDetector { } @Override - public boolean onScale(StandardScaleGestureDetector detector) { + public boolean onScale(@NonNull StandardScaleGestureDetector detector) { // dispatching camera start event only when the movement actually occurred cameraChangeDispatcher.onCameraMoveStarted(CameraChangeDispatcher.REASON_API_GESTURE); @@ -531,7 +536,7 @@ final class MapGestureDetector { } @Override - public void onScaleEnd(StandardScaleGestureDetector detector, float velocityX, float velocityY) { + public void onScaleEnd(@NonNull StandardScaleGestureDetector detector, float velocityX, float velocityY) { if (quickZoom) { //if quickzoom, re-enabling move gesture detector gesturesManager.getMoveGestureDetector().setEnabled(true); @@ -561,7 +566,7 @@ final class MapGestureDetector { scheduleAnimator(scaleAnimator); } - private void setScaleFocalPoint(StandardScaleGestureDetector detector) { + private void setScaleFocalPoint(@NonNull StandardScaleGestureDetector detector) { if (focalPoint != null) { // around user provided focal point scaleFocalPoint = focalPoint; @@ -597,6 +602,7 @@ final class MapGestureDetector { } private final class RotateGestureListener extends RotateGestureDetector.SimpleOnRotateGestureListener { + @Nullable private PointF rotateFocalPoint; private final float minimumScaleSpanWhenRotating; private final float minimumAngularVelocity; @@ -610,7 +616,7 @@ final class MapGestureDetector { } @Override - public boolean onRotateBegin(RotateGestureDetector detector) { + public boolean onRotateBegin(@NonNull RotateGestureDetector detector) { if (!uiSettings.isRotateGesturesEnabled()) { return false; } @@ -635,7 +641,7 @@ final class MapGestureDetector { } @Override - public boolean onRotate(RotateGestureDetector detector, float rotationDegreesSinceLast, + public boolean onRotate(@NonNull RotateGestureDetector detector, float rotationDegreesSinceLast, float rotationDegreesSinceFirst) { // dispatching camera start event only when the movement actually occurred cameraChangeDispatcher.onCameraMoveStarted(CameraChangeDispatcher.REASON_API_GESTURE); @@ -654,7 +660,8 @@ final class MapGestureDetector { } @Override - public void onRotateEnd(RotateGestureDetector detector, float velocityX, float velocityY, float angularVelocity) { + public void onRotateEnd(@NonNull RotateGestureDetector detector, float velocityX, float velocityY, + float angularVelocity) { if (uiSettings.isIncreaseScaleThresholdWhenRotating()) { // resetting default scale threshold values gesturesManager.getStandardScaleGestureDetector().setSpanSinceStartThreshold(defaultSpanSinceStartThreshold); @@ -683,7 +690,7 @@ final class MapGestureDetector { scheduleAnimator(rotateAnimator); } - private void setRotateFocalPoint(RotateGestureDetector detector) { + private void setRotateFocalPoint(@NonNull RotateGestureDetector detector) { if (focalPoint != null) { // User provided focal point rotateFocalPoint = focalPoint; @@ -699,7 +706,7 @@ final class MapGestureDetector { animator.setInterpolator(new DecelerateInterpolator()); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override - public void onAnimationUpdate(ValueAnimator animation) { + public void onAnimationUpdate(@NonNull ValueAnimator animation) { transform.setBearing( transform.getRawBearing() + (float) animation.getAnimatedValue(), rotateFocalPoint.x, rotateFocalPoint.y, @@ -733,7 +740,7 @@ final class MapGestureDetector { private final class ShoveGestureListener extends ShoveGestureDetector.SimpleOnShoveGestureListener { @Override - public boolean onShoveBegin(ShoveGestureDetector detector) { + public boolean onShoveBegin(@NonNull ShoveGestureDetector detector) { if (!uiSettings.isTiltGesturesEnabled()) { return false; } @@ -751,7 +758,8 @@ final class MapGestureDetector { } @Override - public boolean onShove(ShoveGestureDetector detector, float deltaPixelsSinceLast, float deltaPixelsSinceStart) { + public boolean onShove(@NonNull ShoveGestureDetector detector, float deltaPixelsSinceLast, + float deltaPixelsSinceStart) { // dispatching camera start event only when the movement actually occurred cameraChangeDispatcher.onCameraMoveStarted(CameraChangeDispatcher.REASON_API_GESTURE); @@ -769,7 +777,7 @@ final class MapGestureDetector { } @Override - public void onShoveEnd(ShoveGestureDetector detector, float velocityX, float velocityY) { + public void onShoveEnd(@NonNull ShoveGestureDetector detector, float velocityX, float velocityY) { dispatchCameraIdle(); // re-enabling move gesture @@ -781,7 +789,7 @@ final class MapGestureDetector { private final class TapGestureListener implements MultiFingerTapGestureDetector.OnMultiFingerTapGestureListener { @Override - public boolean onMultiFingerTap(MultiFingerTapGestureDetector detector, int pointersCount) { + public boolean onMultiFingerTap(@NonNull MultiFingerTapGestureDetector detector, int pointersCount) { if (!uiSettings.isZoomGesturesEnabled() || pointersCount != 2) { return false; } @@ -807,15 +815,15 @@ final class MapGestureDetector { } } - private Animator createScaleAnimator(double currentZoom, double zoomAddition, final PointF animationFocalPoint, - long animationTime) { + private Animator createScaleAnimator(double currentZoom, double zoomAddition, + @NonNull final PointF animationFocalPoint, long animationTime) { ValueAnimator animator = ValueAnimator.ofFloat((float) currentZoom, (float) (currentZoom + zoomAddition)); animator.setDuration(animationTime); animator.setInterpolator(new DecelerateInterpolator()); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override - public void onAnimationUpdate(ValueAnimator animation) { + public void onAnimationUpdate(@NonNull ValueAnimator animation) { transform.setZoom((Float) animation.getAnimatedValue(), animationFocalPoint); } }); @@ -848,7 +856,7 @@ final class MapGestureDetector { * @param runImmediately if true, animation will be started right away, otherwise it will wait until * {@link MotionEvent#ACTION_UP} is registered. */ - void zoomInAnimated(PointF zoomFocalPoint, boolean runImmediately) { + void zoomInAnimated(@NonNull PointF zoomFocalPoint, boolean runImmediately) { zoomAnimated(true, zoomFocalPoint, runImmediately); } @@ -859,11 +867,11 @@ final class MapGestureDetector { * @param runImmediately if true, animation will be started right away, otherwise it will wait until * {@link MotionEvent#ACTION_UP} is registered. */ - void zoomOutAnimated(PointF zoomFocalPoint, boolean runImmediately) { + void zoomOutAnimated(@NonNull PointF zoomFocalPoint, boolean runImmediately) { zoomAnimated(false, zoomFocalPoint, runImmediately); } - private void zoomAnimated(boolean zoomIn, PointF zoomFocalPoint, boolean runImmediately) { + private void zoomAnimated(boolean zoomIn, @NonNull PointF zoomFocalPoint, boolean runImmediately) { //canceling here as well, because when using a button it will not be canceled automatically by onDown() cancelAnimator(scaleAnimator); @@ -901,7 +909,7 @@ final class MapGestureDetector { && (!uiSettings.isTiltGesturesEnabled() || !gesturesManager.getShoveGestureDetector().isInProgress()); } - private void sendTelemetryEvent(String eventType, PointF focalPoint) { + private void sendTelemetryEvent(String eventType, @NonNull PointF focalPoint) { TelemetryDefinition telemetry = Mapbox.getTelemetry(); if (telemetry != null) { CameraPosition cameraPosition = transform.getCameraPosition(); @@ -919,7 +927,7 @@ final class MapGestureDetector { return mapZoom >= MapboxConstants.MINIMUM_ZOOM && mapZoom <= MapboxConstants.MAXIMUM_ZOOM; } - void notifyOnMapClickListeners(PointF tapPoint) { + void notifyOnMapClickListeners(@NonNull PointF tapPoint) { // deprecated API if (onMapClickListener != null) { onMapClickListener.onMapClick(projection.fromScreenLocation(tapPoint)); @@ -931,7 +939,7 @@ final class MapGestureDetector { } } - void notifyOnMapLongClickListeners(PointF longClickPoint) { + void notifyOnMapLongClickListeners(@NonNull PointF longClickPoint) { // deprecated API if (onMapLongClickListener != null) { onMapLongClickListener.onMapLongClick(projection.fromScreenLocation(longClickPoint)); @@ -967,73 +975,73 @@ final class MapGestureDetector { } } - void notifyOnMoveBeginListeners(MoveGestureDetector detector) { + void notifyOnMoveBeginListeners(@NonNull MoveGestureDetector detector) { for (MapboxMap.OnMoveListener listener : onMoveListenerList) { listener.onMoveBegin(detector); } } - void notifyOnMoveListeners(MoveGestureDetector detector) { + void notifyOnMoveListeners(@NonNull MoveGestureDetector detector) { for (MapboxMap.OnMoveListener listener : onMoveListenerList) { listener.onMove(detector); } } - void notifyOnMoveEndListeners(MoveGestureDetector detector) { + void notifyOnMoveEndListeners(@NonNull MoveGestureDetector detector) { for (MapboxMap.OnMoveListener listener : onMoveListenerList) { listener.onMoveEnd(detector); } } - void notifyOnRotateBeginListeners(RotateGestureDetector detector) { + void notifyOnRotateBeginListeners(@NonNull RotateGestureDetector detector) { for (MapboxMap.OnRotateListener listener : onRotateListenerList) { listener.onRotateBegin(detector); } } - void notifyOnRotateListeners(RotateGestureDetector detector) { + void notifyOnRotateListeners(@NonNull RotateGestureDetector detector) { for (MapboxMap.OnRotateListener listener : onRotateListenerList) { listener.onRotate(detector); } } - void notifyOnRotateEndListeners(RotateGestureDetector detector) { + void notifyOnRotateEndListeners(@NonNull RotateGestureDetector detector) { for (MapboxMap.OnRotateListener listener : onRotateListenerList) { listener.onRotateEnd(detector); } } - void notifyOnScaleBeginListeners(StandardScaleGestureDetector detector) { + void notifyOnScaleBeginListeners(@NonNull StandardScaleGestureDetector detector) { for (MapboxMap.OnScaleListener listener : onScaleListenerList) { listener.onScaleBegin(detector); } } - void notifyOnScaleListeners(StandardScaleGestureDetector detector) { + void notifyOnScaleListeners(@NonNull StandardScaleGestureDetector detector) { for (MapboxMap.OnScaleListener listener : onScaleListenerList) { listener.onScale(detector); } } - void notifyOnScaleEndListeners(StandardScaleGestureDetector detector) { + void notifyOnScaleEndListeners(@NonNull StandardScaleGestureDetector detector) { for (MapboxMap.OnScaleListener listener : onScaleListenerList) { listener.onScaleEnd(detector); } } - void notifyOnShoveBeginListeners(ShoveGestureDetector detector) { + void notifyOnShoveBeginListeners(@NonNull ShoveGestureDetector detector) { for (MapboxMap.OnShoveListener listener : onShoveListenerList) { listener.onShoveBegin(detector); } } - void notifyOnShoveListeners(ShoveGestureDetector detector) { + void notifyOnShoveListeners(@NonNull ShoveGestureDetector detector) { for (MapboxMap.OnShoveListener listener : onShoveListenerList) { listener.onShove(detector); } } - void notifyOnShoveEndListeners(ShoveGestureDetector detector) { + void notifyOnShoveEndListeners(@NonNull ShoveGestureDetector detector) { for (MapboxMap.OnShoveListener listener : onShoveListenerList) { listener.onShoveEnd(detector); } @@ -1123,8 +1131,8 @@ final class MapGestureDetector { return gesturesManager; } - void setGesturesManager(Context context, AndroidGesturesManager gesturesManager, boolean attachDefaultListeners, - boolean setDefaultMutuallyExclusives) { + void setGesturesManager(@NonNull Context context, @NonNull AndroidGesturesManager gesturesManager, + boolean attachDefaultListeners, boolean setDefaultMutuallyExclusives) { initializeGesturesManager(gesturesManager, setDefaultMutuallyExclusives); initializeGestureListeners(context, attachDefaultListeners); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapKeyListener.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapKeyListener.java index 08110ff326..afb80027d9 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapKeyListener.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapKeyListener.java @@ -4,6 +4,7 @@ import android.graphics.PointF; import android.os.Handler; import android.os.Looper; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.ViewConfiguration; @@ -23,6 +24,7 @@ final class MapKeyListener { private final UiSettings uiSettings; private final MapGestureDetector mapGestureDetector; + @Nullable private TrackballLongPressTimeOut currentTrackballLongPressTimeOut; MapKeyListener(Transform transform, UiSettings uiSettings, MapGestureDetector mapGestureDetector) { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java index 1c92b3fe0b..bd44807033 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java @@ -80,7 +80,9 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback { private final CopyOnWriteArrayList<OnMapChangedListener> onMapChangedListeners = new CopyOnWriteArrayList<>(); private final MapChangeReceiver mapChangeReceiver = new MapChangeReceiver(); + @Nullable private NativeMapView nativeMapView; + @Nullable private MapboxMap mapboxMap; private MapboxMapOptions mapboxMapOptions; private MapRenderer mapRenderer; @@ -92,9 +94,12 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback { private ImageView attrView; private ImageView logoView; + @Nullable private MapGestureDetector mapGestureDetector; + @Nullable private MapKeyListener mapKeyListener; private MapZoomButtonController mapZoomButtonController; + @Nullable private Bundle savedInstanceState; @UiThread @@ -231,7 +236,7 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback { }; } - private MapboxMap.OnCompassAnimationListener createCompassAnimationListener(final CameraChangeDispatcher + private MapboxMap.OnCompassAnimationListener createCompassAnimationListener(@NonNull final CameraChangeDispatcher cameraChangeDispatcher) { return new MapboxMap.OnCompassAnimationListener() { @Override @@ -247,7 +252,7 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback { }; } - private OnClickListener createCompassClickListener(final CameraChangeDispatcher cameraChangeDispatcher) { + private OnClickListener createCompassClickListener(@NonNull final CameraChangeDispatcher cameraChangeDispatcher) { return new OnClickListener() { @Override public void onClick(View v) { @@ -460,7 +465,7 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback { } @Override - public boolean onTouchEvent(MotionEvent event) { + public boolean onTouchEvent(@NonNull MotionEvent event) { if (!isMapInitialized() || !isZoomButtonControllerInitialized() || !isGestureDetectorInitialized()) { return super.onTouchEvent(event); } @@ -472,7 +477,7 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback { } @Override - public boolean onKeyDown(int keyCode, KeyEvent event) { + public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) { return mapKeyListener.onKeyDown(keyCode, event) || super.onKeyDown(keyCode, event); } @@ -482,17 +487,17 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback { } @Override - public boolean onKeyUp(int keyCode, KeyEvent event) { + public boolean onKeyUp(int keyCode, @NonNull KeyEvent event) { return mapKeyListener.onKeyUp(keyCode, event) || super.onKeyUp(keyCode, event); } @Override - public boolean onTrackballEvent(MotionEvent event) { + public boolean onTrackballEvent(@NonNull MotionEvent event) { return mapKeyListener.onTrackballEvent(event) || super.onTrackballEvent(event); } @Override - public boolean onGenericMotionEvent(MotionEvent event) { + public boolean onGenericMotionEvent(@NonNull MotionEvent event) { if (!isGestureDetectorInitialized()) { return super.onGenericMotionEvent(event); } @@ -500,7 +505,7 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback { } @Override - public boolean onHoverEvent(MotionEvent event) { + public boolean onHoverEvent(@NonNull MotionEvent event) { if (!isZoomButtonControllerInitialized()) { return super.onHoverEvent(event); } @@ -590,9 +595,9 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback { } } - private void setOfflineRegionDefinition(String styleUrl, LatLng cameraTarget, double minZoom, double maxZoom) { + private void setOfflineRegionDefinition(@NonNull String styleUrl, LatLng latLng, double minZoom, double maxZoom) { CameraPosition cameraPosition = new CameraPosition.Builder() - .target(cameraTarget) + .target(latLng) .zoom(minZoom) .build(); setStyleUrl(styleUrl); @@ -678,6 +683,7 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback { // ViewCallback // + @Nullable @Override public Bitmap getViewContent() { return BitmapUtils.createBitmapFromView(this); @@ -1117,6 +1123,7 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback { return mapGestureDetector != null; } + @Nullable MapboxMap getMapboxMap() { return mapboxMap; } @@ -1658,10 +1665,11 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback { */ private static class AttributionClickListener implements OnClickListener { + @NonNull private final AttributionDialogManager defaultDialogManager; private UiSettings uiSettings; - private AttributionClickListener(Context context, MapboxMap mapboxMap) { + private AttributionClickListener(@NonNull Context context, @NonNull MapboxMap mapboxMap) { this.defaultDialogManager = new AttributionDialogManager(context, mapboxMap); this.uiSettings = mapboxMap.getUiSettings(); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java index c1392be731..ba6339f2fb 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java @@ -77,6 +77,7 @@ public final class MapboxMap { private final OnGesturesManagerInteractionListener onGesturesManagerInteractionListener; private LocationComponent locationComponent; + @Nullable private MapboxMap.OnFpsChangedListener onFpsChangedListener; MapboxMap(NativeMapView map, Transform transform, UiSettings ui, Projection projection, @@ -686,7 +687,7 @@ public final class MapboxMap { * @param update The change that should be applied to the camera. * @see com.mapbox.mapboxsdk.camera.CameraUpdateFactory for a set of updates. */ - public final void easeCamera(CameraUpdate update) { + public final void easeCamera(@NonNull CameraUpdate update) { easeCamera(update, MapboxConstants.ANIMATION_DURATION); } @@ -1064,7 +1065,7 @@ public final class MapboxMap { * @param style The bundled style. * @see Style */ - public void setStyle(@Style.StyleUrl String style) { + public void setStyle(@NonNull @Style.StyleUrl String style) { setStyleUrl(style); } @@ -1080,7 +1081,7 @@ public final class MapboxMap { * @param callback The callback to be invoked when the style has finished loading * @see Style */ - public void setStyle(@Style.StyleUrl String style, @Nullable OnStyleLoadedListener callback) { + public void setStyle(@NonNull @Style.StyleUrl String style, @Nullable OnStyleLoadedListener callback) { setStyleUrl(style, callback); } @@ -1759,7 +1760,7 @@ public final class MapboxMap { */ @NonNull @Deprecated - public CameraPosition getCameraForGeometry(Geometry geometry, double bearing, int[] padding) { + public CameraPosition getCameraForGeometry(@NonNull Geometry geometry, double bearing, @NonNull int[] padding) { return getCameraForGeometry(geometry, padding, bearing, transform.getTilt()); } @@ -2429,7 +2430,7 @@ public final class MapboxMap { * * @param position The CameraPosition at the end of the last camera change. */ - void onCameraChange(CameraPosition position); + void onCameraChange(@NonNull CameraPosition position); } /** @@ -2711,6 +2712,7 @@ public final class MapboxMap { private Context context; private final Class<U> persistentClass; + @NonNull private final Pools.SimplePool<View> viewReusePool; /** @@ -2794,6 +2796,7 @@ public final class MapboxMap { * * @return the pool associated to this adapter */ + @NonNull public final Pools.SimplePool<View> getViewReusePool() { return viewReusePool; } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java index 3fac981fe5..f1d1c1715d 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java @@ -143,6 +143,7 @@ public class MapboxMapOptions implements Parcelable { * @param attrs Attributeset containing configuration * @return the MapboxMapOptions created from attributes */ + @NonNull public static MapboxMapOptions createFromAttributes(@NonNull Context context, @Nullable AttributeSet attrs) { MapboxMapOptions mapboxMapOptions = new MapboxMapOptions(); float pxlRatio = context.getResources().getDisplayMetrics().density; @@ -250,6 +251,7 @@ public class MapboxMapOptions implements Parcelable { * @param apiBaseUrl The base of our API endpoint * @return This */ + @NonNull public MapboxMapOptions apiBaseUrl(String apiBaseUrl) { this.apiBaseUrl = apiBaseUrl; return this; @@ -261,6 +263,7 @@ public class MapboxMapOptions implements Parcelable { * @param cameraPosition Inital camera position * @return This */ + @NonNull public MapboxMapOptions camera(CameraPosition cameraPosition) { this.cameraPosition = cameraPosition; return this; @@ -272,6 +275,7 @@ public class MapboxMapOptions implements Parcelable { * @param styleUrl Url to be used to load a styleUrl * @return This */ + @NonNull public MapboxMapOptions styleUrl(String styleUrl) { this.styleUrl = styleUrl; return this; @@ -283,6 +287,7 @@ public class MapboxMapOptions implements Parcelable { * @param styleJson json to used as style * @return This */ + @NonNull public MapboxMapOptions styleJson(String styleJson) { this.styleJson = styleJson; return this; @@ -294,6 +299,7 @@ public class MapboxMapOptions implements Parcelable { * @param enabled True is debug is enabled * @return This */ + @NonNull public MapboxMapOptions debugActive(boolean enabled) { debugActive = enabled; return this; @@ -305,6 +311,7 @@ public class MapboxMapOptions implements Parcelable { * @param minZoom Zoom level to be used * @return This */ + @NonNull public MapboxMapOptions minZoomPreference(double minZoom) { this.minZoom = minZoom; return this; @@ -316,6 +323,7 @@ public class MapboxMapOptions implements Parcelable { * @param maxZoom Zoom level to be used * @return This */ + @NonNull public MapboxMapOptions maxZoomPreference(double maxZoom) { this.maxZoom = maxZoom; return this; @@ -327,6 +335,7 @@ public class MapboxMapOptions implements Parcelable { * @param enabled True and mapbox_compass_icon is shown * @return This */ + @NonNull public MapboxMapOptions compassEnabled(boolean enabled) { compassEnabled = enabled; return this; @@ -338,6 +347,7 @@ public class MapboxMapOptions implements Parcelable { * @param gravity Android SDK Gravity. * @return This */ + @NonNull public MapboxMapOptions compassGravity(int gravity) { compassGravity = gravity; return this; @@ -349,6 +359,7 @@ public class MapboxMapOptions implements Parcelable { * @param margins 4 long array for LTRB margins * @return This */ + @NonNull public MapboxMapOptions compassMargins(int[] margins) { compassMargins = margins; return this; @@ -363,6 +374,7 @@ public class MapboxMapOptions implements Parcelable { * @param compassFadeWhenFacingNorth true is mapbox_compass_icon fades to invisble * @return This */ + @NonNull public MapboxMapOptions compassFadesWhenFacingNorth(boolean compassFadeWhenFacingNorth) { this.fadeCompassFacingNorth = compassFadeWhenFacingNorth; return this; @@ -377,6 +389,7 @@ public class MapboxMapOptions implements Parcelable { * @param compass the drawable to show as image compass * @return This */ + @NonNull public MapboxMapOptions compassImage(Drawable compass) { this.compassImage = compass; return this; @@ -388,6 +401,7 @@ public class MapboxMapOptions implements Parcelable { * @param enabled True and logo is shown * @return This */ + @NonNull public MapboxMapOptions logoEnabled(boolean enabled) { logoEnabled = enabled; return this; @@ -399,6 +413,7 @@ public class MapboxMapOptions implements Parcelable { * @param gravity Android SDK Gravity. * @return This */ + @NonNull public MapboxMapOptions logoGravity(int gravity) { logoGravity = gravity; return this; @@ -410,6 +425,7 @@ public class MapboxMapOptions implements Parcelable { * @param margins 4 long array for LTRB margins * @return This */ + @NonNull public MapboxMapOptions logoMargins(int[] margins) { logoMargins = margins; return this; @@ -421,6 +437,7 @@ public class MapboxMapOptions implements Parcelable { * @param enabled True and attribution is shown * @return This */ + @NonNull public MapboxMapOptions attributionEnabled(boolean enabled) { attributionEnabled = enabled; return this; @@ -432,6 +449,7 @@ public class MapboxMapOptions implements Parcelable { * @param gravity Android SDK Gravity. * @return This */ + @NonNull public MapboxMapOptions attributionGravity(int gravity) { attributionGravity = gravity; return this; @@ -443,6 +461,7 @@ public class MapboxMapOptions implements Parcelable { * @param margins 4 long array for LTRB margins * @return This */ + @NonNull public MapboxMapOptions attributionMargins(int[] margins) { attributionMargins = margins; return this; @@ -454,6 +473,7 @@ public class MapboxMapOptions implements Parcelable { * @param color integer resembling a color * @return This */ + @NonNull public MapboxMapOptions attributionTintColor(@ColorInt int color) { attributionTintColor = color; return this; @@ -465,6 +485,7 @@ public class MapboxMapOptions implements Parcelable { * @param enabled True and gesture will be enabled * @return This */ + @NonNull public MapboxMapOptions rotateGesturesEnabled(boolean enabled) { rotateGesturesEnabled = enabled; return this; @@ -476,6 +497,7 @@ public class MapboxMapOptions implements Parcelable { * @param enabled True and gesture will be enabled * @return This */ + @NonNull public MapboxMapOptions scrollGesturesEnabled(boolean enabled) { scrollGesturesEnabled = enabled; return this; @@ -487,6 +509,7 @@ public class MapboxMapOptions implements Parcelable { * @param enabled True and gesture will be enabled * @return This */ + @NonNull public MapboxMapOptions tiltGesturesEnabled(boolean enabled) { tiltGesturesEnabled = enabled; return this; @@ -498,6 +521,7 @@ public class MapboxMapOptions implements Parcelable { * @param enabled True and gesture will be enabled * @return This */ + @NonNull public MapboxMapOptions zoomControlsEnabled(boolean enabled) { zoomControlsEnabled = enabled; return this; @@ -509,6 +533,7 @@ public class MapboxMapOptions implements Parcelable { * @param enabled True and gesture will be enabled * @return This */ + @NonNull public MapboxMapOptions zoomGesturesEnabled(boolean enabled) { zoomGesturesEnabled = enabled; return this; @@ -520,6 +545,7 @@ public class MapboxMapOptions implements Parcelable { * @param enabled True and gesture will be enabled * @return This */ + @NonNull public MapboxMapOptions doubleTapGesturesEnabled(boolean enabled) { doubleTapGesturesEnabled = enabled; return this; @@ -538,11 +564,13 @@ public class MapboxMapOptions implements Parcelable { * @param textureMode True to enable texture mode * @return This */ + @NonNull public MapboxMapOptions textureMode(boolean textureMode) { this.textureMode = textureMode; return this; } + @NonNull public MapboxMapOptions translucentTextureSurface(boolean translucentTextureSurface) { this.translucentTextureSurface = translucentTextureSurface; return this; @@ -554,6 +582,7 @@ public class MapboxMapOptions implements Parcelable { * @param loadColor the color to show during map creation * @return This */ + @NonNull public MapboxMapOptions foregroundLoadColor(@ColorInt int loadColor) { this.foregroundLoadColor = loadColor; return this; @@ -567,6 +596,7 @@ public class MapboxMapOptions implements Parcelable { * @param enable true to enable * @return This */ + @NonNull public MapboxMapOptions setPrefetchesTiles(boolean enable) { this.prefetchesTiles = enable; return this; @@ -582,6 +612,7 @@ public class MapboxMapOptions implements Parcelable { * @param crossSourceCollisions true to enable, false to disable * @return This */ + @NonNull public MapboxMapOptions crossSourceCollisions(boolean crossSourceCollisions) { this.crossSourceCollisions = crossSourceCollisions; return this; @@ -597,6 +628,7 @@ public class MapboxMapOptions implements Parcelable { * @param fontFamily font family for local ideograph generation. * @return This */ + @NonNull public MapboxMapOptions localIdeographFontFamily(String fontFamily) { this.localIdeographFontFamily = fontFamily; return this; @@ -609,6 +641,7 @@ public class MapboxMapOptions implements Parcelable { * @param pixelRatio the custom pixel ratio of the map under construction * @return This */ + @NonNull public MapboxMapOptions pixelRatio(float pixelRatio) { this.pixelRatio = pixelRatio; return this; @@ -919,7 +952,7 @@ public class MapboxMapOptions implements Parcelable { } public static final Parcelable.Creator<MapboxMapOptions> CREATOR = new Parcelable.Creator<MapboxMapOptions>() { - public MapboxMapOptions createFromParcel(Parcel in) { + public MapboxMapOptions createFromParcel(@NonNull Parcel in) { return new MapboxMapOptions(in); } @@ -934,7 +967,7 @@ public class MapboxMapOptions implements Parcelable { } @Override - public void writeToParcel(Parcel dest, int flags) { + public void writeToParcel(@NonNull Parcel dest, int flags) { dest.writeParcelable(cameraPosition, flags); dest.writeByte((byte) (debugActive ? 1 : 0)); @@ -978,7 +1011,7 @@ public class MapboxMapOptions implements Parcelable { } @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/maps/MarkerContainer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MarkerContainer.java index 2c2f07a112..8b9ff78aa3 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MarkerContainer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MarkerContainer.java @@ -48,6 +48,7 @@ class MarkerContainer implements Markers { return marker; } + @NonNull @Override public List<Marker> addBy(@NonNull List<? extends BaseMarkerOptions> markerOptionsList, @NonNull MapboxMap mapboxMap) { @@ -82,6 +83,7 @@ class MarkerContainer implements Markers { annotations.setValueAt(annotations.indexOfKey(updatedMarker.getId()), updatedMarker); } + @NonNull @Override public List<Marker> obtainAll() { List<Marker> markers = new ArrayList<>(); @@ -137,6 +139,7 @@ class MarkerContainer implements Markers { return marker; } + @NonNull @Override public List<MarkerView> addViewsBy(@NonNull List<? extends BaseMarkerViewOptions> markerViewOptions, @NonNull MapboxMap mapboxMap) { @@ -160,6 +163,7 @@ class MarkerContainer implements Markers { return markers; } + @NonNull @Override public List<MarkerView> obtainViewsIn(@NonNull RectF rectangle) { float pixelRatio = nativeMapView.getPixelRatio(); @@ -210,12 +214,13 @@ class MarkerContainer implements Markers { return marker; } - private void ensureIconLoaded(Marker marker, MapboxMap mapboxMap) { + private void ensureIconLoaded(Marker marker, @NonNull MapboxMap mapboxMap) { if (!(marker instanceof MarkerView)) { iconManager.ensureIconLoaded(marker, mapboxMap); } } + @NonNull private List<Annotation> obtainAnnotations() { List<Annotation> annotations = new ArrayList<>(); for (int i = 0; i < this.annotations.size(); i++) { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Markers.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Markers.java index d646e0ac49..d85f388d09 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Markers.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Markers.java @@ -25,6 +25,7 @@ interface Markers { List<Marker> obtainAll(); + @NonNull List<Marker> obtainAllIn(@NonNull RectF rectangle); MarkerView addViewBy(@NonNull BaseMarkerViewOptions markerOptions, @NonNull MapboxMap mapboxMap, diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java index 48c571ee98..1ce1f4ba38 100755 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java @@ -50,18 +50,23 @@ final class NativeMapView { private static final String TAG = "Mbgl-NativeMapView"; //Hold a reference to prevent it from being GC'd as long as it's used on the native side + @NonNull private final FileSource fileSource; // Used to schedule work on the MapRenderer Thread + @NonNull private final MapRenderer mapRenderer; // Used to validate if methods are called from the correct thread + @NonNull private final Thread thread; // Used for view callbacks + @NonNull private ViewCallback viewCallback; // Used for map change callbacks + @NonNull private StateCallback stateCallback; // Device density @@ -87,15 +92,16 @@ final class NativeMapView { // Constructors // - public NativeMapView(final Context context, final boolean crossSourceCollisions, final ViewCallback viewCallback, - final StateCallback stateCallback, final MapRenderer mapRenderer) { - this(context, context.getResources().getDisplayMetrics().density, crossSourceCollisions, viewCallback, - stateCallback, mapRenderer); + public NativeMapView(@NonNull final Context context, final boolean crossSourceCollisions, + @NonNull final ViewCallback viewCallback, @NonNull final StateCallback stateCallback, + @NonNull final MapRenderer mapRenderer) { + this(context, context.getResources().getDisplayMetrics().density, + crossSourceCollisions, viewCallback, stateCallback, mapRenderer); } - public NativeMapView(final Context context, final float pixelRatio, final boolean crossSourceCollisions, - final ViewCallback viewCallback, final StateCallback stateCallback, - final MapRenderer mapRenderer) { + public NativeMapView(@NonNull final Context context, final float pixelRatio, final boolean crossSourceCollisions, + @NonNull final ViewCallback viewCallback, @NonNull final StateCallback stateCallback, + @NonNull final MapRenderer mapRenderer) { this.mapRenderer = mapRenderer; this.viewCallback = viewCallback; this.fileSource = FileSource.getInstance(context); @@ -243,14 +249,14 @@ final class NativeMapView { nativeMoveBy(dx / pixelRatio, dy / pixelRatio, duration); } - public void setLatLng(LatLng latLng) { + public void setLatLng(@NonNull LatLng latLng) { if (checkState("setLatLng")) { return; } setLatLng(latLng, 0); } - public void setLatLng(LatLng latLng, long duration) { + public void setLatLng(@NonNull LatLng latLng, long duration) { if (checkState("setLatLng")) { return; } @@ -316,7 +322,7 @@ final class NativeMapView { nativeSetPitch(pitch, duration); } - public void setZoom(double zoom, PointF focalPoint, long duration) { + public void setZoom(double zoom, @NonNull PointF focalPoint, long duration) { if (checkState("setZoom")) { return; } @@ -441,7 +447,8 @@ final class NativeMapView { return nativeAddMarkers(markers)[0]; } - public long[] addMarkers(List<Marker> markers) { + @NonNull + public long[] addMarkers(@NonNull List<Marker> markers) { if (checkState("addMarkers")) { return new long[] {}; } @@ -456,7 +463,8 @@ final class NativeMapView { return nativeAddPolylines(polylines)[0]; } - public long[] addPolylines(List<Polyline> polylines) { + @NonNull + public long[] addPolylines(@NonNull List<Polyline> polylines) { if (checkState("addPolylines")) { return new long[] {}; } @@ -471,14 +479,15 @@ final class NativeMapView { return nativeAddPolygons(polygons)[0]; } - public long[] addPolygons(List<Polygon> polygons) { + @NonNull + public long[] addPolygons(@NonNull List<Polygon> polygons) { if (checkState("addPolygons")) { return new long[] {}; } return nativeAddPolygons(polygons.toArray(new Polygon[polygons.size()])); } - public void updateMarker(Marker marker) { + public void updateMarker(@NonNull Marker marker) { if (checkState("updateMarker")) { return; } @@ -487,14 +496,14 @@ final class NativeMapView { nativeUpdateMarker(marker.getId(), position.getLatitude(), position.getLongitude(), icon.getId()); } - public void updatePolygon(Polygon polygon) { + public void updatePolygon(@NonNull Polygon polygon) { if (checkState("updatePolygon")) { return; } nativeUpdatePolygon(polygon.getId(), polygon); } - public void updatePolyline(Polyline polyline) { + public void updatePolyline(@NonNull Polyline polyline) { if (checkState("updatePolyline")) { return; } @@ -516,6 +525,7 @@ final class NativeMapView { nativeRemoveAnnotations(ids); } + @NonNull public long[] queryPointAnnotations(RectF rect) { if (checkState("queryPointAnnotations")) { return new long[] {}; @@ -523,6 +533,7 @@ final class NativeMapView { return nativeQueryPointAnnotations(rect); } + @NonNull public long[] queryShapeAnnotations(RectF rectF) { if (checkState("queryShapeAnnotations")) { return new long[] {}; @@ -600,14 +611,14 @@ final class NativeMapView { return nativeGetMetersPerPixelAtLatitude(lat, getZoom()) / pixelRatio; } - public ProjectedMeters projectedMetersForLatLng(LatLng latLng) { + public ProjectedMeters projectedMetersForLatLng(@NonNull LatLng latLng) { if (checkState("projectedMetersForLatLng")) { return null; } return nativeProjectedMetersForLatLng(latLng.getLatitude(), latLng.getLongitude()); } - public LatLng latLngForProjectedMeters(ProjectedMeters projectedMeters) { + public LatLng latLngForProjectedMeters(@NonNull ProjectedMeters projectedMeters) { if (checkState("latLngForProjectedMeters")) { return new LatLng(); } @@ -615,7 +626,8 @@ final class NativeMapView { projectedMeters.getEasting()).wrap(); } - public PointF pixelForLatLng(LatLng latLng) { + @NonNull + public PointF pixelForLatLng(@NonNull LatLng latLng) { if (checkState("pixelForLatLng")) { return new PointF(); } @@ -624,7 +636,7 @@ final class NativeMapView { return pointF; } - public LatLng latLngForPixel(PointF pixel) { + public LatLng latLngForPixel(@NonNull PointF pixel) { if (checkState("latLngForPixel")) { return new LatLng(); } @@ -638,14 +650,14 @@ final class NativeMapView { return nativeGetTopOffsetPixelsForAnnotationSymbol(symbolName); } - public void jumpTo(double angle, LatLng center, double pitch, double zoom) { + public void jumpTo(double angle, @NonNull LatLng center, double pitch, double zoom) { if (checkState("jumpTo")) { return; } nativeJumpTo(angle, center.getLatitude(), center.getLongitude(), pitch, zoom); } - public void easeTo(double angle, LatLng center, long duration, double pitch, double zoom, + public void easeTo(double angle, @NonNull LatLng center, long duration, double pitch, double zoom, boolean easingInterpolator) { if (checkState("easeTo")) { return; @@ -654,13 +666,14 @@ final class NativeMapView { easingInterpolator); } - public void flyTo(double angle, LatLng center, long duration, double pitch, double zoom) { + public void flyTo(double angle, @NonNull LatLng center, long duration, double pitch, double zoom) { if (checkState("flyTo")) { return; } nativeFlyTo(angle, center.getLatitude(), center.getLongitude(), duration, pitch, zoom); } + @NonNull public CameraPosition getCameraPosition() { if (checkState("getCameraValues")) { return new CameraPosition.Builder().build(); @@ -1007,7 +1020,7 @@ final class NativeMapView { } @Keep - protected void onSnapshotReady(Bitmap mapContent) { + protected void onSnapshotReady(@Nullable Bitmap mapContent) { if (checkState("OnSnapshotReady")) { return; } @@ -1038,12 +1051,14 @@ final class NativeMapView { @Keep private native void nativeSetStyleUrl(String url); + @NonNull @Keep private native String nativeGetStyleUrl(); @Keep private native void nativeSetStyleJson(String newStyleJson); + @NonNull @Keep private native String nativeGetStyleJson(); @@ -1062,13 +1077,16 @@ final class NativeMapView { @Keep private native void nativeSetLatLng(double latitude, double longitude, long duration); + @NonNull @Keep private native LatLng nativeGetLatLng(); + @NonNull @Keep private native CameraPosition nativeGetCameraForLatLngBounds( LatLngBounds latLngBounds, double top, double left, double bottom, double right, double bearing, double tilt); + @NonNull @Keep private native CameraPosition nativeGetCameraForGeometry( Geometry geometry, double top, double left, double bottom, double right, double bearing, double tilt); @@ -1124,21 +1142,26 @@ final class NativeMapView { @Keep private native void nativeUpdateMarker(long markerId, double lat, double lon, String iconId); + @NonNull @Keep private native long[] nativeAddMarkers(Marker[] markers); + @NonNull @Keep private native long[] nativeAddPolylines(Polyline[] polylines); + @NonNull @Keep private native long[] nativeAddPolygons(Polygon[] polygons); @Keep private native void nativeRemoveAnnotations(long[] id); + @NonNull @Keep private native long[] nativeQueryPointAnnotations(RectF rect); + @NonNull @Keep private native long[] nativeQueryShapeAnnotations(RectF rect); @@ -1173,15 +1196,19 @@ final class NativeMapView { @Keep private native double nativeGetMetersPerPixelAtLatitude(double lat, double zoom); + @NonNull @Keep private native ProjectedMeters nativeProjectedMetersForLatLng(double latitude, double longitude); + @NonNull @Keep private native LatLng nativeLatLngForProjectedMeters(double northing, double easting); + @NonNull @Keep private native PointF nativePixelForLatLng(double lat, double lon); + @NonNull @Keep private native LatLng nativeLatLngForPixel(float x, float y); @@ -1200,6 +1227,7 @@ final class NativeMapView { private native void nativeFlyTo(double angle, double latitude, double longitude, long duration, double pitch, double zoom); + @NonNull @Keep private native CameraPosition nativeGetCameraPosition(); @@ -1215,9 +1243,11 @@ final class NativeMapView { @Keep private native void nativeSetTransitionDelay(long delay); + @NonNull @Keep private native Layer[] nativeGetLayers(); + @NonNull @Keep private native Layer nativeGetLayer(String layerId); @@ -1230,18 +1260,22 @@ final class NativeMapView { @Keep private native void nativeAddLayerAt(long layerPtr, int index) throws CannotAddLayerException; + @NonNull @Keep private native Layer nativeRemoveLayerById(String layerId); @Keep private native void nativeRemoveLayer(long layerId); + @NonNull @Keep private native Layer nativeRemoveLayerAt(int index); + @NonNull @Keep private native Source[] nativeGetSources(); + @NonNull @Keep private native Source nativeGetSource(String sourceId); @@ -1260,6 +1294,7 @@ final class NativeMapView { @Keep private native void nativeRemoveImage(String name); + @NonNull @Keep private native Bitmap nativeGetImage(String name); @@ -1272,17 +1307,20 @@ final class NativeMapView { @Keep private native void nativeTakeSnapshot(); + @NonNull @Keep private native Feature[] nativeQueryRenderedFeaturesForPoint(float x, float y, String[] layerIds, Object[] filter); + @NonNull @Keep private native Feature[] nativeQueryRenderedFeaturesForBox(float left, float top, float right, float bottom, String[] layerIds, Object[] filter); + @NonNull @Keep private native Light nativeGetLight(); @@ -1339,7 +1377,7 @@ final class NativeMapView { nativeTakeSnapshot(); } - public void setOnFpsChangedListener(final MapboxMap.OnFpsChangedListener listener) { + public void setOnFpsChangedListener(@NonNull final MapboxMap.OnFpsChangedListener listener) { final Handler handler = new Handler(); mapRenderer.queueEvent(new Runnable() { @@ -1377,6 +1415,7 @@ final class NativeMapView { this.sdf = sdf; } + @NonNull @Override protected List<Image> doInBackground(HashMap<String, Bitmap>... params) { HashMap<String, Bitmap> bitmapHashMap = params[0]; @@ -1406,7 +1445,7 @@ final class NativeMapView { } @Override - protected void onPostExecute(List<Image> images) { + protected void onPostExecute(@NonNull List<Image> images) { super.onPostExecute(images); if (nativeMapView != null && !nativeMapView.checkState("nativeAddImages")) { nativeMapView.nativeAddImages(images.toArray(new Image[images.size()])); @@ -1419,6 +1458,7 @@ final class NativeMapView { int getHeight(); + @Nullable Bitmap getViewContent(); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/PolygonContainer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/PolygonContainer.java index 016862bddc..2cdcc052fb 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/PolygonContainer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/PolygonContainer.java @@ -36,6 +36,7 @@ class PolygonContainer implements Polygons { return polygon; } + @NonNull @Override public List<Polygon> addBy(@NonNull List<PolygonOptions> polygonOptionsList, @NonNull MapboxMap mapboxMap) { int count = polygonOptionsList.size(); @@ -62,11 +63,12 @@ class PolygonContainer implements Polygons { } @Override - public void update(Polygon polygon) { + public void update(@NonNull Polygon polygon) { nativeMapView.updatePolygon(polygon); annotations.setValueAt(annotations.indexOfKey(polygon.getId()), polygon); } + @NonNull @Override public List<Polygon> obtainAll() { List<Polygon> polygons = new ArrayList<>(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/PolylineContainer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/PolylineContainer.java index 303b25fb55..ed0ceceb1f 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/PolylineContainer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/PolylineContainer.java @@ -36,6 +36,7 @@ class PolylineContainer implements Polylines { return polyline; } + @NonNull @Override public List<Polyline> addBy(@NonNull List<PolylineOptions> polylineOptionsList, @NonNull MapboxMap mapboxMap) { int count = polylineOptionsList.size(); @@ -61,11 +62,12 @@ class PolylineContainer implements Polylines { } @Override - public void update(Polyline polyline) { + public void update(@NonNull Polyline polyline) { nativeMapView.updatePolyline(polyline); annotations.setValueAt(annotations.indexOfKey(polyline.getId()), polyline); } + @NonNull @Override public List<Polyline> obtainAll() { List<Polyline> polylines = new ArrayList<>(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java index 3ecf7354c4..8e3092ae1d 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java @@ -21,6 +21,7 @@ import java.util.List; */ public class Projection { + @NonNull private final NativeMapView nativeMapView; private int[] contentPadding; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/ShapeAnnotationContainer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/ShapeAnnotationContainer.java index 6ded2f32fb..d04860a345 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/ShapeAnnotationContainer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/ShapeAnnotationContainer.java @@ -1,6 +1,7 @@ package com.mapbox.mapboxsdk.maps; import android.graphics.RectF; +import android.support.annotation.NonNull; import android.support.v4.util.LongSparseArray; import com.mapbox.mapboxsdk.annotations.Annotation; @@ -18,13 +19,15 @@ class ShapeAnnotationContainer implements ShapeAnnotations { this.annotations = annotations; } + @NonNull @Override - public List<Annotation> obtainAllIn(RectF rectangle) { + public List<Annotation> obtainAllIn(@NonNull RectF rectangle) { RectF rect = nativeMapView.getDensityDependantRectangle(rectangle); long[] annotationIds = nativeMapView.queryShapeAnnotations(rect); return getAnnotationsFromIds(annotationIds); } + @NonNull private List<Annotation> getAnnotationsFromIds(long[] annotationIds) { List<Annotation> shapeAnnotations = new ArrayList<>(); for (long annotationId : annotationIds) { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/SupportMapFragment.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/SupportMapFragment.java index 0e54002a17..cda59380a9 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/SupportMapFragment.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/SupportMapFragment.java @@ -51,6 +51,7 @@ public class SupportMapFragment extends Fragment implements OnMapReadyCallback { * @param mapboxMapOptions The configuration options to be used. * @return MapFragment created. */ + @NonNull public static SupportMapFragment newInstance(@Nullable MapboxMapOptions mapboxMapOptions) { SupportMapFragment mapFragment = new SupportMapFragment(); mapFragment.setArguments(MapFragmentUtils.createFragmentArgs(mapboxMapOptions)); @@ -78,7 +79,7 @@ public class SupportMapFragment extends Fragment implements OnMapReadyCallback { * @param savedInstanceState The saved instance state for the map fragment. */ @Override - public void onInflate(Context context, AttributeSet attrs, Bundle savedInstanceState) { + public void onInflate(@NonNull Context context, AttributeSet attrs, Bundle savedInstanceState) { super.onInflate(context, attrs, savedInstanceState); setArguments(MapFragmentUtils.createFragmentArgs(MapboxMapOptions.createFromAttributes(context, attrs))); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TelemetryDefinition.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TelemetryDefinition.java index 3918c67129..ae1b210a00 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TelemetryDefinition.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TelemetryDefinition.java @@ -1,5 +1,6 @@ package com.mapbox.mapboxsdk.maps; +import android.support.annotation.NonNull; import com.mapbox.mapboxsdk.offline.OfflineRegionDefinition; /** @@ -20,7 +21,7 @@ public interface TelemetryDefinition { * @param longitude the longitude value of the gesture focal point * @param zoom current zoom of the map */ - void onGestureInteraction(String eventType, double latitude, double longitude, double zoom); + void onGestureInteraction(@NonNull String eventType, double latitude, double longitude, double zoom); /** * Set the end-user selected state to participate or opt-out in telemetry collection. @@ -45,5 +46,5 @@ public interface TelemetryDefinition { * * @param offlineDefinition the offline region definition */ - void onCreateOfflineRegion(OfflineRegionDefinition offlineDefinition); + void onCreateOfflineRegion(@NonNull OfflineRegionDefinition offlineDefinition); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java index 3c039d3de2..14f5495a5b 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java @@ -31,9 +31,12 @@ final class Transform implements MapView.OnMapChangedListener { private final MarkerViewManager markerViewManager; private final Handler handler = new Handler(); + @Nullable private CameraPosition cameraPosition; + @Nullable private MapboxMap.CancelableCallback cameraCancelableCallback; + @Nullable private MapboxMap.OnCameraChangeListener onCameraChangeListener; private CameraChangeDispatcher cameraChangeDispatcher; @@ -58,6 +61,7 @@ final class Transform implements MapView.OnMapChangedListener { // Camera API // + @Nullable @UiThread public final CameraPosition getCameraPosition() { if (cameraPosition == null) { @@ -92,7 +96,8 @@ final class Transform implements MapView.OnMapChangedListener { } @UiThread - final void moveCamera(MapboxMap mapboxMap, CameraUpdate update, final MapboxMap.CancelableCallback callback) { + final void moveCamera(@NonNull MapboxMap mapboxMap, @NonNull CameraUpdate update, + @Nullable final MapboxMap.CancelableCallback callback) { CameraPosition cameraPosition = update.getCameraPosition(mapboxMap); if (isValidCameraPosition(cameraPosition)) { cancelTransitions(); @@ -112,8 +117,9 @@ final class Transform implements MapView.OnMapChangedListener { } @UiThread - final void easeCamera(MapboxMap mapboxMap, CameraUpdate update, int durationMs, boolean easingInterpolator, - final MapboxMap.CancelableCallback callback, boolean isDismissable) { + final void easeCamera(@NonNull MapboxMap mapboxMap, @NonNull CameraUpdate update, int durationMs, + boolean easingInterpolator, @Nullable final MapboxMap.CancelableCallback callback, + boolean isDismissable) { CameraPosition cameraPosition = update.getCameraPosition(mapboxMap); if (isValidCameraPosition(cameraPosition)) { cancelTransitions(); @@ -129,8 +135,8 @@ final class Transform implements MapView.OnMapChangedListener { } @UiThread - final void animateCamera(MapboxMap mapboxMap, CameraUpdate update, int durationMs, - final MapboxMap.CancelableCallback callback) { + final void animateCamera(@NonNull MapboxMap mapboxMap, @NonNull CameraUpdate update, int durationMs, + @Nullable final MapboxMap.CancelableCallback callback) { CameraPosition cameraPosition = update.getCameraPosition(mapboxMap); if (isValidCameraPosition(cameraPosition)) { cancelTransitions(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java index 32fc0589d1..f49481b50a 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java @@ -30,15 +30,21 @@ import com.mapbox.mapboxsdk.utils.ColorUtils; */ public final class UiSettings { + @NonNull private final FocalPointChangeListener focalPointChangeListener; + @NonNull private final Projection projection; + @NonNull private final CompassView compassView; private final int[] compassMargins = new int[4]; + @NonNull private final ImageView attributionsView; private final int[] attributionsMargins = new int[4]; + @Nullable private AttributionDialogManager attributionDialogManager; + @NonNull private final View logoView; private final int[] logoMargins = new int[4]; @@ -65,6 +71,7 @@ public final class UiSettings { private boolean deselectMarkersOnTap = true; + @Nullable private PointF userProvidedFocalPoint; UiSettings(@NonNull Projection projection, @NonNull FocalPointChangeListener listener, @@ -87,7 +94,7 @@ public final class UiSettings { initialiseZoomControl(context); } - void onSaveInstanceState(Bundle outState) { + void onSaveInstanceState(@NonNull Bundle outState) { saveGestures(outState); saveCompass(outState); saveLogo(outState); @@ -144,7 +151,7 @@ public final class UiSettings { savedInstanceState.getBoolean(MapboxConstants.STATE_INCREASE_SCALE_THRESHOLD)); } - private void initialiseCompass(MapboxMapOptions options, Resources resources) { + private void initialiseCompass(MapboxMapOptions options, @NonNull Resources resources) { setCompassEnabled(options.getCompassEnabled()); setCompassGravity(options.getCompassGravity()); int[] compassMargins = options.getCompassMargins(); @@ -185,13 +192,13 @@ public final class UiSettings { compassView.getContext(), savedInstanceState.getByteArray(MapboxConstants.STATE_COMPASS_IMAGE_BITMAP))); } - private void initialiseLogo(MapboxMapOptions options, Resources resources) { + private void initialiseLogo(MapboxMapOptions options, @NonNull Resources resources) { setLogoEnabled(options.getLogoEnabled()); setLogoGravity(options.getLogoGravity()); setLogoMargins(resources, options.getLogoMargins()); } - private void setLogoMargins(Resources resources, int[] logoMargins) { + private void setLogoMargins(@NonNull Resources resources, @Nullable int[] logoMargins) { if (logoMargins != null) { setLogoMargins(logoMargins[0], logoMargins[1], logoMargins[2], logoMargins[3]); } else { @@ -219,7 +226,7 @@ public final class UiSettings { savedInstanceState.getInt(MapboxConstants.STATE_LOGO_MARGIN_BOTTOM)); } - private void initialiseAttribution(Context context, MapboxMapOptions options) { + private void initialiseAttribution(@NonNull Context context, MapboxMapOptions options) { setAttributionEnabled(options.getAttributionEnabled()); setAttributionGravity(options.getAttributionGravity()); setAttributionMargins(context, options.getAttributionMargins()); @@ -228,7 +235,7 @@ public final class UiSettings { ? attributionTintColor : ColorUtils.getPrimaryColor(context)); } - private void setAttributionMargins(Context context, int[] attributionMargins) { + private void setAttributionMargins(@NonNull Context context, @Nullable int[] attributionMargins) { if (attributionMargins != null) { setAttributionMargins(attributionMargins[0], attributionMargins[1], attributionMargins[2], attributionMargins[3]); @@ -544,7 +551,7 @@ public final class UiSettings { * * @param attributionDialogManager the manager class used for showing attribution */ - public void setAttributionDialogManager(@NonNull AttributionDialogManager attributionDialogManager) { + public void setAttributionDialogManager(@Nullable AttributionDialogManager attributionDialogManager) { this.attributionDialogManager = attributionDialogManager; } @@ -553,7 +560,7 @@ public final class UiSettings { * * @return the active manager class used for showing attribution */ - @NonNull + @Nullable public AttributionDialogManager getAttributionDialogManager() { return attributionDialogManager; } @@ -975,6 +982,7 @@ public final class UiSettings { * * @return The focal point */ + @Nullable public PointF getFocalPoint() { return userProvidedFocalPoint; } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRenderer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRenderer.java index 492f653dae..0c529aa464 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRenderer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRenderer.java @@ -4,6 +4,7 @@ import android.content.Context; import android.support.annotation.CallSuper; import android.support.annotation.Keep; +import android.support.annotation.NonNull; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.storage.FileSource; @@ -25,7 +26,7 @@ public abstract class MapRenderer implements MapRendererScheduler { private MapboxMap.OnFpsChangedListener onFpsChangedListener; - public MapRenderer(Context context, String localIdeographFontFamily) { + public MapRenderer(@NonNull Context context, String localIdeographFontFamily) { FileSource fileSource = FileSource.getInstance(context); float pixelRatio = context.getResources().getDisplayMetrics().density; String programCacheDir = FileSource.getInternalCachePath(context); @@ -64,7 +65,7 @@ public abstract class MapRenderer implements MapRendererScheduler { } @CallSuper - protected void onSurfaceChanged(GL10 gl, int width, int height) { + protected void onSurfaceChanged(@NonNull GL10 gl, int width, int height) { gl.glViewport(0, 0, width, height); nativeOnSurfaceChanged(width, height); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRendererScheduler.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRendererScheduler.java index fd12cceee6..80403b575a 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRendererScheduler.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRendererScheduler.java @@ -1,6 +1,7 @@ package com.mapbox.mapboxsdk.maps.renderer; import android.support.annotation.Keep; +import android.support.annotation.NonNull; /** * Can be used to schedule work on the map renderer @@ -12,6 +13,6 @@ public interface MapRendererScheduler { void requestRender(); @Keep - void queueEvent(Runnable runnable); + void queueEvent(@NonNull Runnable runnable); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/egl/EGLConfigChooser.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/egl/EGLConfigChooser.java index 65db8241cf..178911b0ac 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/egl/EGLConfigChooser.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/egl/EGLConfigChooser.java @@ -67,7 +67,7 @@ public class EGLConfigChooser implements GLSurfaceView.EGLConfigChooser { } @Override - public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) { + public EGLConfig chooseConfig(@NonNull EGL10 egl, EGLDisplay display) { int[] configAttribs = getConfigAttributes(); // Determine number of possible configurations @@ -90,6 +90,7 @@ public class EGLConfigChooser implements GLSurfaceView.EGLConfigChooser { return config; } + @NonNull private int[] getNumberOfConfigurations(EGL10 egl, EGLDisplay display, int[] configAttributes) { int[] numConfigs = new int[1]; if (!egl.eglChooseConfig(display, configAttributes, null, 0, numConfigs)) { @@ -101,6 +102,7 @@ public class EGLConfigChooser implements GLSurfaceView.EGLConfigChooser { return numConfigs; } + @NonNull private EGLConfig[] getPossibleConfigurations(EGL10 egl, EGLDisplay display, int[] configAttributes, int[] numConfigs) { EGLConfig[] configs = new EGLConfig[numConfigs[0]]; @@ -139,7 +141,7 @@ public class EGLConfigChooser implements GLSurfaceView.EGLConfigChooser { } } - private EGLConfig chooseBestMatchConfig(EGL10 egl, EGLDisplay display, EGLConfig[] configs) { + private EGLConfig chooseBestMatchConfig(@NonNull EGL10 egl, EGLDisplay display, EGLConfig[] configs) { class Config implements Comparable<Config> { private final BufferFormat bufferFormat; private final DepthStencilFormat depthStencilFormat; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/glsurfaceview/GLSurfaceViewMapRenderer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/glsurfaceview/GLSurfaceViewMapRenderer.java index ed0bed0ac0..584c9dcf57 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/glsurfaceview/GLSurfaceViewMapRenderer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/glsurfaceview/GLSurfaceViewMapRenderer.java @@ -3,6 +3,7 @@ package com.mapbox.mapboxsdk.maps.renderer.glsurfaceview; import android.content.Context; import android.opengl.GLSurfaceView; +import android.support.annotation.NonNull; import com.mapbox.mapboxsdk.maps.renderer.MapRenderer; import com.mapbox.mapboxsdk.maps.renderer.egl.EGLConfigChooser; @@ -19,6 +20,7 @@ import static android.opengl.GLSurfaceView.RENDERMODE_WHEN_DIRTY; */ public class GLSurfaceViewMapRenderer extends MapRenderer implements GLSurfaceView.Renderer { + @NonNull private final GLSurfaceView glSurfaceView; public GLSurfaceViewMapRenderer(Context context, diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/TextureViewRenderThread.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/TextureViewRenderThread.java index 8f4f1c852c..165b15a512 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/TextureViewRenderThread.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/TextureViewRenderThread.java @@ -2,6 +2,7 @@ package com.mapbox.mapboxsdk.maps.renderer.textureview; import android.graphics.SurfaceTexture; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.annotation.UiThread; import android.view.TextureView; import com.mapbox.mapboxsdk.log.Logger; @@ -26,7 +27,9 @@ class TextureViewRenderThread extends Thread implements TextureView.SurfaceTextu private static final String TAG = "Mbgl-TextureViewRenderThread"; + @NonNull private final TextureViewMapRenderer mapRenderer; + @NonNull private final EGLHolder eglHolder; // Lock used for synchronization @@ -34,6 +37,7 @@ class TextureViewRenderThread extends Thread implements TextureView.SurfaceTextu // Guarded by lock private final ArrayList<Runnable> eventQueue = new ArrayList<>(); + @Nullable private SurfaceTexture surface; private int width; private int height; @@ -118,7 +122,7 @@ class TextureViewRenderThread extends Thread implements TextureView.SurfaceTextu /** * May be called from any thread */ - void queueEvent(Runnable runnable) { + void queueEvent(@NonNull Runnable runnable) { if (runnable == null) { throw new IllegalArgumentException("runnable must not be null"); } @@ -328,6 +332,7 @@ class TextureViewRenderThread extends Thread implements TextureView.SurfaceTextu private boolean translucentSurface; private EGL10 egl; + @Nullable private EGLConfig eglConfig; private EGLDisplay eglDisplay = EGL10.EGL_NO_DISPLAY; private EGLContext eglContext = EGL10.EGL_NO_CONTEXT; @@ -370,6 +375,7 @@ class TextureViewRenderThread extends Thread implements TextureView.SurfaceTextu } } + @NonNull GL10 createGL() { return (GL10) eglContext.getGL(); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/CompassView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/CompassView.java index fb2c70cb73..a7eecfd958 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/CompassView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/CompassView.java @@ -4,6 +4,7 @@ import android.annotation.SuppressLint; import android.content.Context; import android.graphics.drawable.Drawable; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.v4.view.ViewCompat; import android.support.v4.view.ViewPropertyAnimatorCompat; import android.support.v4.view.ViewPropertyAnimatorListenerAdapter; @@ -32,21 +33,22 @@ public final class CompassView extends ImageView implements Runnable { private float rotation = 0.0f; private boolean fadeCompassViewFacingNorth = true; + @Nullable private ViewPropertyAnimatorCompat fadeAnimator; private MapboxMap.OnCompassAnimationListener compassAnimationListener; private boolean isAnimating = false; - public CompassView(Context context) { + public CompassView(@NonNull Context context) { super(context); initialize(context); } - public CompassView(Context context, AttributeSet attrs) { + public CompassView(@NonNull Context context, AttributeSet attrs) { super(context, attrs); initialize(context); } - public CompassView(Context context, AttributeSet attrs, int defStyleAttr) { + public CompassView(@NonNull Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); initialize(context); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/http/HttpRequestImpl.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/http/HttpRequestImpl.java index 3195022d3a..62ad1222cc 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/http/HttpRequestImpl.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/http/HttpRequestImpl.java @@ -2,6 +2,7 @@ package com.mapbox.mapboxsdk.module.http; import android.os.Build; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.text.TextUtils; import android.util.Log; import com.mapbox.mapboxsdk.BuildConfig; @@ -46,8 +47,8 @@ public class HttpRequestImpl implements HttpRequest { private Call call; @Override - public void executeRequest(HttpResponder httpRequest, long nativePtr, String resourceUrl, - String etag, String modified) { + public void executeRequest(HttpResponder httpRequest, long nativePtr, @NonNull String resourceUrl, + @NonNull String etag, @NonNull String modified) { OkHttpCallback callback = new OkHttpCallback(httpRequest); try { HttpUrl httpUrl = HttpUrl.parse(resourceUrl); @@ -147,7 +148,7 @@ public class HttpRequestImpl implements HttpRequest { body); } - private void handleFailure(Call call, Exception e) { + private void handleFailure(@Nullable Call call, Exception e) { String errorMessage = e.getMessage() != null ? e.getMessage() : "Error processing the request"; int type = getFailureType(e); @@ -169,6 +170,7 @@ public class HttpRequestImpl implements HttpRequest { } } + @NonNull private static Dispatcher getDispatcher() { Dispatcher dispatcher = new Dispatcher(); // Matches core limit set on diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/http/HttpRequestUtil.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/http/HttpRequestUtil.java index 66031ea724..6fdaca138e 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/http/HttpRequestUtil.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/http/HttpRequestUtil.java @@ -1,5 +1,6 @@ package com.mapbox.mapboxsdk.module.http; +import android.support.annotation.NonNull; import okhttp3.OkHttpClient; import okio.Buffer; @@ -44,6 +45,7 @@ public class HttpRequestUtil { HttpRequestImpl.setOkHttpClient(client); } + @NonNull static String toHumanReadableAscii(String s) { for (int i = 0, length = s.length(), c; i < length; i += Character.charCount(c)) { c = s.codePointAt(i); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/TelemetryImpl.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/TelemetryImpl.java index e8e0504157..1b13591b81 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/TelemetryImpl.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/TelemetryImpl.java @@ -1,6 +1,8 @@ package com.mapbox.mapboxsdk.module.telemetry; import android.content.Context; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import com.mapbox.android.telemetry.AppUserTurnstile; import com.mapbox.android.telemetry.Event; import com.mapbox.android.telemetry.MapEventFactory; @@ -23,6 +25,7 @@ public class TelemetryImpl implements TelemetryDefinition { private static final String TAG = "Mbgl-TelemetryImpl"; private static TelemetryImpl instance; + @Nullable private MapboxTelemetry telemetry; /** @@ -154,7 +157,7 @@ public class TelemetryImpl implements TelemetryDefinition { * @deprecated use {@link #setSessionIdRotationInterval(int)} instead */ @Deprecated - public static boolean updateSessionIdRotationInterval(SessionInterval interval) { + public static boolean updateSessionIdRotationInterval(@NonNull SessionInterval interval) { try { Field field = interval.getClass().getDeclaredField("interval"); field.setAccessible(true); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/net/ConnectivityReceiver.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/net/ConnectivityReceiver.java index 08be617560..bf7341ac96 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/net/ConnectivityReceiver.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/net/ConnectivityReceiver.java @@ -32,7 +32,7 @@ public class ConnectivityReceiver extends BroadcastReceiver { * @param context the context to extract the application context from * @return single instance of ConnectivityReceiver */ - public static synchronized ConnectivityReceiver instance(Context context) { + public static synchronized ConnectivityReceiver instance(@NonNull Context context) { if (INSTANCE == null) { // Register new instance INSTANCE = new ConnectivityReceiver(context.getApplicationContext()); @@ -43,6 +43,7 @@ public class ConnectivityReceiver extends BroadcastReceiver { return INSTANCE; } + @NonNull private List<ConnectivityListener> listeners = new CopyOnWriteArrayList<>(); private Context context; private int activationCounter; @@ -83,7 +84,7 @@ public class ConnectivityReceiver extends BroadcastReceiver { * {@inheritDoc} */ @Override - public void onReceive(Context context, Intent intent) { + public void onReceive(@NonNull Context context, Intent intent) { boolean connected = isConnected(context); Logger.v(TAG, String.format("Connected: %s", connected)); @@ -117,7 +118,7 @@ public class ConnectivityReceiver extends BroadcastReceiver { * @param context current Context * @return true if connected */ - public boolean isConnected(Context context) { + public boolean isConnected(@NonNull Context context) { Boolean connected = Mapbox.isConnected(); if (connected != null) { // Connectivity state overridden by app diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineGeometryRegionDefinition.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineGeometryRegionDefinition.java index 73e277dda3..4fa15602ba 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineGeometryRegionDefinition.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineGeometryRegionDefinition.java @@ -4,6 +4,8 @@ import android.os.Parcel; import android.os.Parcelable; import android.support.annotation.Keep; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import com.mapbox.geojson.Feature; import com.mapbox.geojson.Geometry; import com.mapbox.mapboxsdk.geometry.LatLngBounds; @@ -24,6 +26,7 @@ public class OfflineGeometryRegionDefinition implements OfflineRegionDefinition, @Keep private String styleURL; + @Nullable @Keep private Geometry geometry; @Keep @@ -74,6 +77,7 @@ public class OfflineGeometryRegionDefinition implements OfflineRegionDefinition, return styleURL; } + @Nullable public Geometry getGeometry() { return geometry; } @@ -83,6 +87,7 @@ public class OfflineGeometryRegionDefinition implements OfflineRegionDefinition, * to retain backwards compatibility * @return the {@link LatLngBounds} or null */ + @Nullable @Override public LatLngBounds getBounds() { if (geometry == null) { @@ -115,7 +120,7 @@ public class OfflineGeometryRegionDefinition implements OfflineRegionDefinition, } @Override - public void writeToParcel(Parcel dest, int flags) { + public void writeToParcel(@NonNull Parcel dest, int flags) { dest.writeString(styleURL); dest.writeString(Feature.fromGeometry(geometry).toJson()); dest.writeDouble(minZoom); @@ -124,7 +129,7 @@ public class OfflineGeometryRegionDefinition implements OfflineRegionDefinition, } public static final Creator CREATOR = new Creator() { - public OfflineGeometryRegionDefinition createFromParcel(Parcel in) { + public OfflineGeometryRegionDefinition createFromParcel(@NonNull Parcel in) { return new OfflineGeometryRegionDefinition(in); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java index 01258b917e..06fb737c52 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java @@ -161,7 +161,7 @@ public class OfflineManager { * @param context the context used to host the offline manager * @return the single instance of offline manager */ - public static synchronized OfflineManager getInstance(Context context) { + public static synchronized OfflineManager getInstance(@NonNull Context context) { if (instance == null) { instance = new OfflineManager(context); } @@ -267,7 +267,9 @@ public class OfflineManager { } private static final class CopyTempDatabaseFileTask extends AsyncTask<Object, Void, Object> { + @NonNull private final WeakReference<OfflineManager> offlineManagerWeakReference; + @NonNull private final WeakReference<MergeOfflineRegionsCallback> callbackWeakReference; CopyTempDatabaseFileTask(OfflineManager offlineManager, MergeOfflineRegionsCallback callback) { @@ -305,7 +307,7 @@ public class OfflineManager { } } - private static void copyTempDatabaseFile(File sourceFile, File destFile) throws IOException { + private static void copyTempDatabaseFile(@NonNull File sourceFile, File destFile) throws IOException { if (!destFile.exists() && !destFile.createNewFile()) { throw new IOException("Unable to copy database file for merge."); } @@ -380,7 +382,7 @@ public class OfflineManager { * @param callback the callback to be invoked */ public void createOfflineRegion(@NonNull OfflineRegionDefinition definition, @NonNull byte[] metadata, - final CreateOfflineRegionCallback callback) { + @NonNull final CreateOfflineRegionCallback callback) { if (!isValidOfflineRegionDefinition(definition)) { callback.onError( String.format(context.getString(R.string.mapbox_offline_error_region_definition_invalid), diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineTilePyramidRegionDefinition.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineTilePyramidRegionDefinition.java index b0d12859ed..57fc8298f4 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineTilePyramidRegionDefinition.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineTilePyramidRegionDefinition.java @@ -4,6 +4,7 @@ import android.os.Parcel; import android.os.Parcelable; import android.support.annotation.Keep; +import android.support.annotation.NonNull; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.geometry.LatLngBounds; @@ -101,7 +102,7 @@ public class OfflineTilePyramidRegionDefinition implements OfflineRegionDefiniti } @Override - public void writeToParcel(Parcel dest, int flags) { + public void writeToParcel(@NonNull Parcel dest, int flags) { dest.writeString(styleURL); dest.writeDouble(bounds.getLatNorth()); dest.writeDouble(bounds.getLonEast()); @@ -113,7 +114,7 @@ public class OfflineTilePyramidRegionDefinition implements OfflineRegionDefiniti } public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - public OfflineTilePyramidRegionDefinition createFromParcel(Parcel in) { + public OfflineTilePyramidRegionDefinition createFromParcel(@NonNull Parcel in) { return new OfflineTilePyramidRegionDefinition(in); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshot.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshot.java index f3acf829bf..4da835a5f1 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshot.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshot.java @@ -4,6 +4,7 @@ import android.graphics.Bitmap; import android.graphics.PointF; import android.support.annotation.Keep; +import android.support.annotation.NonNull; import com.mapbox.mapboxsdk.geometry.LatLng; /** @@ -43,6 +44,7 @@ public class MapSnapshot { * @param latLng the geographical coordinates * @return the point on the image */ + @NonNull @Keep public native PointF pixelForLatLng(LatLng latLng); @@ -52,6 +54,7 @@ public class MapSnapshot { * @param pointF the point in pixels * @return the geographical coordinates */ + @NonNull @Keep public native LatLng latLngForPixel(PointF pointF); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotter.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotter.java index fac6a75742..c07cc5e606 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotter.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotter.java @@ -50,7 +50,7 @@ public class MapSnapshotter { * * @param snapshot the snapshot */ - void onSnapshotReady(MapSnapshot snapshot); + void onSnapshotReady(@NonNull MapSnapshot snapshot); } @@ -68,7 +68,7 @@ public class MapSnapshotter { * * @param error the error message */ - void onError(String error); + void onError(@NonNull String error); } private static final int LOGO_MARGIN_DP = 4; @@ -78,7 +78,9 @@ public class MapSnapshotter { private long nativePtr = 0; private final Context context; + @Nullable private SnapshotReadyCallback callback; + @Nullable private ErrorHandler errorHandler; /** @@ -110,6 +112,7 @@ public class MapSnapshotter { * @param url The style URL to use * @return the mutated {@link Options} */ + @NonNull public Options withStyle(String url) { this.styleUrl = url; return this; @@ -119,6 +122,7 @@ public class MapSnapshotter { * @param styleJson The style json to use * @return the mutated {@link Options} */ + @NonNull public Options withStyleJson(String styleJson) { this.styleJson = styleJson; return this; @@ -129,6 +133,7 @@ public class MapSnapshotter { * This is applied after the camera position * @return the mutated {@link Options} */ + @NonNull public Options withRegion(LatLngBounds region) { this.region = region; return this; @@ -138,6 +143,7 @@ public class MapSnapshotter { * @param pixelRatio the pixel ratio to use (default: 1) * @return the mutated {@link Options} */ + @NonNull public Options withPixelRatio(float pixelRatio) { this.pixelRatio = pixelRatio; return this; @@ -149,6 +155,7 @@ public class MapSnapshotter { * by region if set in conjunction. * @return the mutated {@link Options} */ + @NonNull public Options withCameraPosition(CameraPosition cameraPosition) { this.cameraPosition = cameraPosition; return this; @@ -158,6 +165,7 @@ public class MapSnapshotter { * @param showLogo The flag indicating to show the Mapbox logo. * @return the mutated {@link Options} */ + @NonNull public Options withLogo(boolean showLogo) { this.showLogo = showLogo; return this; @@ -309,21 +317,24 @@ public class MapSnapshotter { * * @param mapSnapshot the map snapshot to draw the overlay on */ - protected void addOverlay(MapSnapshot mapSnapshot) { + protected void addOverlay(@NonNull MapSnapshot mapSnapshot) { Bitmap snapshot = mapSnapshot.getBitmap(); Canvas canvas = new Canvas(snapshot); int margin = (int) context.getResources().getDisplayMetrics().density * LOGO_MARGIN_DP; drawOverlay(mapSnapshot, snapshot, canvas, margin); } - private void drawOverlay(MapSnapshot mapSnapshot, Bitmap snapshot, Canvas canvas, int margin) { + private void drawOverlay(@NonNull MapSnapshot mapSnapshot, @NonNull Bitmap snapshot, + @NonNull Canvas canvas, int margin) { AttributionMeasure measure = getAttributionMeasure(mapSnapshot, snapshot, margin); AttributionLayout layout = measure.measure(); drawLogo(mapSnapshot, canvas, margin, layout); drawAttribution(mapSnapshot, canvas, measure, layout); } - private AttributionMeasure getAttributionMeasure(MapSnapshot mapSnapshot, Bitmap snapshot, int margin) { + @NonNull + private AttributionMeasure getAttributionMeasure(@NonNull MapSnapshot mapSnapshot, @NonNull Bitmap snapshot, + int margin) { Logo logo = createScaledLogo(snapshot); TextView longText = createTextView(mapSnapshot, false, logo.getScale()); TextView shortText = createTextView(mapSnapshot, true, logo.getScale()); @@ -338,21 +349,22 @@ public class MapSnapshotter { .build(); } - private void drawLogo(MapSnapshot mapSnapshot, Canvas canvas, int margin, AttributionLayout layout) { + private void drawLogo(MapSnapshot mapSnapshot, @NonNull Canvas canvas, int margin, + @NonNull AttributionLayout layout) { if (mapSnapshot.isShowLogo()) { drawLogo(mapSnapshot.getBitmap(), canvas, margin, layout); } } - private void drawLogo(Bitmap snapshot, Canvas canvas, int margin, AttributionLayout placement) { + private void drawLogo(@NonNull Bitmap snapshot, @NonNull Canvas canvas, int margin, AttributionLayout placement) { Bitmap selectedLogo = placement.getLogo(); if (selectedLogo != null) { canvas.drawBitmap(selectedLogo, margin, snapshot.getHeight() - selectedLogo.getHeight() - margin, null); } } - private void drawAttribution(MapSnapshot mapSnapshot, Canvas canvas, - AttributionMeasure measure, AttributionLayout layout) { + private void drawAttribution(@NonNull MapSnapshot mapSnapshot, @NonNull Canvas canvas, + @NonNull AttributionMeasure measure, @NonNull AttributionLayout layout) { // draw attribution PointF anchorPoint = layout.getAnchorPoint(); if (anchorPoint != null) { @@ -373,7 +385,8 @@ public class MapSnapshotter { canvas.restore(); } - private TextView createTextView(MapSnapshot mapSnapshot, boolean shortText, float scale) { + @NonNull + private TextView createTextView(@NonNull MapSnapshot mapSnapshot, boolean shortText, float scale) { int textColor = ResourcesCompat.getColor(context.getResources(), R.color.mapbox_gray_dark, context.getTheme()); int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); @@ -399,6 +412,7 @@ public class MapSnapshotter { * @param shortText indicates if the short variant of the string should be parsed * @return the parsed attribution string */ + @NonNull private String createAttributionString(MapSnapshot mapSnapshot, boolean shortText) { AttributionParser attributionParser = new AttributionParser.Options() .withAttributionData(mapSnapshot.getAttributions()) @@ -457,7 +471,7 @@ public class MapSnapshotter { * @param snapshot the generated snapshot */ @Keep - protected void onSnapshotReady(final MapSnapshot snapshot) { + protected void onSnapshotReady(@NonNull final MapSnapshot snapshot) { new Handler().post(new Runnable() { @Override public void run() { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/storage/FileSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/storage/FileSource.java index c242ef3699..ec75f66112 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/storage/FileSource.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/storage/FileSource.java @@ -8,6 +8,7 @@ import android.os.AsyncTask; import android.os.Environment; import android.support.annotation.Keep; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.annotation.UiThread; import com.mapbox.mapboxsdk.MapStrictMode; @@ -29,6 +30,7 @@ public class FileSource { private static final String TAG = "Mbgl-FileSource"; private static final Lock resourcesCachePathLoaderLock = new ReentrantLock(); private static final Lock internalCachePathLoaderLock = new ReentrantLock(); + @Nullable private static String resourcesCachePath; private static String internalCachePath; @@ -61,7 +63,7 @@ public class FileSource { * @return the single instance of FileSource */ @UiThread - public static synchronized FileSource getInstance(Context context) { + public static synchronized FileSource getInstance(@NonNull Context context) { if (INSTANCE == null) { INSTANCE = new FileSource(getResourcesCachePath(context), context.getResources().getAssets()); } @@ -76,8 +78,9 @@ public class FileSource { * @return the files directory path * @deprecated Use {@link #getResourcesCachePath(Context)} instead. */ + @Nullable @Deprecated - public static String getCachePath(Context context) { + public static String getCachePath(@NonNull Context context) { // Default value boolean setStorageExternal = MapboxConstants.DEFAULT_SET_STORAGE_EXTERNAL; @@ -159,6 +162,7 @@ public class FileSource { unlockPathLoaders(); } + @NonNull @Override protected String[] doInBackground(Context... contexts) { return new String[] { @@ -181,7 +185,8 @@ public class FileSource { * @param context the context to derive the files directory path from * @return the files directory path */ - public static String getResourcesCachePath(Context context) { + @Nullable + public static String getResourcesCachePath(@NonNull Context context) { resourcesCachePathLoaderLock.lock(); try { if (resourcesCachePath == null) { @@ -199,7 +204,7 @@ public class FileSource { * @param context the context to derive the internal cache path from * @return the internal cache path */ - public static String getInternalCachePath(Context context) { + public static String getInternalCachePath(@NonNull Context context) { internalCachePathLoaderLock.lock(); try { if (internalCachePath == null) { @@ -240,6 +245,7 @@ public class FileSource { @Keep public native void setAccessToken(@NonNull String accessToken); + @NonNull @Keep public native String getAccessToken(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/expressions/Expression.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/expressions/Expression.java index bdeeeb0926..c71dc3ce82 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/expressions/Expression.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/expressions/Expression.java @@ -90,7 +90,9 @@ import java.util.Map; */ public class Expression { + @Nullable private final String operator; + @Nullable private final Expression[] arguments; /** @@ -435,7 +437,7 @@ public class Expression { * @return expression * @see <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions-==">Style specification</a> */ - public static Expression eq(Expression compareOne, boolean compareTwo) { + public static Expression eq(@NonNull Expression compareOne, boolean compareTwo) { return eq(compareOne, literal(compareTwo)); } @@ -2234,7 +2236,7 @@ public class Expression { * @return expression * @see <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions-ln">Style specification</a> */ - public static Expression ln(Number number) { + public static Expression ln(@NonNull Number number) { return ln(literal(number)); } @@ -2686,7 +2688,7 @@ public class Expression { * @return expression * @see <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions-round">Style specification</a> */ - public static Expression round(Number number) { + public static Expression round(@NonNull Number number) { return round(literal(number)); } @@ -2730,7 +2732,7 @@ public class Expression { * @return expression * @see <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions-abs">Style specification</a> */ - public static Expression abs(Number number) { + public static Expression abs(@NonNull Number number) { return abs(literal(number)); } @@ -2774,7 +2776,7 @@ public class Expression { * @return expression * @see <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions-abs">Style specification</a> */ - public static Expression ceil(Number number) { + public static Expression ceil(@NonNull Number number) { return ceil(literal(number)); } @@ -2818,7 +2820,7 @@ public class Expression { * @return expression * @see <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions-abs">Style specification</a> */ - public static Expression floor(Number number) { + public static Expression floor(@NonNull Number number) { return floor(literal(number)); } @@ -2904,7 +2906,7 @@ public class Expression { * @return expression * @see <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions-is-supported-script">Style specification</a> */ - public static Expression isSupportedScript(String string) { + public static Expression isSupportedScript(@NonNull String string) { return new Expression("is-supported-script", literal(string)); } @@ -3495,7 +3497,7 @@ public class Expression { * @return expression * @see <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions-step">Style specification</a> */ - public static Expression step(@NonNull Expression input, @NonNull Expression defaultOutput, Expression... stops) { + public static Expression step(@NonNull Expression input, @NonNull Expression defaultOutput, @NonNull Expression... stops) { return new Expression("step", join(new Expression[] {input, defaultOutput}, stops)); } @@ -3722,7 +3724,7 @@ public class Expression { * @see <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions-interpolate">Style specification</a> */ public static Expression interpolate(@NonNull Interpolator interpolation, - @NonNull Expression number, Expression... stops) { + @NonNull Expression number, @NonNull Expression... stops) { return new Expression("interpolate", join(new Expression[] {interpolation, number}, stops)); } @@ -3929,6 +3931,7 @@ public class Expression { * @param right the right part of an expression * @return the joined expression */ + @NonNull private static Expression[] join(Expression[] left, Expression[] right) { Expression[] output = new Expression[left.length + right.length]; System.arraycopy(left, 0, output, 0, left.length); @@ -4021,7 +4024,7 @@ public class Expression { * @return true if equal, false if not */ @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { super.equals(o); if (this == o) { return true; @@ -4121,7 +4124,7 @@ public class Expression { * @return true if equal, false if not */ @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } @@ -4149,6 +4152,7 @@ public class Expression { return result; } + @NonNull private static String unwrapStringLiteral(String value) { if (value.length() > 1 && value.charAt(0) == '\"' && value.charAt(value.length() - 1) == '\"') { @@ -4201,6 +4205,7 @@ public class Expression { * @param stops the stops to convert * @return the converted stops as an expression array */ + @NonNull static Expression[] toExpressionArray(Stop... stops) { Expression[] expressions = new Expression[stops.length * 2]; Stop stop; @@ -4332,6 +4337,7 @@ public class Expression { * * @return the string representation of the expression array */ + @NonNull @Override public String toString() { StringBuilder builder = new StringBuilder("[\"literal\"], ["); @@ -4363,6 +4369,7 @@ public class Expression { this.map = map; } + @NonNull @Override public Object toValue() { Map<String, Object> unwrappedMap = new HashMap<>(); @@ -4378,6 +4385,7 @@ public class Expression { return unwrappedMap; } + @NonNull @Override public String toString() { StringBuilder builder = new StringBuilder(); @@ -4397,7 +4405,7 @@ public class Expression { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } @@ -4432,6 +4440,7 @@ public class Expression { * @param object the object to convert to an object array * @return the converted object array */ + @NonNull static Object[] toObjectArray(Object object) { // object is a primitive array int len = java.lang.reflect.Array.getLength(object); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/BackgroundLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/BackgroundLayer.java index dd20a4b957..a89f012fe6 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/BackgroundLayer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/BackgroundLayer.java @@ -51,6 +51,7 @@ public class BackgroundLayer extends Layer { * @param properties the var-args properties * @return This */ + @NonNull public BackgroundLayer withProperties(@NonNull PropertyValue<?>... properties) { setProperties(properties); return this; @@ -63,6 +64,7 @@ public class BackgroundLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getBackgroundColor() { checkThread(); @@ -91,6 +93,7 @@ public class BackgroundLayer extends Layer { * * @return transition options for String */ + @NonNull public TransitionOptions getBackgroundColorTransition() { checkThread(); return nativeGetBackgroundColorTransition(); @@ -101,7 +104,7 @@ public class BackgroundLayer extends Layer { * * @param options transition options for String */ - public void setBackgroundColorTransition(TransitionOptions options) { + public void setBackgroundColorTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetBackgroundColorTransition(options.getDuration(), options.getDelay()); } @@ -111,6 +114,7 @@ public class BackgroundLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getBackgroundPattern() { checkThread(); @@ -122,6 +126,7 @@ public class BackgroundLayer extends Layer { * * @return transition options for String */ + @NonNull public TransitionOptions getBackgroundPatternTransition() { checkThread(); return nativeGetBackgroundPatternTransition(); @@ -132,7 +137,7 @@ public class BackgroundLayer extends Layer { * * @param options transition options for String */ - public void setBackgroundPatternTransition(TransitionOptions options) { + public void setBackgroundPatternTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetBackgroundPatternTransition(options.getDuration(), options.getDelay()); } @@ -142,6 +147,7 @@ public class BackgroundLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getBackgroundOpacity() { checkThread(); @@ -153,6 +159,7 @@ public class BackgroundLayer extends Layer { * * @return transition options for Float */ + @NonNull public TransitionOptions getBackgroundOpacityTransition() { checkThread(); return nativeGetBackgroundOpacityTransition(); @@ -163,32 +170,38 @@ public class BackgroundLayer extends Layer { * * @param options transition options for Float */ - public void setBackgroundOpacityTransition(TransitionOptions options) { + public void setBackgroundOpacityTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetBackgroundOpacityTransition(options.getDuration(), options.getDelay()); } + @NonNull @Keep private native Object nativeGetBackgroundColor(); + @NonNull @Keep private native TransitionOptions nativeGetBackgroundColorTransition(); @Keep private native void nativeSetBackgroundColorTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetBackgroundPattern(); + @NonNull @Keep private native TransitionOptions nativeGetBackgroundPatternTransition(); @Keep private native void nativeSetBackgroundPatternTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetBackgroundOpacity(); + @NonNull @Keep private native TransitionOptions nativeGetBackgroundOpacityTransition(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/CircleLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/CircleLayer.java index 4718adc5c1..76f7b2f9fa 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/CircleLayer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/CircleLayer.java @@ -62,6 +62,7 @@ public class CircleLayer extends Layer { * @param sourceLayer the source layer to set * @return This */ + @NonNull public CircleLayer withSourceLayer(String sourceLayer) { setSourceLayer(sourceLayer); return this; @@ -72,6 +73,7 @@ public class CircleLayer extends Layer { * * @return id of the source */ + @NonNull public String getSourceId() { checkThread(); return nativeGetSourceId(); @@ -82,6 +84,7 @@ public class CircleLayer extends Layer { * * @return sourceLayer the source layer to get */ + @NonNull public String getSourceLayer() { checkThread(); return nativeGetSourceLayer(); @@ -92,7 +95,7 @@ public class CircleLayer extends Layer { * * @param filter the expression filter to set */ - public void setFilter(Expression filter) { + public void setFilter(@NonNull Expression filter) { checkThread(); nativeSetFilter(filter.toArray()); } @@ -103,7 +106,8 @@ public class CircleLayer extends Layer { * @param filter the expression filter to set * @return This */ - public CircleLayer withFilter(Expression filter) { + @NonNull + public CircleLayer withFilter(@NonNull Expression filter) { setFilter(filter); return this; } @@ -130,6 +134,7 @@ public class CircleLayer extends Layer { * @param properties the var-args properties * @return This */ + @NonNull public CircleLayer withProperties(@NonNull PropertyValue<?>... properties) { setProperties(properties); return this; @@ -142,6 +147,7 @@ public class CircleLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getCircleRadius() { checkThread(); @@ -153,6 +159,7 @@ public class CircleLayer extends Layer { * * @return transition options for Float */ + @NonNull public TransitionOptions getCircleRadiusTransition() { checkThread(); return nativeGetCircleRadiusTransition(); @@ -163,7 +170,7 @@ public class CircleLayer extends Layer { * * @param options transition options for Float */ - public void setCircleRadiusTransition(TransitionOptions options) { + public void setCircleRadiusTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetCircleRadiusTransition(options.getDuration(), options.getDelay()); } @@ -173,6 +180,7 @@ public class CircleLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getCircleColor() { checkThread(); @@ -201,6 +209,7 @@ public class CircleLayer extends Layer { * * @return transition options for String */ + @NonNull public TransitionOptions getCircleColorTransition() { checkThread(); return nativeGetCircleColorTransition(); @@ -211,7 +220,7 @@ public class CircleLayer extends Layer { * * @param options transition options for String */ - public void setCircleColorTransition(TransitionOptions options) { + public void setCircleColorTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetCircleColorTransition(options.getDuration(), options.getDelay()); } @@ -221,6 +230,7 @@ public class CircleLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getCircleBlur() { checkThread(); @@ -232,6 +242,7 @@ public class CircleLayer extends Layer { * * @return transition options for Float */ + @NonNull public TransitionOptions getCircleBlurTransition() { checkThread(); return nativeGetCircleBlurTransition(); @@ -242,7 +253,7 @@ public class CircleLayer extends Layer { * * @param options transition options for Float */ - public void setCircleBlurTransition(TransitionOptions options) { + public void setCircleBlurTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetCircleBlurTransition(options.getDuration(), options.getDelay()); } @@ -252,6 +263,7 @@ public class CircleLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getCircleOpacity() { checkThread(); @@ -263,6 +275,7 @@ public class CircleLayer extends Layer { * * @return transition options for Float */ + @NonNull public TransitionOptions getCircleOpacityTransition() { checkThread(); return nativeGetCircleOpacityTransition(); @@ -273,7 +286,7 @@ public class CircleLayer extends Layer { * * @param options transition options for Float */ - public void setCircleOpacityTransition(TransitionOptions options) { + public void setCircleOpacityTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetCircleOpacityTransition(options.getDuration(), options.getDelay()); } @@ -283,6 +296,7 @@ public class CircleLayer extends Layer { * * @return property wrapper value around Float[] */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float[]> getCircleTranslate() { checkThread(); @@ -294,6 +308,7 @@ public class CircleLayer extends Layer { * * @return transition options for Float[] */ + @NonNull public TransitionOptions getCircleTranslateTransition() { checkThread(); return nativeGetCircleTranslateTransition(); @@ -304,7 +319,7 @@ public class CircleLayer extends Layer { * * @param options transition options for Float[] */ - public void setCircleTranslateTransition(TransitionOptions options) { + public void setCircleTranslateTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetCircleTranslateTransition(options.getDuration(), options.getDelay()); } @@ -314,6 +329,7 @@ public class CircleLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getCircleTranslateAnchor() { checkThread(); @@ -325,6 +341,7 @@ public class CircleLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getCirclePitchScale() { checkThread(); @@ -336,6 +353,7 @@ public class CircleLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getCirclePitchAlignment() { checkThread(); @@ -347,6 +365,7 @@ public class CircleLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getCircleStrokeWidth() { checkThread(); @@ -358,6 +377,7 @@ public class CircleLayer extends Layer { * * @return transition options for Float */ + @NonNull public TransitionOptions getCircleStrokeWidthTransition() { checkThread(); return nativeGetCircleStrokeWidthTransition(); @@ -368,7 +388,7 @@ public class CircleLayer extends Layer { * * @param options transition options for Float */ - public void setCircleStrokeWidthTransition(TransitionOptions options) { + public void setCircleStrokeWidthTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetCircleStrokeWidthTransition(options.getDuration(), options.getDelay()); } @@ -378,6 +398,7 @@ public class CircleLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getCircleStrokeColor() { checkThread(); @@ -406,6 +427,7 @@ public class CircleLayer extends Layer { * * @return transition options for String */ + @NonNull public TransitionOptions getCircleStrokeColorTransition() { checkThread(); return nativeGetCircleStrokeColorTransition(); @@ -416,7 +438,7 @@ public class CircleLayer extends Layer { * * @param options transition options for String */ - public void setCircleStrokeColorTransition(TransitionOptions options) { + public void setCircleStrokeColorTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetCircleStrokeColorTransition(options.getDuration(), options.getDelay()); } @@ -426,6 +448,7 @@ public class CircleLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getCircleStrokeOpacity() { checkThread(); @@ -437,6 +460,7 @@ public class CircleLayer extends Layer { * * @return transition options for Float */ + @NonNull public TransitionOptions getCircleStrokeOpacityTransition() { checkThread(); return nativeGetCircleStrokeOpacityTransition(); @@ -447,86 +471,105 @@ public class CircleLayer extends Layer { * * @param options transition options for Float */ - public void setCircleStrokeOpacityTransition(TransitionOptions options) { + public void setCircleStrokeOpacityTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetCircleStrokeOpacityTransition(options.getDuration(), options.getDelay()); } + @NonNull @Keep private native Object nativeGetCircleRadius(); + @NonNull @Keep private native TransitionOptions nativeGetCircleRadiusTransition(); @Keep private native void nativeSetCircleRadiusTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetCircleColor(); + @NonNull @Keep private native TransitionOptions nativeGetCircleColorTransition(); @Keep private native void nativeSetCircleColorTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetCircleBlur(); + @NonNull @Keep private native TransitionOptions nativeGetCircleBlurTransition(); @Keep private native void nativeSetCircleBlurTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetCircleOpacity(); + @NonNull @Keep private native TransitionOptions nativeGetCircleOpacityTransition(); @Keep private native void nativeSetCircleOpacityTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetCircleTranslate(); + @NonNull @Keep private native TransitionOptions nativeGetCircleTranslateTransition(); @Keep private native void nativeSetCircleTranslateTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetCircleTranslateAnchor(); + @NonNull @Keep private native Object nativeGetCirclePitchScale(); + @NonNull @Keep private native Object nativeGetCirclePitchAlignment(); + @NonNull @Keep private native Object nativeGetCircleStrokeWidth(); + @NonNull @Keep private native TransitionOptions nativeGetCircleStrokeWidthTransition(); @Keep private native void nativeSetCircleStrokeWidthTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetCircleStrokeColor(); + @NonNull @Keep private native TransitionOptions nativeGetCircleStrokeColorTransition(); @Keep private native void nativeSetCircleStrokeColorTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetCircleStrokeOpacity(); + @NonNull @Keep private native TransitionOptions nativeGetCircleStrokeOpacityTransition(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillExtrusionLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillExtrusionLayer.java index 339b25b3f7..864d1d5a20 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillExtrusionLayer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillExtrusionLayer.java @@ -62,6 +62,7 @@ public class FillExtrusionLayer extends Layer { * @param sourceLayer the source layer to set * @return This */ + @NonNull public FillExtrusionLayer withSourceLayer(String sourceLayer) { setSourceLayer(sourceLayer); return this; @@ -72,6 +73,7 @@ public class FillExtrusionLayer extends Layer { * * @return id of the source */ + @NonNull public String getSourceId() { checkThread(); return nativeGetSourceId(); @@ -82,6 +84,7 @@ public class FillExtrusionLayer extends Layer { * * @return sourceLayer the source layer to get */ + @NonNull public String getSourceLayer() { checkThread(); return nativeGetSourceLayer(); @@ -92,7 +95,7 @@ public class FillExtrusionLayer extends Layer { * * @param filter the expression filter to set */ - public void setFilter(Expression filter) { + public void setFilter(@NonNull Expression filter) { checkThread(); nativeSetFilter(filter.toArray()); } @@ -103,7 +106,8 @@ public class FillExtrusionLayer extends Layer { * @param filter the expression filter to set * @return This */ - public FillExtrusionLayer withFilter(Expression filter) { + @NonNull + public FillExtrusionLayer withFilter(@NonNull Expression filter) { setFilter(filter); return this; } @@ -130,6 +134,7 @@ public class FillExtrusionLayer extends Layer { * @param properties the var-args properties * @return This */ + @NonNull public FillExtrusionLayer withProperties(@NonNull PropertyValue<?>... properties) { setProperties(properties); return this; @@ -142,6 +147,7 @@ public class FillExtrusionLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getFillExtrusionOpacity() { checkThread(); @@ -153,6 +159,7 @@ public class FillExtrusionLayer extends Layer { * * @return transition options for Float */ + @NonNull public TransitionOptions getFillExtrusionOpacityTransition() { checkThread(); return nativeGetFillExtrusionOpacityTransition(); @@ -163,7 +170,7 @@ public class FillExtrusionLayer extends Layer { * * @param options transition options for Float */ - public void setFillExtrusionOpacityTransition(TransitionOptions options) { + public void setFillExtrusionOpacityTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetFillExtrusionOpacityTransition(options.getDuration(), options.getDelay()); } @@ -173,6 +180,7 @@ public class FillExtrusionLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getFillExtrusionColor() { checkThread(); @@ -201,6 +209,7 @@ public class FillExtrusionLayer extends Layer { * * @return transition options for String */ + @NonNull public TransitionOptions getFillExtrusionColorTransition() { checkThread(); return nativeGetFillExtrusionColorTransition(); @@ -211,7 +220,7 @@ public class FillExtrusionLayer extends Layer { * * @param options transition options for String */ - public void setFillExtrusionColorTransition(TransitionOptions options) { + public void setFillExtrusionColorTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetFillExtrusionColorTransition(options.getDuration(), options.getDelay()); } @@ -221,6 +230,7 @@ public class FillExtrusionLayer extends Layer { * * @return property wrapper value around Float[] */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float[]> getFillExtrusionTranslate() { checkThread(); @@ -232,6 +242,7 @@ public class FillExtrusionLayer extends Layer { * * @return transition options for Float[] */ + @NonNull public TransitionOptions getFillExtrusionTranslateTransition() { checkThread(); return nativeGetFillExtrusionTranslateTransition(); @@ -242,7 +253,7 @@ public class FillExtrusionLayer extends Layer { * * @param options transition options for Float[] */ - public void setFillExtrusionTranslateTransition(TransitionOptions options) { + public void setFillExtrusionTranslateTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetFillExtrusionTranslateTransition(options.getDuration(), options.getDelay()); } @@ -252,6 +263,7 @@ public class FillExtrusionLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getFillExtrusionTranslateAnchor() { checkThread(); @@ -263,6 +275,7 @@ public class FillExtrusionLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getFillExtrusionPattern() { checkThread(); @@ -274,6 +287,7 @@ public class FillExtrusionLayer extends Layer { * * @return transition options for String */ + @NonNull public TransitionOptions getFillExtrusionPatternTransition() { checkThread(); return nativeGetFillExtrusionPatternTransition(); @@ -284,7 +298,7 @@ public class FillExtrusionLayer extends Layer { * * @param options transition options for String */ - public void setFillExtrusionPatternTransition(TransitionOptions options) { + public void setFillExtrusionPatternTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetFillExtrusionPatternTransition(options.getDuration(), options.getDelay()); } @@ -294,6 +308,7 @@ public class FillExtrusionLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getFillExtrusionHeight() { checkThread(); @@ -305,6 +320,7 @@ public class FillExtrusionLayer extends Layer { * * @return transition options for Float */ + @NonNull public TransitionOptions getFillExtrusionHeightTransition() { checkThread(); return nativeGetFillExtrusionHeightTransition(); @@ -315,7 +331,7 @@ public class FillExtrusionLayer extends Layer { * * @param options transition options for Float */ - public void setFillExtrusionHeightTransition(TransitionOptions options) { + public void setFillExtrusionHeightTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetFillExtrusionHeightTransition(options.getDuration(), options.getDelay()); } @@ -325,6 +341,7 @@ public class FillExtrusionLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getFillExtrusionBase() { checkThread(); @@ -336,6 +353,7 @@ public class FillExtrusionLayer extends Layer { * * @return transition options for Float */ + @NonNull public TransitionOptions getFillExtrusionBaseTransition() { checkThread(); return nativeGetFillExtrusionBaseTransition(); @@ -346,62 +364,75 @@ public class FillExtrusionLayer extends Layer { * * @param options transition options for Float */ - public void setFillExtrusionBaseTransition(TransitionOptions options) { + public void setFillExtrusionBaseTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetFillExtrusionBaseTransition(options.getDuration(), options.getDelay()); } + @NonNull @Keep private native Object nativeGetFillExtrusionOpacity(); + @NonNull @Keep private native TransitionOptions nativeGetFillExtrusionOpacityTransition(); @Keep private native void nativeSetFillExtrusionOpacityTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetFillExtrusionColor(); + @NonNull @Keep private native TransitionOptions nativeGetFillExtrusionColorTransition(); @Keep private native void nativeSetFillExtrusionColorTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetFillExtrusionTranslate(); + @NonNull @Keep private native TransitionOptions nativeGetFillExtrusionTranslateTransition(); @Keep private native void nativeSetFillExtrusionTranslateTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetFillExtrusionTranslateAnchor(); + @NonNull @Keep private native Object nativeGetFillExtrusionPattern(); + @NonNull @Keep private native TransitionOptions nativeGetFillExtrusionPatternTransition(); @Keep private native void nativeSetFillExtrusionPatternTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetFillExtrusionHeight(); + @NonNull @Keep private native TransitionOptions nativeGetFillExtrusionHeightTransition(); @Keep private native void nativeSetFillExtrusionHeightTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetFillExtrusionBase(); + @NonNull @Keep private native TransitionOptions nativeGetFillExtrusionBaseTransition(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillLayer.java index 295ffd3963..14c80c044c 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillLayer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillLayer.java @@ -62,6 +62,7 @@ public class FillLayer extends Layer { * @param sourceLayer the source layer to set * @return This */ + @NonNull public FillLayer withSourceLayer(String sourceLayer) { setSourceLayer(sourceLayer); return this; @@ -72,6 +73,7 @@ public class FillLayer extends Layer { * * @return id of the source */ + @NonNull public String getSourceId() { checkThread(); return nativeGetSourceId(); @@ -82,6 +84,7 @@ public class FillLayer extends Layer { * * @return sourceLayer the source layer to get */ + @NonNull public String getSourceLayer() { checkThread(); return nativeGetSourceLayer(); @@ -92,7 +95,7 @@ public class FillLayer extends Layer { * * @param filter the expression filter to set */ - public void setFilter(Expression filter) { + public void setFilter(@NonNull Expression filter) { checkThread(); nativeSetFilter(filter.toArray()); } @@ -103,7 +106,8 @@ public class FillLayer extends Layer { * @param filter the expression filter to set * @return This */ - public FillLayer withFilter(Expression filter) { + @NonNull + public FillLayer withFilter(@NonNull Expression filter) { setFilter(filter); return this; } @@ -130,6 +134,7 @@ public class FillLayer extends Layer { * @param properties the var-args properties * @return This */ + @NonNull public FillLayer withProperties(@NonNull PropertyValue<?>... properties) { setProperties(properties); return this; @@ -142,6 +147,7 @@ public class FillLayer extends Layer { * * @return property wrapper value around Boolean */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Boolean> getFillAntialias() { checkThread(); @@ -153,6 +159,7 @@ public class FillLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getFillOpacity() { checkThread(); @@ -164,6 +171,7 @@ public class FillLayer extends Layer { * * @return transition options for Float */ + @NonNull public TransitionOptions getFillOpacityTransition() { checkThread(); return nativeGetFillOpacityTransition(); @@ -174,7 +182,7 @@ public class FillLayer extends Layer { * * @param options transition options for Float */ - public void setFillOpacityTransition(TransitionOptions options) { + public void setFillOpacityTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetFillOpacityTransition(options.getDuration(), options.getDelay()); } @@ -184,6 +192,7 @@ public class FillLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getFillColor() { checkThread(); @@ -212,6 +221,7 @@ public class FillLayer extends Layer { * * @return transition options for String */ + @NonNull public TransitionOptions getFillColorTransition() { checkThread(); return nativeGetFillColorTransition(); @@ -222,7 +232,7 @@ public class FillLayer extends Layer { * * @param options transition options for String */ - public void setFillColorTransition(TransitionOptions options) { + public void setFillColorTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetFillColorTransition(options.getDuration(), options.getDelay()); } @@ -232,6 +242,7 @@ public class FillLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getFillOutlineColor() { checkThread(); @@ -260,6 +271,7 @@ public class FillLayer extends Layer { * * @return transition options for String */ + @NonNull public TransitionOptions getFillOutlineColorTransition() { checkThread(); return nativeGetFillOutlineColorTransition(); @@ -270,7 +282,7 @@ public class FillLayer extends Layer { * * @param options transition options for String */ - public void setFillOutlineColorTransition(TransitionOptions options) { + public void setFillOutlineColorTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetFillOutlineColorTransition(options.getDuration(), options.getDelay()); } @@ -280,6 +292,7 @@ public class FillLayer extends Layer { * * @return property wrapper value around Float[] */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float[]> getFillTranslate() { checkThread(); @@ -291,6 +304,7 @@ public class FillLayer extends Layer { * * @return transition options for Float[] */ + @NonNull public TransitionOptions getFillTranslateTransition() { checkThread(); return nativeGetFillTranslateTransition(); @@ -301,7 +315,7 @@ public class FillLayer extends Layer { * * @param options transition options for Float[] */ - public void setFillTranslateTransition(TransitionOptions options) { + public void setFillTranslateTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetFillTranslateTransition(options.getDuration(), options.getDelay()); } @@ -311,6 +325,7 @@ public class FillLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getFillTranslateAnchor() { checkThread(); @@ -322,6 +337,7 @@ public class FillLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getFillPattern() { checkThread(); @@ -333,6 +349,7 @@ public class FillLayer extends Layer { * * @return transition options for String */ + @NonNull public TransitionOptions getFillPatternTransition() { checkThread(); return nativeGetFillPatternTransition(); @@ -343,56 +360,68 @@ public class FillLayer extends Layer { * * @param options transition options for String */ - public void setFillPatternTransition(TransitionOptions options) { + public void setFillPatternTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetFillPatternTransition(options.getDuration(), options.getDelay()); } + @NonNull @Keep private native Object nativeGetFillAntialias(); + @NonNull @Keep private native Object nativeGetFillOpacity(); + @NonNull @Keep private native TransitionOptions nativeGetFillOpacityTransition(); @Keep private native void nativeSetFillOpacityTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetFillColor(); + @NonNull @Keep private native TransitionOptions nativeGetFillColorTransition(); @Keep private native void nativeSetFillColorTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetFillOutlineColor(); + @NonNull @Keep private native TransitionOptions nativeGetFillOutlineColorTransition(); @Keep private native void nativeSetFillOutlineColorTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetFillTranslate(); + @NonNull @Keep private native TransitionOptions nativeGetFillTranslateTransition(); @Keep private native void nativeSetFillTranslateTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetFillTranslateAnchor(); + @NonNull @Keep private native Object nativeGetFillPattern(); + @NonNull @Keep private native TransitionOptions nativeGetFillPatternTransition(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/HeatmapLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/HeatmapLayer.java index 796f6a28bb..730471190c 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/HeatmapLayer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/HeatmapLayer.java @@ -62,6 +62,7 @@ public class HeatmapLayer extends Layer { * @param sourceLayer the source layer to set * @return This */ + @NonNull public HeatmapLayer withSourceLayer(String sourceLayer) { setSourceLayer(sourceLayer); return this; @@ -72,6 +73,7 @@ public class HeatmapLayer extends Layer { * * @return id of the source */ + @NonNull public String getSourceId() { checkThread(); return nativeGetSourceId(); @@ -82,6 +84,7 @@ public class HeatmapLayer extends Layer { * * @return sourceLayer the source layer to get */ + @NonNull public String getSourceLayer() { checkThread(); return nativeGetSourceLayer(); @@ -92,7 +95,7 @@ public class HeatmapLayer extends Layer { * * @param filter the expression filter to set */ - public void setFilter(Expression filter) { + public void setFilter(@NonNull Expression filter) { checkThread(); nativeSetFilter(filter.toArray()); } @@ -103,7 +106,8 @@ public class HeatmapLayer extends Layer { * @param filter the expression filter to set * @return This */ - public HeatmapLayer withFilter(Expression filter) { + @NonNull + public HeatmapLayer withFilter(@NonNull Expression filter) { setFilter(filter); return this; } @@ -130,6 +134,7 @@ public class HeatmapLayer extends Layer { * @param properties the var-args properties * @return This */ + @NonNull public HeatmapLayer withProperties(@NonNull PropertyValue<?>... properties) { setProperties(properties); return this; @@ -142,6 +147,7 @@ public class HeatmapLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getHeatmapRadius() { checkThread(); @@ -153,6 +159,7 @@ public class HeatmapLayer extends Layer { * * @return transition options for Float */ + @NonNull public TransitionOptions getHeatmapRadiusTransition() { checkThread(); return nativeGetHeatmapRadiusTransition(); @@ -163,7 +170,7 @@ public class HeatmapLayer extends Layer { * * @param options transition options for Float */ - public void setHeatmapRadiusTransition(TransitionOptions options) { + public void setHeatmapRadiusTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetHeatmapRadiusTransition(options.getDuration(), options.getDelay()); } @@ -173,6 +180,7 @@ public class HeatmapLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getHeatmapWeight() { checkThread(); @@ -184,6 +192,7 @@ public class HeatmapLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getHeatmapIntensity() { checkThread(); @@ -195,6 +204,7 @@ public class HeatmapLayer extends Layer { * * @return transition options for Float */ + @NonNull public TransitionOptions getHeatmapIntensityTransition() { checkThread(); return nativeGetHeatmapIntensityTransition(); @@ -205,7 +215,7 @@ public class HeatmapLayer extends Layer { * * @param options transition options for Float */ - public void setHeatmapIntensityTransition(TransitionOptions options) { + public void setHeatmapIntensityTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetHeatmapIntensityTransition(options.getDuration(), options.getDelay()); } @@ -215,6 +225,7 @@ public class HeatmapLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getHeatmapColor() { checkThread(); @@ -243,6 +254,7 @@ public class HeatmapLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getHeatmapOpacity() { checkThread(); @@ -254,6 +266,7 @@ public class HeatmapLayer extends Layer { * * @return transition options for Float */ + @NonNull public TransitionOptions getHeatmapOpacityTransition() { checkThread(); return nativeGetHeatmapOpacityTransition(); @@ -264,38 +277,46 @@ public class HeatmapLayer extends Layer { * * @param options transition options for Float */ - public void setHeatmapOpacityTransition(TransitionOptions options) { + public void setHeatmapOpacityTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetHeatmapOpacityTransition(options.getDuration(), options.getDelay()); } + @NonNull @Keep private native Object nativeGetHeatmapRadius(); + @NonNull @Keep private native TransitionOptions nativeGetHeatmapRadiusTransition(); @Keep private native void nativeSetHeatmapRadiusTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetHeatmapWeight(); + @NonNull @Keep private native Object nativeGetHeatmapIntensity(); + @NonNull @Keep private native TransitionOptions nativeGetHeatmapIntensityTransition(); @Keep private native void nativeSetHeatmapIntensityTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetHeatmapColor(); + @NonNull @Keep private native Object nativeGetHeatmapOpacity(); + @NonNull @Keep private native TransitionOptions nativeGetHeatmapOpacityTransition(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/HillshadeLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/HillshadeLayer.java index d548d2c9f6..22df96f2c6 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/HillshadeLayer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/HillshadeLayer.java @@ -62,6 +62,7 @@ public class HillshadeLayer extends Layer { * @param sourceLayer the source layer to set * @return This */ + @NonNull public HillshadeLayer withSourceLayer(String sourceLayer) { setSourceLayer(sourceLayer); return this; @@ -72,6 +73,7 @@ public class HillshadeLayer extends Layer { * * @return id of the source */ + @NonNull public String getSourceId() { checkThread(); return nativeGetSourceId(); @@ -83,6 +85,7 @@ public class HillshadeLayer extends Layer { * @param properties the var-args properties * @return This */ + @NonNull public HillshadeLayer withProperties(@NonNull PropertyValue<?>... properties) { setProperties(properties); return this; @@ -95,6 +98,7 @@ public class HillshadeLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getHillshadeIlluminationDirection() { checkThread(); @@ -106,6 +110,7 @@ public class HillshadeLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getHillshadeIlluminationAnchor() { checkThread(); @@ -117,6 +122,7 @@ public class HillshadeLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getHillshadeExaggeration() { checkThread(); @@ -128,6 +134,7 @@ public class HillshadeLayer extends Layer { * * @return transition options for Float */ + @NonNull public TransitionOptions getHillshadeExaggerationTransition() { checkThread(); return nativeGetHillshadeExaggerationTransition(); @@ -138,7 +145,7 @@ public class HillshadeLayer extends Layer { * * @param options transition options for Float */ - public void setHillshadeExaggerationTransition(TransitionOptions options) { + public void setHillshadeExaggerationTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetHillshadeExaggerationTransition(options.getDuration(), options.getDelay()); } @@ -148,6 +155,7 @@ public class HillshadeLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getHillshadeShadowColor() { checkThread(); @@ -176,6 +184,7 @@ public class HillshadeLayer extends Layer { * * @return transition options for String */ + @NonNull public TransitionOptions getHillshadeShadowColorTransition() { checkThread(); return nativeGetHillshadeShadowColorTransition(); @@ -186,7 +195,7 @@ public class HillshadeLayer extends Layer { * * @param options transition options for String */ - public void setHillshadeShadowColorTransition(TransitionOptions options) { + public void setHillshadeShadowColorTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetHillshadeShadowColorTransition(options.getDuration(), options.getDelay()); } @@ -196,6 +205,7 @@ public class HillshadeLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getHillshadeHighlightColor() { checkThread(); @@ -224,6 +234,7 @@ public class HillshadeLayer extends Layer { * * @return transition options for String */ + @NonNull public TransitionOptions getHillshadeHighlightColorTransition() { checkThread(); return nativeGetHillshadeHighlightColorTransition(); @@ -234,7 +245,7 @@ public class HillshadeLayer extends Layer { * * @param options transition options for String */ - public void setHillshadeHighlightColorTransition(TransitionOptions options) { + public void setHillshadeHighlightColorTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetHillshadeHighlightColorTransition(options.getDuration(), options.getDelay()); } @@ -244,6 +255,7 @@ public class HillshadeLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getHillshadeAccentColor() { checkThread(); @@ -272,6 +284,7 @@ public class HillshadeLayer extends Layer { * * @return transition options for String */ + @NonNull public TransitionOptions getHillshadeAccentColorTransition() { checkThread(); return nativeGetHillshadeAccentColorTransition(); @@ -282,47 +295,57 @@ public class HillshadeLayer extends Layer { * * @param options transition options for String */ - public void setHillshadeAccentColorTransition(TransitionOptions options) { + public void setHillshadeAccentColorTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetHillshadeAccentColorTransition(options.getDuration(), options.getDelay()); } + @NonNull @Keep private native Object nativeGetHillshadeIlluminationDirection(); + @NonNull @Keep private native Object nativeGetHillshadeIlluminationAnchor(); + @NonNull @Keep private native Object nativeGetHillshadeExaggeration(); + @NonNull @Keep private native TransitionOptions nativeGetHillshadeExaggerationTransition(); @Keep private native void nativeSetHillshadeExaggerationTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetHillshadeShadowColor(); + @NonNull @Keep private native TransitionOptions nativeGetHillshadeShadowColorTransition(); @Keep private native void nativeSetHillshadeShadowColorTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetHillshadeHighlightColor(); + @NonNull @Keep private native TransitionOptions nativeGetHillshadeHighlightColorTransition(); @Keep private native void nativeSetHillshadeHighlightColorTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetHillshadeAccentColor(); + @NonNull @Keep private native TransitionOptions nativeGetHillshadeAccentColorTransition(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Layer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Layer.java index b17c4a661a..ea89330c95 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Layer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Layer.java @@ -3,6 +3,7 @@ package com.mapbox.mapboxsdk.style.layers; import android.support.annotation.Keep; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import com.google.gson.JsonElement; import com.mapbox.mapboxsdk.style.expressions.Expression; import com.mapbox.mapboxsdk.utils.ThreadUtils; @@ -50,11 +51,13 @@ public abstract class Layer { } } + @NonNull public String getId() { checkThread(); return nativeGetId(); } + @NonNull public PropertyValue<String> getVisibility() { checkThread(); return new PaintPropertyValue<>("visibility", (String) nativeGetVisibility()); @@ -84,9 +87,11 @@ public abstract class Layer { @Keep protected native void finalize() throws Throwable; + @NonNull @Keep protected native String nativeGetId(); + @NonNull @Keep protected native Object nativeGetVisibility(); @@ -99,15 +104,18 @@ public abstract class Layer { @Keep protected native void nativeSetFilter(Object[] filter); + @NonNull @Keep protected native JsonElement nativeGetFilter(); @Keep protected native void nativeSetSourceLayer(String sourceLayer); + @NonNull @Keep protected native String nativeGetSourceLayer(); + @NonNull @Keep protected native String nativeGetSourceId(); @@ -127,7 +135,8 @@ public abstract class Layer { return nativePtr; } - private Object convertValue(Object value) { + @Nullable + private Object convertValue(@Nullable Object value) { if (value != null && value instanceof Expression) { return ((Expression) value).toArray(); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/LineLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/LineLayer.java index f6022f836a..662d7c7ea7 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/LineLayer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/LineLayer.java @@ -62,6 +62,7 @@ public class LineLayer extends Layer { * @param sourceLayer the source layer to set * @return This */ + @NonNull public LineLayer withSourceLayer(String sourceLayer) { setSourceLayer(sourceLayer); return this; @@ -72,6 +73,7 @@ public class LineLayer extends Layer { * * @return id of the source */ + @NonNull public String getSourceId() { checkThread(); return nativeGetSourceId(); @@ -82,6 +84,7 @@ public class LineLayer extends Layer { * * @return sourceLayer the source layer to get */ + @NonNull public String getSourceLayer() { checkThread(); return nativeGetSourceLayer(); @@ -92,7 +95,7 @@ public class LineLayer extends Layer { * * @param filter the expression filter to set */ - public void setFilter(Expression filter) { + public void setFilter(@NonNull Expression filter) { checkThread(); nativeSetFilter(filter.toArray()); } @@ -103,7 +106,8 @@ public class LineLayer extends Layer { * @param filter the expression filter to set * @return This */ - public LineLayer withFilter(Expression filter) { + @NonNull + public LineLayer withFilter(@NonNull Expression filter) { setFilter(filter); return this; } @@ -130,6 +134,7 @@ public class LineLayer extends Layer { * @param properties the var-args properties * @return This */ + @NonNull public LineLayer withProperties(@NonNull PropertyValue<?>... properties) { setProperties(properties); return this; @@ -142,6 +147,7 @@ public class LineLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getLineCap() { checkThread(); @@ -153,6 +159,7 @@ public class LineLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getLineJoin() { checkThread(); @@ -164,6 +171,7 @@ public class LineLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getLineMiterLimit() { checkThread(); @@ -175,6 +183,7 @@ public class LineLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getLineRoundLimit() { checkThread(); @@ -186,6 +195,7 @@ public class LineLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getLineOpacity() { checkThread(); @@ -197,6 +207,7 @@ public class LineLayer extends Layer { * * @return transition options for Float */ + @NonNull public TransitionOptions getLineOpacityTransition() { checkThread(); return nativeGetLineOpacityTransition(); @@ -207,7 +218,7 @@ public class LineLayer extends Layer { * * @param options transition options for Float */ - public void setLineOpacityTransition(TransitionOptions options) { + public void setLineOpacityTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetLineOpacityTransition(options.getDuration(), options.getDelay()); } @@ -217,6 +228,7 @@ public class LineLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getLineColor() { checkThread(); @@ -245,6 +257,7 @@ public class LineLayer extends Layer { * * @return transition options for String */ + @NonNull public TransitionOptions getLineColorTransition() { checkThread(); return nativeGetLineColorTransition(); @@ -255,7 +268,7 @@ public class LineLayer extends Layer { * * @param options transition options for String */ - public void setLineColorTransition(TransitionOptions options) { + public void setLineColorTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetLineColorTransition(options.getDuration(), options.getDelay()); } @@ -265,6 +278,7 @@ public class LineLayer extends Layer { * * @return property wrapper value around Float[] */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float[]> getLineTranslate() { checkThread(); @@ -276,6 +290,7 @@ public class LineLayer extends Layer { * * @return transition options for Float[] */ + @NonNull public TransitionOptions getLineTranslateTransition() { checkThread(); return nativeGetLineTranslateTransition(); @@ -286,7 +301,7 @@ public class LineLayer extends Layer { * * @param options transition options for Float[] */ - public void setLineTranslateTransition(TransitionOptions options) { + public void setLineTranslateTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetLineTranslateTransition(options.getDuration(), options.getDelay()); } @@ -296,6 +311,7 @@ public class LineLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getLineTranslateAnchor() { checkThread(); @@ -307,6 +323,7 @@ public class LineLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getLineWidth() { checkThread(); @@ -318,6 +335,7 @@ public class LineLayer extends Layer { * * @return transition options for Float */ + @NonNull public TransitionOptions getLineWidthTransition() { checkThread(); return nativeGetLineWidthTransition(); @@ -328,7 +346,7 @@ public class LineLayer extends Layer { * * @param options transition options for Float */ - public void setLineWidthTransition(TransitionOptions options) { + public void setLineWidthTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetLineWidthTransition(options.getDuration(), options.getDelay()); } @@ -338,6 +356,7 @@ public class LineLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getLineGapWidth() { checkThread(); @@ -349,6 +368,7 @@ public class LineLayer extends Layer { * * @return transition options for Float */ + @NonNull public TransitionOptions getLineGapWidthTransition() { checkThread(); return nativeGetLineGapWidthTransition(); @@ -359,7 +379,7 @@ public class LineLayer extends Layer { * * @param options transition options for Float */ - public void setLineGapWidthTransition(TransitionOptions options) { + public void setLineGapWidthTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetLineGapWidthTransition(options.getDuration(), options.getDelay()); } @@ -369,6 +389,7 @@ public class LineLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getLineOffset() { checkThread(); @@ -380,6 +401,7 @@ public class LineLayer extends Layer { * * @return transition options for Float */ + @NonNull public TransitionOptions getLineOffsetTransition() { checkThread(); return nativeGetLineOffsetTransition(); @@ -390,7 +412,7 @@ public class LineLayer extends Layer { * * @param options transition options for Float */ - public void setLineOffsetTransition(TransitionOptions options) { + public void setLineOffsetTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetLineOffsetTransition(options.getDuration(), options.getDelay()); } @@ -400,6 +422,7 @@ public class LineLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getLineBlur() { checkThread(); @@ -411,6 +434,7 @@ public class LineLayer extends Layer { * * @return transition options for Float */ + @NonNull public TransitionOptions getLineBlurTransition() { checkThread(); return nativeGetLineBlurTransition(); @@ -421,7 +445,7 @@ public class LineLayer extends Layer { * * @param options transition options for Float */ - public void setLineBlurTransition(TransitionOptions options) { + public void setLineBlurTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetLineBlurTransition(options.getDuration(), options.getDelay()); } @@ -431,6 +455,7 @@ public class LineLayer extends Layer { * * @return property wrapper value around Float[] */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float[]> getLineDasharray() { checkThread(); @@ -442,6 +467,7 @@ public class LineLayer extends Layer { * * @return transition options for Float[] */ + @NonNull public TransitionOptions getLineDasharrayTransition() { checkThread(); return nativeGetLineDasharrayTransition(); @@ -452,7 +478,7 @@ public class LineLayer extends Layer { * * @param options transition options for Float[] */ - public void setLineDasharrayTransition(TransitionOptions options) { + public void setLineDasharrayTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetLineDasharrayTransition(options.getDuration(), options.getDelay()); } @@ -462,6 +488,7 @@ public class LineLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getLinePattern() { checkThread(); @@ -473,6 +500,7 @@ public class LineLayer extends Layer { * * @return transition options for String */ + @NonNull public TransitionOptions getLinePatternTransition() { checkThread(); return nativeGetLinePatternTransition(); @@ -483,7 +511,7 @@ public class LineLayer extends Layer { * * @param options transition options for String */ - public void setLinePatternTransition(TransitionOptions options) { + public void setLinePatternTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetLinePatternTransition(options.getDuration(), options.getDelay()); } @@ -493,6 +521,7 @@ public class LineLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getLineGradient() { checkThread(); @@ -516,102 +545,126 @@ public class LineLayer extends Layer { } } + @NonNull @Keep private native Object nativeGetLineCap(); + @NonNull @Keep private native Object nativeGetLineJoin(); + @NonNull @Keep private native Object nativeGetLineMiterLimit(); + @NonNull @Keep private native Object nativeGetLineRoundLimit(); + @NonNull @Keep private native Object nativeGetLineOpacity(); + @NonNull @Keep private native TransitionOptions nativeGetLineOpacityTransition(); @Keep private native void nativeSetLineOpacityTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetLineColor(); + @NonNull @Keep private native TransitionOptions nativeGetLineColorTransition(); @Keep private native void nativeSetLineColorTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetLineTranslate(); + @NonNull @Keep private native TransitionOptions nativeGetLineTranslateTransition(); @Keep private native void nativeSetLineTranslateTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetLineTranslateAnchor(); + @NonNull @Keep private native Object nativeGetLineWidth(); + @NonNull @Keep private native TransitionOptions nativeGetLineWidthTransition(); @Keep private native void nativeSetLineWidthTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetLineGapWidth(); + @NonNull @Keep private native TransitionOptions nativeGetLineGapWidthTransition(); @Keep private native void nativeSetLineGapWidthTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetLineOffset(); + @NonNull @Keep private native TransitionOptions nativeGetLineOffsetTransition(); @Keep private native void nativeSetLineOffsetTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetLineBlur(); + @NonNull @Keep private native TransitionOptions nativeGetLineBlurTransition(); @Keep private native void nativeSetLineBlurTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetLineDasharray(); + @NonNull @Keep private native TransitionOptions nativeGetLineDasharrayTransition(); @Keep private native void nativeSetLineDasharrayTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetLinePattern(); + @NonNull @Keep private native TransitionOptions nativeGetLinePatternTransition(); @Keep private native void nativeSetLinePatternTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetLineGradient(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyValue.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyValue.java index 848165f00f..e21833ed7d 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyValue.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyValue.java @@ -17,6 +17,7 @@ public class PropertyValue<T> { private static final String TAG = "Mbgl-PropertyValue"; + @NonNull public final String name; public final T value; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/RasterLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/RasterLayer.java index 792ea1193c..f2c5b03a27 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/RasterLayer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/RasterLayer.java @@ -62,6 +62,7 @@ public class RasterLayer extends Layer { * @param sourceLayer the source layer to set * @return This */ + @NonNull public RasterLayer withSourceLayer(String sourceLayer) { setSourceLayer(sourceLayer); return this; @@ -72,6 +73,7 @@ public class RasterLayer extends Layer { * * @return id of the source */ + @NonNull public String getSourceId() { checkThread(); return nativeGetSourceId(); @@ -83,6 +85,7 @@ public class RasterLayer extends Layer { * @param properties the var-args properties * @return This */ + @NonNull public RasterLayer withProperties(@NonNull PropertyValue<?>... properties) { setProperties(properties); return this; @@ -95,6 +98,7 @@ public class RasterLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getRasterOpacity() { checkThread(); @@ -106,6 +110,7 @@ public class RasterLayer extends Layer { * * @return transition options for Float */ + @NonNull public TransitionOptions getRasterOpacityTransition() { checkThread(); return nativeGetRasterOpacityTransition(); @@ -116,7 +121,7 @@ public class RasterLayer extends Layer { * * @param options transition options for Float */ - public void setRasterOpacityTransition(TransitionOptions options) { + public void setRasterOpacityTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetRasterOpacityTransition(options.getDuration(), options.getDelay()); } @@ -126,6 +131,7 @@ public class RasterLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getRasterHueRotate() { checkThread(); @@ -137,6 +143,7 @@ public class RasterLayer extends Layer { * * @return transition options for Float */ + @NonNull public TransitionOptions getRasterHueRotateTransition() { checkThread(); return nativeGetRasterHueRotateTransition(); @@ -147,7 +154,7 @@ public class RasterLayer extends Layer { * * @param options transition options for Float */ - public void setRasterHueRotateTransition(TransitionOptions options) { + public void setRasterHueRotateTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetRasterHueRotateTransition(options.getDuration(), options.getDelay()); } @@ -157,6 +164,7 @@ public class RasterLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getRasterBrightnessMin() { checkThread(); @@ -168,6 +176,7 @@ public class RasterLayer extends Layer { * * @return transition options for Float */ + @NonNull public TransitionOptions getRasterBrightnessMinTransition() { checkThread(); return nativeGetRasterBrightnessMinTransition(); @@ -178,7 +187,7 @@ public class RasterLayer extends Layer { * * @param options transition options for Float */ - public void setRasterBrightnessMinTransition(TransitionOptions options) { + public void setRasterBrightnessMinTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetRasterBrightnessMinTransition(options.getDuration(), options.getDelay()); } @@ -188,6 +197,7 @@ public class RasterLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getRasterBrightnessMax() { checkThread(); @@ -199,6 +209,7 @@ public class RasterLayer extends Layer { * * @return transition options for Float */ + @NonNull public TransitionOptions getRasterBrightnessMaxTransition() { checkThread(); return nativeGetRasterBrightnessMaxTransition(); @@ -209,7 +220,7 @@ public class RasterLayer extends Layer { * * @param options transition options for Float */ - public void setRasterBrightnessMaxTransition(TransitionOptions options) { + public void setRasterBrightnessMaxTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetRasterBrightnessMaxTransition(options.getDuration(), options.getDelay()); } @@ -219,6 +230,7 @@ public class RasterLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getRasterSaturation() { checkThread(); @@ -230,6 +242,7 @@ public class RasterLayer extends Layer { * * @return transition options for Float */ + @NonNull public TransitionOptions getRasterSaturationTransition() { checkThread(); return nativeGetRasterSaturationTransition(); @@ -240,7 +253,7 @@ public class RasterLayer extends Layer { * * @param options transition options for Float */ - public void setRasterSaturationTransition(TransitionOptions options) { + public void setRasterSaturationTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetRasterSaturationTransition(options.getDuration(), options.getDelay()); } @@ -250,6 +263,7 @@ public class RasterLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getRasterContrast() { checkThread(); @@ -261,6 +275,7 @@ public class RasterLayer extends Layer { * * @return transition options for Float */ + @NonNull public TransitionOptions getRasterContrastTransition() { checkThread(); return nativeGetRasterContrastTransition(); @@ -271,7 +286,7 @@ public class RasterLayer extends Layer { * * @param options transition options for Float */ - public void setRasterContrastTransition(TransitionOptions options) { + public void setRasterContrastTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetRasterContrastTransition(options.getDuration(), options.getDelay()); } @@ -281,6 +296,7 @@ public class RasterLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getRasterResampling() { checkThread(); @@ -292,69 +308,84 @@ public class RasterLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getRasterFadeDuration() { checkThread(); return (PropertyValue<Float>) new PropertyValue("raster-fade-duration", nativeGetRasterFadeDuration()); } + @NonNull @Keep private native Object nativeGetRasterOpacity(); + @NonNull @Keep private native TransitionOptions nativeGetRasterOpacityTransition(); @Keep private native void nativeSetRasterOpacityTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetRasterHueRotate(); + @NonNull @Keep private native TransitionOptions nativeGetRasterHueRotateTransition(); @Keep private native void nativeSetRasterHueRotateTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetRasterBrightnessMin(); + @NonNull @Keep private native TransitionOptions nativeGetRasterBrightnessMinTransition(); @Keep private native void nativeSetRasterBrightnessMinTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetRasterBrightnessMax(); + @NonNull @Keep private native TransitionOptions nativeGetRasterBrightnessMaxTransition(); @Keep private native void nativeSetRasterBrightnessMaxTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetRasterSaturation(); + @NonNull @Keep private native TransitionOptions nativeGetRasterSaturationTransition(); @Keep private native void nativeSetRasterSaturationTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetRasterContrast(); + @NonNull @Keep private native TransitionOptions nativeGetRasterContrastTransition(); @Keep private native void nativeSetRasterContrastTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetRasterResampling(); + @NonNull @Keep private native Object nativeGetRasterFadeDuration(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java index 1d45f34bd3..ba5bff178c 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java @@ -62,6 +62,7 @@ public class SymbolLayer extends Layer { * @param sourceLayer the source layer to set * @return This */ + @NonNull public SymbolLayer withSourceLayer(String sourceLayer) { setSourceLayer(sourceLayer); return this; @@ -72,6 +73,7 @@ public class SymbolLayer extends Layer { * * @return id of the source */ + @NonNull public String getSourceId() { checkThread(); return nativeGetSourceId(); @@ -82,6 +84,7 @@ public class SymbolLayer extends Layer { * * @return sourceLayer the source layer to get */ + @NonNull public String getSourceLayer() { checkThread(); return nativeGetSourceLayer(); @@ -92,7 +95,7 @@ public class SymbolLayer extends Layer { * * @param filter the expression filter to set */ - public void setFilter(Expression filter) { + public void setFilter(@NonNull Expression filter) { checkThread(); nativeSetFilter(filter.toArray()); } @@ -103,7 +106,8 @@ public class SymbolLayer extends Layer { * @param filter the expression filter to set * @return This */ - public SymbolLayer withFilter(Expression filter) { + @NonNull + public SymbolLayer withFilter(@NonNull Expression filter) { setFilter(filter); return this; } @@ -130,6 +134,7 @@ public class SymbolLayer extends Layer { * @param properties the var-args properties * @return This */ + @NonNull public SymbolLayer withProperties(@NonNull PropertyValue<?>... properties) { setProperties(properties); return this; @@ -142,6 +147,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getSymbolPlacement() { checkThread(); @@ -153,6 +159,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getSymbolSpacing() { checkThread(); @@ -164,6 +171,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around Boolean */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Boolean> getSymbolAvoidEdges() { checkThread(); @@ -175,6 +183,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getSymbolZOrder() { checkThread(); @@ -186,6 +195,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around Boolean */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Boolean> getIconAllowOverlap() { checkThread(); @@ -197,6 +207,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around Boolean */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Boolean> getIconIgnorePlacement() { checkThread(); @@ -208,6 +219,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around Boolean */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Boolean> getIconOptional() { checkThread(); @@ -219,6 +231,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getIconRotationAlignment() { checkThread(); @@ -230,6 +243,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getIconSize() { checkThread(); @@ -241,6 +255,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getIconTextFit() { checkThread(); @@ -252,6 +267,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around Float[] */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float[]> getIconTextFitPadding() { checkThread(); @@ -263,6 +279,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getIconImage() { checkThread(); @@ -274,6 +291,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getIconRotate() { checkThread(); @@ -285,6 +303,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getIconPadding() { checkThread(); @@ -296,6 +315,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around Boolean */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Boolean> getIconKeepUpright() { checkThread(); @@ -307,6 +327,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around Float[] */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float[]> getIconOffset() { checkThread(); @@ -318,6 +339,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getIconAnchor() { checkThread(); @@ -329,6 +351,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getIconPitchAlignment() { checkThread(); @@ -340,6 +363,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getTextPitchAlignment() { checkThread(); @@ -351,6 +375,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getTextRotationAlignment() { checkThread(); @@ -362,6 +387,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getTextField() { checkThread(); @@ -373,6 +399,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around String[] */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String[]> getTextFont() { checkThread(); @@ -384,6 +411,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getTextSize() { checkThread(); @@ -395,6 +423,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getTextMaxWidth() { checkThread(); @@ -406,6 +435,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getTextLineHeight() { checkThread(); @@ -417,6 +447,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getTextLetterSpacing() { checkThread(); @@ -428,6 +459,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getTextJustify() { checkThread(); @@ -439,6 +471,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getTextAnchor() { checkThread(); @@ -450,6 +483,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getTextMaxAngle() { checkThread(); @@ -461,6 +495,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getTextRotate() { checkThread(); @@ -472,6 +507,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getTextPadding() { checkThread(); @@ -483,6 +519,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around Boolean */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Boolean> getTextKeepUpright() { checkThread(); @@ -494,6 +531,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getTextTransform() { checkThread(); @@ -505,6 +543,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around Float[] */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float[]> getTextOffset() { checkThread(); @@ -516,6 +555,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around Boolean */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Boolean> getTextAllowOverlap() { checkThread(); @@ -527,6 +567,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around Boolean */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Boolean> getTextIgnorePlacement() { checkThread(); @@ -538,6 +579,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around Boolean */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Boolean> getTextOptional() { checkThread(); @@ -549,6 +591,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getIconOpacity() { checkThread(); @@ -560,6 +603,7 @@ public class SymbolLayer extends Layer { * * @return transition options for Float */ + @NonNull public TransitionOptions getIconOpacityTransition() { checkThread(); return nativeGetIconOpacityTransition(); @@ -570,7 +614,7 @@ public class SymbolLayer extends Layer { * * @param options transition options for Float */ - public void setIconOpacityTransition(TransitionOptions options) { + public void setIconOpacityTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetIconOpacityTransition(options.getDuration(), options.getDelay()); } @@ -580,6 +624,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getIconColor() { checkThread(); @@ -608,6 +653,7 @@ public class SymbolLayer extends Layer { * * @return transition options for String */ + @NonNull public TransitionOptions getIconColorTransition() { checkThread(); return nativeGetIconColorTransition(); @@ -618,7 +664,7 @@ public class SymbolLayer extends Layer { * * @param options transition options for String */ - public void setIconColorTransition(TransitionOptions options) { + public void setIconColorTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetIconColorTransition(options.getDuration(), options.getDelay()); } @@ -628,6 +674,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getIconHaloColor() { checkThread(); @@ -656,6 +703,7 @@ public class SymbolLayer extends Layer { * * @return transition options for String */ + @NonNull public TransitionOptions getIconHaloColorTransition() { checkThread(); return nativeGetIconHaloColorTransition(); @@ -666,7 +714,7 @@ public class SymbolLayer extends Layer { * * @param options transition options for String */ - public void setIconHaloColorTransition(TransitionOptions options) { + public void setIconHaloColorTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetIconHaloColorTransition(options.getDuration(), options.getDelay()); } @@ -676,6 +724,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getIconHaloWidth() { checkThread(); @@ -687,6 +736,7 @@ public class SymbolLayer extends Layer { * * @return transition options for Float */ + @NonNull public TransitionOptions getIconHaloWidthTransition() { checkThread(); return nativeGetIconHaloWidthTransition(); @@ -697,7 +747,7 @@ public class SymbolLayer extends Layer { * * @param options transition options for Float */ - public void setIconHaloWidthTransition(TransitionOptions options) { + public void setIconHaloWidthTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetIconHaloWidthTransition(options.getDuration(), options.getDelay()); } @@ -707,6 +757,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getIconHaloBlur() { checkThread(); @@ -718,6 +769,7 @@ public class SymbolLayer extends Layer { * * @return transition options for Float */ + @NonNull public TransitionOptions getIconHaloBlurTransition() { checkThread(); return nativeGetIconHaloBlurTransition(); @@ -728,7 +780,7 @@ public class SymbolLayer extends Layer { * * @param options transition options for Float */ - public void setIconHaloBlurTransition(TransitionOptions options) { + public void setIconHaloBlurTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetIconHaloBlurTransition(options.getDuration(), options.getDelay()); } @@ -738,6 +790,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around Float[] */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float[]> getIconTranslate() { checkThread(); @@ -749,6 +802,7 @@ public class SymbolLayer extends Layer { * * @return transition options for Float[] */ + @NonNull public TransitionOptions getIconTranslateTransition() { checkThread(); return nativeGetIconTranslateTransition(); @@ -759,7 +813,7 @@ public class SymbolLayer extends Layer { * * @param options transition options for Float[] */ - public void setIconTranslateTransition(TransitionOptions options) { + public void setIconTranslateTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetIconTranslateTransition(options.getDuration(), options.getDelay()); } @@ -769,6 +823,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getIconTranslateAnchor() { checkThread(); @@ -780,6 +835,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getTextOpacity() { checkThread(); @@ -791,6 +847,7 @@ public class SymbolLayer extends Layer { * * @return transition options for Float */ + @NonNull public TransitionOptions getTextOpacityTransition() { checkThread(); return nativeGetTextOpacityTransition(); @@ -801,7 +858,7 @@ public class SymbolLayer extends Layer { * * @param options transition options for Float */ - public void setTextOpacityTransition(TransitionOptions options) { + public void setTextOpacityTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetTextOpacityTransition(options.getDuration(), options.getDelay()); } @@ -811,6 +868,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getTextColor() { checkThread(); @@ -839,6 +897,7 @@ public class SymbolLayer extends Layer { * * @return transition options for String */ + @NonNull public TransitionOptions getTextColorTransition() { checkThread(); return nativeGetTextColorTransition(); @@ -849,7 +908,7 @@ public class SymbolLayer extends Layer { * * @param options transition options for String */ - public void setTextColorTransition(TransitionOptions options) { + public void setTextColorTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetTextColorTransition(options.getDuration(), options.getDelay()); } @@ -859,6 +918,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getTextHaloColor() { checkThread(); @@ -887,6 +947,7 @@ public class SymbolLayer extends Layer { * * @return transition options for String */ + @NonNull public TransitionOptions getTextHaloColorTransition() { checkThread(); return nativeGetTextHaloColorTransition(); @@ -897,7 +958,7 @@ public class SymbolLayer extends Layer { * * @param options transition options for String */ - public void setTextHaloColorTransition(TransitionOptions options) { + public void setTextHaloColorTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetTextHaloColorTransition(options.getDuration(), options.getDelay()); } @@ -907,6 +968,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getTextHaloWidth() { checkThread(); @@ -918,6 +980,7 @@ public class SymbolLayer extends Layer { * * @return transition options for Float */ + @NonNull public TransitionOptions getTextHaloWidthTransition() { checkThread(); return nativeGetTextHaloWidthTransition(); @@ -928,7 +991,7 @@ public class SymbolLayer extends Layer { * * @param options transition options for Float */ - public void setTextHaloWidthTransition(TransitionOptions options) { + public void setTextHaloWidthTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetTextHaloWidthTransition(options.getDuration(), options.getDelay()); } @@ -938,6 +1001,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around Float */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float> getTextHaloBlur() { checkThread(); @@ -949,6 +1013,7 @@ public class SymbolLayer extends Layer { * * @return transition options for Float */ + @NonNull public TransitionOptions getTextHaloBlurTransition() { checkThread(); return nativeGetTextHaloBlurTransition(); @@ -959,7 +1024,7 @@ public class SymbolLayer extends Layer { * * @param options transition options for Float */ - public void setTextHaloBlurTransition(TransitionOptions options) { + public void setTextHaloBlurTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetTextHaloBlurTransition(options.getDuration(), options.getDelay()); } @@ -969,6 +1034,7 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around Float[] */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<Float[]> getTextTranslate() { checkThread(); @@ -980,6 +1046,7 @@ public class SymbolLayer extends Layer { * * @return transition options for Float[] */ + @NonNull public TransitionOptions getTextTranslateTransition() { checkThread(); return nativeGetTextTranslateTransition(); @@ -990,7 +1057,7 @@ public class SymbolLayer extends Layer { * * @param options transition options for Float[] */ - public void setTextTranslateTransition(TransitionOptions options) { + public void setTextTranslateTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetTextTranslateTransition(options.getDuration(), options.getDelay()); } @@ -1000,234 +1067,298 @@ public class SymbolLayer extends Layer { * * @return property wrapper value around String */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<String> getTextTranslateAnchor() { checkThread(); return (PropertyValue<String>) new PropertyValue("text-translate-anchor", nativeGetTextTranslateAnchor()); } + @NonNull @Keep private native Object nativeGetSymbolPlacement(); + @NonNull @Keep private native Object nativeGetSymbolSpacing(); + @NonNull @Keep private native Object nativeGetSymbolAvoidEdges(); + @NonNull @Keep private native Object nativeGetSymbolZOrder(); + @NonNull @Keep private native Object nativeGetIconAllowOverlap(); + @NonNull @Keep private native Object nativeGetIconIgnorePlacement(); + @NonNull @Keep private native Object nativeGetIconOptional(); + @NonNull @Keep private native Object nativeGetIconRotationAlignment(); + @NonNull @Keep private native Object nativeGetIconSize(); + @NonNull @Keep private native Object nativeGetIconTextFit(); + @NonNull @Keep private native Object nativeGetIconTextFitPadding(); + @NonNull @Keep private native Object nativeGetIconImage(); + @NonNull @Keep private native Object nativeGetIconRotate(); + @NonNull @Keep private native Object nativeGetIconPadding(); + @NonNull @Keep private native Object nativeGetIconKeepUpright(); + @NonNull @Keep private native Object nativeGetIconOffset(); + @NonNull @Keep private native Object nativeGetIconAnchor(); + @NonNull @Keep private native Object nativeGetIconPitchAlignment(); + @NonNull @Keep private native Object nativeGetTextPitchAlignment(); + @NonNull @Keep private native Object nativeGetTextRotationAlignment(); + @NonNull @Keep private native Object nativeGetTextField(); + @NonNull @Keep private native Object nativeGetTextFont(); + @NonNull @Keep private native Object nativeGetTextSize(); + @NonNull @Keep private native Object nativeGetTextMaxWidth(); + @NonNull @Keep private native Object nativeGetTextLineHeight(); + @NonNull @Keep private native Object nativeGetTextLetterSpacing(); + @NonNull @Keep private native Object nativeGetTextJustify(); + @NonNull @Keep private native Object nativeGetTextAnchor(); + @NonNull @Keep private native Object nativeGetTextMaxAngle(); + @NonNull @Keep private native Object nativeGetTextRotate(); + @NonNull @Keep private native Object nativeGetTextPadding(); + @NonNull @Keep private native Object nativeGetTextKeepUpright(); + @NonNull @Keep private native Object nativeGetTextTransform(); + @NonNull @Keep private native Object nativeGetTextOffset(); + @NonNull @Keep private native Object nativeGetTextAllowOverlap(); + @NonNull @Keep private native Object nativeGetTextIgnorePlacement(); + @NonNull @Keep private native Object nativeGetTextOptional(); + @NonNull @Keep private native Object nativeGetIconOpacity(); + @NonNull @Keep private native TransitionOptions nativeGetIconOpacityTransition(); @Keep private native void nativeSetIconOpacityTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetIconColor(); + @NonNull @Keep private native TransitionOptions nativeGetIconColorTransition(); @Keep private native void nativeSetIconColorTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetIconHaloColor(); + @NonNull @Keep private native TransitionOptions nativeGetIconHaloColorTransition(); @Keep private native void nativeSetIconHaloColorTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetIconHaloWidth(); + @NonNull @Keep private native TransitionOptions nativeGetIconHaloWidthTransition(); @Keep private native void nativeSetIconHaloWidthTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetIconHaloBlur(); + @NonNull @Keep private native TransitionOptions nativeGetIconHaloBlurTransition(); @Keep private native void nativeSetIconHaloBlurTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetIconTranslate(); + @NonNull @Keep private native TransitionOptions nativeGetIconTranslateTransition(); @Keep private native void nativeSetIconTranslateTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetIconTranslateAnchor(); + @NonNull @Keep private native Object nativeGetTextOpacity(); + @NonNull @Keep private native TransitionOptions nativeGetTextOpacityTransition(); @Keep private native void nativeSetTextOpacityTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetTextColor(); + @NonNull @Keep private native TransitionOptions nativeGetTextColorTransition(); @Keep private native void nativeSetTextColorTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetTextHaloColor(); + @NonNull @Keep private native TransitionOptions nativeGetTextHaloColorTransition(); @Keep private native void nativeSetTextHaloColorTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetTextHaloWidth(); + @NonNull @Keep private native TransitionOptions nativeGetTextHaloWidthTransition(); @Keep private native void nativeSetTextHaloWidthTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetTextHaloBlur(); + @NonNull @Keep private native TransitionOptions nativeGetTextHaloBlurTransition(); @Keep private native void nativeSetTextHaloBlurTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetTextTranslate(); + @NonNull @Keep private native TransitionOptions nativeGetTextTranslateTransition(); @Keep private native void nativeSetTextTranslateTransition(long duration, long delay); + @NonNull @Keep private native Object nativeGetTextTranslateAnchor(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/TransitionOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/TransitionOptions.java index 2a25302aed..dbd6d77761 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/TransitionOptions.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/TransitionOptions.java @@ -1,6 +1,8 @@ package com.mapbox.mapboxsdk.style.layers; import android.support.annotation.Keep; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; /** * Resembles transition property from the style specification. @@ -54,7 +56,7 @@ public class TransitionOptions { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } @@ -77,6 +79,7 @@ public class TransitionOptions { return result; } + @NonNull @Override public String toString() { return "TransitionOptions{" diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/layer.java.ejs b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/layer.java.ejs index 958cb7383d..022858c29d 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/layer.java.ejs +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/layer.java.ejs @@ -82,6 +82,7 @@ public class <%- camelize(type) %>Layer extends Layer { * @param sourceLayer the source layer to set * @return This */ + @NonNull public <%- camelize(type) %>Layer withSourceLayer(String sourceLayer) { setSourceLayer(sourceLayer); return this; @@ -94,6 +95,7 @@ public class <%- camelize(type) %>Layer extends Layer { * * @return id of the source */ + @NonNull public String getSourceId() { checkThread(); return nativeGetSourceId(); @@ -106,6 +108,7 @@ public class <%- camelize(type) %>Layer extends Layer { * * @return sourceLayer the source layer to get */ + @NonNull public String getSourceLayer() { checkThread(); return nativeGetSourceLayer(); @@ -116,7 +119,7 @@ public class <%- camelize(type) %>Layer extends Layer { * * @param filter the expression filter to set */ - public void setFilter(Expression filter) { + public void setFilter(@NonNull Expression filter) { checkThread(); nativeSetFilter(filter.toArray()); } @@ -127,7 +130,8 @@ public class <%- camelize(type) %>Layer extends Layer { * @param filter the expression filter to set * @return This */ - public <%- camelize(type) %>Layer withFilter(Expression filter) { + @NonNull + public <%- camelize(type) %>Layer withFilter(@NonNull Expression filter) { setFilter(filter); return this; } @@ -155,6 +159,7 @@ public class <%- camelize(type) %>Layer extends Layer { * @param properties the var-args properties * @return This */ + @NonNull public <%- camelize(type) %>Layer withProperties(@NonNull PropertyValue<?>... properties) { setProperties(properties); return this; @@ -168,6 +173,7 @@ public class <%- camelize(type) %>Layer extends Layer { * * @return property wrapper value around <%- propertyType(property) %> */ + @NonNull @SuppressWarnings("unchecked") public PropertyValue<<%- propertyType(property) %>> get<%- camelize(property.name) %>() { checkThread(); @@ -199,6 +205,7 @@ public class <%- camelize(type) %>Layer extends Layer { * * @return transition options for <%- propertyType(property) %> */ + @NonNull public TransitionOptions get<%- camelize(property.name) %>Transition() { checkThread(); return nativeGet<%- camelize(property.name) %>Transition(); @@ -209,7 +216,7 @@ public class <%- camelize(type) %>Layer extends Layer { * * @param options transition options for <%- propertyType(property) %> */ - public void set<%- camelize(property.name) %>Transition(TransitionOptions options) { + public void set<%- camelize(property.name) %>Transition(@NonNull TransitionOptions options) { checkThread(); nativeSet<%- camelize(property.name) %>Transition(options.getDuration(), options.getDelay()); } @@ -217,10 +224,12 @@ public class <%- camelize(type) %>Layer extends Layer { <% } -%> <% for (const property of properties) { -%> + @NonNull @Keep private native Object nativeGet<%- camelize(property.name) %>(); <% if (property.transition) { -%> + @NonNull @Keep private native TransitionOptions nativeGet<%- camelize(property.name) %>Transition(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Light.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Light.java index f3886d6cce..0c8ce01a49 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Light.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Light.java @@ -49,6 +49,7 @@ public class Light { * * @return anchor as String */ + @NonNull @Property.ANCHOR public String getAnchor() { checkThread(); return nativeGetAnchor(); @@ -69,6 +70,7 @@ public class Light { * * @return position as Position */ + @NonNull public Position getPosition() { checkThread(); return nativeGetPosition(); @@ -79,6 +81,7 @@ public class Light { * * @return transition options for position */ + @NonNull public TransitionOptions getPositionTransition() { checkThread(); return nativeGetPositionTransition(); @@ -89,7 +92,7 @@ public class Light { * * @param options transition options for position */ - public void setPositionTransition(TransitionOptions options) { + public void setPositionTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetPositionTransition(options.getDuration(), options.getDelay()); } @@ -119,6 +122,7 @@ public class Light { * * @return color as String */ + @NonNull public String getColor() { checkThread(); return nativeGetColor(); @@ -129,6 +133,7 @@ public class Light { * * @return transition options for color */ + @NonNull public TransitionOptions getColorTransition() { checkThread(); return nativeGetColorTransition(); @@ -139,7 +144,7 @@ public class Light { * * @param options transition options for color */ - public void setColorTransition(TransitionOptions options) { + public void setColorTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetColorTransition(options.getDuration(), options.getDelay()); } @@ -159,6 +164,7 @@ public class Light { * * @return intensity as Float */ + @NonNull public float getIntensity() { checkThread(); return nativeGetIntensity(); @@ -169,6 +175,7 @@ public class Light { * * @return transition options for intensity */ + @NonNull public TransitionOptions getIntensityTransition() { checkThread(); return nativeGetIntensityTransition(); @@ -179,7 +186,7 @@ public class Light { * * @param options transition options for intensity */ - public void setIntensityTransition(TransitionOptions options) { + public void setIntensityTransition(@NonNull TransitionOptions options) { checkThread(); nativeSetIntensityTransition(options.getDuration(), options.getDelay()); } @@ -191,13 +198,16 @@ public class Light { @Keep private native void nativeSetAnchor(String anchor); + @NonNull @Keep private native String nativeGetAnchor(); @Keep private native void nativeSetPosition(Position position); + @NonNull @Keep private native Position nativeGetPosition(); + @NonNull @Keep private native TransitionOptions nativeGetPositionTransition(); @@ -206,8 +216,10 @@ public class Light { @Keep private native void nativeSetColor(String color); + @NonNull @Keep private native String nativeGetColor(); + @NonNull @Keep private native TransitionOptions nativeGetColorTransition(); @@ -216,8 +228,10 @@ public class Light { @Keep private native void nativeSetIntensity(float intensity); + @NonNull @Keep private native float nativeGetIntensity(); + @NonNull @Keep private native TransitionOptions nativeGetIntensityTransition(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Position.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Position.java index efd92f65a4..5678b64470 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Position.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Position.java @@ -1,6 +1,8 @@ package com.mapbox.mapboxsdk.style.light; import android.support.annotation.Keep; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; /** * Position of the light source relative to lit (extruded) geometries. @@ -49,7 +51,7 @@ public class Position { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } @@ -76,6 +78,7 @@ public class Position { return result; } + @NonNull @Override public String toString() { return "Position{" diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/light.java.ejs b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/light.java.ejs index 7c9893a3a4..2a2734f7e1 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/light.java.ejs +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/light.java.ejs @@ -55,6 +55,7 @@ public class Light { * * @return <%- property.name %> as Position */ + @NonNull public Position get<%- camelize(property.name) %>() { checkThread(); return nativeGet<%- camelize(property.name) %>(); @@ -88,6 +89,7 @@ public class Light { * * @return <%- property.name %> as <%- propertyType(property) %> */ + @NonNull <%- propertyTypeAnnotation(property) %> public <%- propertyJavaType(property) %> get<%- camelize(property.name) %>() { checkThread(); return nativeGet<%- camelize(property.name) %>(); @@ -100,6 +102,7 @@ public class Light { * * @return transition options for <%- property.name %> */ + @NonNull public TransitionOptions get<%- camelize(property.name) %>Transition() { checkThread(); return nativeGet<%- camelize(property.name) %>Transition(); @@ -110,7 +113,7 @@ public class Light { * * @param options transition options for <%- property.name %> */ - public void set<%- camelize(property.name) %>Transition(TransitionOptions options) { + public void set<%- camelize(property.name) %>Transition(@NonNull TransitionOptions options) { checkThread(); nativeSet<%- camelize(property.name) %>Transition(options.getDuration(), options.getDelay()); } @@ -126,16 +129,19 @@ public class Light { @Keep private native void nativeSet<%- camelize(property.name) %>(Position position); + @NonNull @Keep private native Position nativeGet<%- camelize(property.name) %>(); <% } else { -%> @Keep private native void nativeSet<%- camelize(property.name) %>(<%- propertyJavaType(property) -%> <%- property.name %>); + @NonNull @Keep private native <%- propertyJavaType(property) -%> nativeGet<%- camelize(property.name) %>(); <% } -%> <% if (property.transition) { -%> + @NonNull @Keep private native TransitionOptions nativeGet<%- camelize(property.name) %>Transition(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/CustomGeometrySource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/CustomGeometrySource.java index a44d7cab1a..cfb46b0cec 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/CustomGeometrySource.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/CustomGeometrySource.java @@ -129,6 +129,7 @@ public class CustomGeometrySource extends Source { @Keep protected native void initialize(String sourceId, Object options); + @NonNull @Keep private native Feature[] querySourceFeatures(Object[] filter); @@ -179,7 +180,7 @@ public class CustomGeometrySource extends Source { } } - private void executeRequest(GeometryTileRequest request) { + private void executeRequest(@NonNull GeometryTileRequest request) { executorLock.lock(); try { if (executor != null && !executor.isShutdown()) { @@ -235,6 +236,7 @@ public class CustomGeometrySource extends Source { final AtomicInteger threadCount = new AtomicInteger(); final int poolId = poolCount.getAndIncrement(); + @NonNull @Override public Thread newThread(@NonNull Runnable runnable) { return new Thread( @@ -277,7 +279,7 @@ public class CustomGeometrySource extends Source { return Arrays.hashCode(new int[] {z, x, y}); } - public boolean equals(Object object) { + public boolean equals(@Nullable Object object) { if (object == this) { return true; } @@ -299,6 +301,7 @@ public class CustomGeometrySource extends Source { private final GeometryTileProvider provider; private final Map<TileID, GeometryTileRequest> awaiting; private final Map<TileID, AtomicBoolean> inProgress; + @NonNull private final WeakReference<CustomGeometrySource> sourceRef; private final AtomicBoolean cancelled; @@ -362,7 +365,7 @@ public class CustomGeometrySource extends Source { } @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/style/sources/CustomGeometrySourceOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/CustomGeometrySourceOptions.java index 4ada38c238..92c0881c74 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/CustomGeometrySourceOptions.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/CustomGeometrySourceOptions.java @@ -1,5 +1,7 @@ package com.mapbox.mapboxsdk.style.sources; +import android.support.annotation.NonNull; + /** * Builder class for composing CustomGeometrySource objects. */ @@ -11,6 +13,7 @@ public class CustomGeometrySourceOptions extends GeoJsonOptions { * @param wrap defaults to false * @return the current instance for chaining */ + @NonNull public CustomGeometrySourceOptions withWrap(boolean wrap) { this.put("wrap", wrap); return this; @@ -23,6 +26,7 @@ public class CustomGeometrySourceOptions extends GeoJsonOptions { * @param clip defaults to false * @return the current instance for chaining */ + @NonNull public CustomGeometrySourceOptions withClip(boolean clip) { this.put("clip", clip); return this; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonOptions.java index 00715bc213..1e1b9bafa6 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonOptions.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonOptions.java @@ -1,5 +1,7 @@ package com.mapbox.mapboxsdk.style.sources; +import android.support.annotation.NonNull; + import java.util.HashMap; /** @@ -16,6 +18,7 @@ public class GeoJsonOptions extends HashMap<String, Object> { * @param minZoom the minimum zoom - Defaults to 0. * @return the current instance for chaining */ + @NonNull public GeoJsonOptions withMinZoom(int minZoom) { this.put("minzoom", minZoom); return this; @@ -27,6 +30,7 @@ public class GeoJsonOptions extends HashMap<String, Object> { * @param maxZoom the maximum zoom - Defaults to 25.5 * @return the current instance for chaining */ + @NonNull public GeoJsonOptions withMaxZoom(int maxZoom) { this.put("maxzoom", maxZoom); return this; @@ -39,6 +43,7 @@ public class GeoJsonOptions extends HashMap<String, Object> { * @param buffer the buffer size - Defaults to 128. * @return the current instance for chaining */ + @NonNull public GeoJsonOptions withBuffer(int buffer) { this.put("buffer", buffer); return this; @@ -50,6 +55,7 @@ public class GeoJsonOptions extends HashMap<String, Object> { * @param lineMetrics true to calculate line distance metrics. * @return the current instance for chaining */ + @NonNull public GeoJsonOptions withLineMetrics(boolean lineMetrics) { this.put("lineMetrics", lineMetrics); return this; @@ -61,6 +67,7 @@ public class GeoJsonOptions extends HashMap<String, Object> { * @param tolerance the tolerance - Defaults to 0.375 * @return the current instance for chaining */ + @NonNull public GeoJsonOptions withTolerance(float tolerance) { this.put("tolerance", tolerance); return this; @@ -72,6 +79,7 @@ public class GeoJsonOptions extends HashMap<String, Object> { * @param cluster cluster? - Defaults to false * @return the current instance for chaining */ + @NonNull public GeoJsonOptions withCluster(boolean cluster) { this.put("cluster", cluster); return this; @@ -84,6 +92,7 @@ public class GeoJsonOptions extends HashMap<String, Object> { * zoom features are not clustered) * @return the current instance for chaining */ + @NonNull public GeoJsonOptions withClusterMaxZoom(int clusterMaxZoom) { this.put("clusterMaxZoom", clusterMaxZoom); return this; @@ -95,6 +104,7 @@ public class GeoJsonOptions extends HashMap<String, Object> { * @param clusterRadius cluster radius - Defaults to 50 * @return the current instance for chaining */ + @NonNull public GeoJsonOptions withClusterRadius(int clusterRadius) { this.put("clusterRadius", clusterRadius); return this; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java index 2d9b1c985a..a9eb43f968 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java @@ -62,7 +62,7 @@ public class GeoJsonSource extends Source { * @param id the source id * @param geoJson raw Json FeatureCollection */ - public GeoJsonSource(String id, String geoJson) { + public GeoJsonSource(String id, @Nullable String geoJson) { super(); if (geoJson == null || geoJson.startsWith("http")) { throw new IllegalArgumentException("Expected a raw json body"); @@ -78,7 +78,7 @@ public class GeoJsonSource extends Source { * @param geoJson raw Json body * @param options options */ - public GeoJsonSource(String id, String geoJson, GeoJsonOptions options) { + public GeoJsonSource(String id, @Nullable String geoJson, GeoJsonOptions options) { super(); if (geoJson == null || geoJson.startsWith("http")) { throw new IllegalArgumentException("Expected a raw json body"); @@ -236,7 +236,7 @@ public class GeoJsonSource extends Source { * * @param url the GeoJSON FeatureCollection url */ - public void setUrl(URL url) { + public void setUrl(@NonNull URL url) { checkThread(); setUrl(url.toExternalForm()); } @@ -279,6 +279,7 @@ public class GeoJsonSource extends Source { @Keep protected native void nativeSetUrl(String url); + @NonNull @Keep protected native String nativeGetUrl(); @@ -294,6 +295,7 @@ public class GeoJsonSource extends Source { @Keep private native void nativeSetGeometry(Geometry geometry); + @NonNull @Keep private native Feature[] querySourceFeatures(Object[] filter); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/ImageSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/ImageSource.java index d0ca5e050b..2579c95870 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/ImageSource.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/ImageSource.java @@ -46,7 +46,7 @@ public class ImageSource extends Source { * @param coordinates The Latitude and Longitude of the four corners of the image * @param url remote json file */ - public ImageSource(String id, LatLngQuad coordinates, URL url) { + public ImageSource(String id, LatLngQuad coordinates, @NonNull URL url) { super(); initialize(id, coordinates); setUrl(url); @@ -83,7 +83,7 @@ public class ImageSource extends Source { * * @param url An Image url */ - public void setUrl(URL url) { + public void setUrl(@NonNull URL url) { setUrl(url.toExternalForm()); } @@ -149,6 +149,7 @@ public class ImageSource extends Source { @Keep protected native void nativeSetUrl(String url); + @NonNull @Keep protected native String nativeGetUrl(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/RasterDemSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/RasterDemSource.java index 4c2b39375a..6bc6d40287 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/RasterDemSource.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/RasterDemSource.java @@ -1,6 +1,7 @@ package com.mapbox.mapboxsdk.style.sources; import android.support.annotation.Keep; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.UiThread; @@ -97,6 +98,7 @@ public class RasterDemSource extends Source { @Keep protected native void finalize() throws Throwable; + @NonNull @Keep protected native String nativeGetUrl(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/RasterSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/RasterSource.java index dac9b02166..1390a1c055 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/RasterSource.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/RasterSource.java @@ -1,6 +1,7 @@ package com.mapbox.mapboxsdk.style.sources; import android.support.annotation.Keep; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import java.net.URL; @@ -96,6 +97,7 @@ public class RasterSource extends Source { @Keep protected native void finalize() throws Throwable; + @NonNull @Keep protected native String nativeGetUrl(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/Source.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/Source.java index 14d9ef1cc5..44f4a6c344 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/Source.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/Source.java @@ -2,6 +2,7 @@ package com.mapbox.mapboxsdk.style.sources; import android.support.annotation.Keep; +import android.support.annotation.NonNull; import com.mapbox.mapboxsdk.utils.ThreadUtils; /** @@ -39,6 +40,7 @@ public abstract class Source { * * @return the source id */ + @NonNull public String getId() { checkThread(); return nativeGetId(); @@ -52,6 +54,7 @@ public abstract class Source { * * @return the string representation of the attribution in html format */ + @NonNull public String getAttribution() { checkThread(); return nativeGetAttribution(); @@ -66,9 +69,11 @@ public abstract class Source { return nativePtr; } + @NonNull @Keep protected native String nativeGetId(); + @NonNull @Keep protected native String nativeGetAttribution(); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/TileSet.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/TileSet.java index 25df2d91e7..1e4be24189 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/TileSet.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/TileSet.java @@ -1,5 +1,6 @@ package com.mapbox.mapboxsdk.style.sources; +import android.support.annotation.NonNull; import android.support.annotation.Size; import com.mapbox.mapboxsdk.geometry.LatLng; @@ -281,10 +282,11 @@ public class TileSet { this.center = center; } - public void setCenter(LatLng center) { + public void setCenter(@NonNull LatLng center) { this.center = new Float[] {(float) center.getLongitude(), (float) center.getLatitude()}; } + @NonNull Map<String, Object> toValueObject() { Map<String, Object> result = new HashMap<>(); result.put("tilejson", tilejson); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/VectorSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/VectorSource.java index 5888eaa7e1..7028530f1f 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/VectorSource.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/VectorSource.java @@ -97,9 +97,11 @@ public class VectorSource extends Source { @Keep protected native void finalize() throws Throwable; + @NonNull @Keep protected native String nativeGetUrl(); + @NonNull @Keep private native Feature[] querySourceFeatures(String[] sourceLayerId, Object[] filter); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/text/LocalGlyphRasterizer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/text/LocalGlyphRasterizer.java index a4e98532d1..40e116fbc6 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/text/LocalGlyphRasterizer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/text/LocalGlyphRasterizer.java @@ -7,6 +7,7 @@ import android.graphics.Bitmap; import android.graphics.PorterDuff; import android.graphics.Typeface; import android.support.annotation.Keep; +import android.support.annotation.NonNull; import android.support.annotation.WorkerThread; /** @@ -15,7 +16,9 @@ import android.support.annotation.WorkerThread; */ public class LocalGlyphRasterizer { private final Bitmap bitmap; + @NonNull private final Paint paint; + @NonNull private final Canvas canvas; LocalGlyphRasterizer() { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/AnimatorUtils.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/AnimatorUtils.java index 34c52c829b..e90c416a2d 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/AnimatorUtils.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/AnimatorUtils.java @@ -35,7 +35,7 @@ public class AnimatorUtils { * @param duration the duration of the animator * @param listener the animator end listener */ - public static void animate(final View view, @AnimatorRes int animatorRes, int duration, + public static void animate(@Nullable final View view, @AnimatorRes int animatorRes, int duration, @Nullable final OnAnimationEndListener listener) { if (view == null) { return; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/BitmapUtils.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/BitmapUtils.java index 78503f9dfe..5584a6eb58 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/BitmapUtils.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/BitmapUtils.java @@ -7,6 +7,7 @@ import android.graphics.Canvas; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.view.View; import java.io.ByteArrayOutputStream; @@ -58,7 +59,8 @@ public class BitmapUtils { * @param sourceDrawable The source drawable * @return The underlying bitmap */ - public static Bitmap getBitmapFromDrawable(Drawable sourceDrawable) { + @Nullable + public static Bitmap getBitmapFromDrawable(@Nullable Drawable sourceDrawable) { if (sourceDrawable == null) { return null; } @@ -88,7 +90,8 @@ public class BitmapUtils { * @param drawable The source drawable * @return The byte array of source drawable */ - public static byte[] getByteArrayFromDrawable(Drawable drawable) { + @Nullable + public static byte[] getByteArrayFromDrawable(@Nullable Drawable drawable) { if (drawable == null) { return null; } @@ -109,7 +112,8 @@ public class BitmapUtils { * @param array The source byte array * @return The drawable created from source byte array */ - public static Drawable getDrawableFromByteArray(Context context, byte[] array) { + @Nullable + public static Drawable getDrawableFromByteArray(@NonNull Context context, @Nullable byte[] array) { if (array == null) { return null; } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ColorUtils.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ColorUtils.java index 3a53794e50..aa87f8762d 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ColorUtils.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ColorUtils.java @@ -126,7 +126,7 @@ public class ColorUtils { * @throws ConversionException on illegal input */ @ColorInt - public static int rgbaToColor(String value) { + public static int rgbaToColor(@NonNull String value) { Pattern c = Pattern.compile("rgba?\\s*\\(\\s*(\\d+\\.?\\d*)\\s*,\\s*(\\d+\\.?\\d*)\\s*,\\s*(\\d+\\.?\\d*)\\s*," + "?\\s*(\\d+\\.?\\d*)?\\s*\\)"); Matcher m = c.matcher(value); @@ -193,7 +193,7 @@ public class ColorUtils { }; } - private static int getColorCompat(Context context, int id) { + private static int getColorCompat(@NonNull Context context, int id) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { return context.getResources().getColor(id, context.getTheme()); } else { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/FileUtils.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/FileUtils.java index b7d09cda2a..52009d20ef 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/FileUtils.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/FileUtils.java @@ -1,6 +1,7 @@ package com.mapbox.mapboxsdk.utils; import android.os.AsyncTask; +import android.support.annotation.NonNull; import java.io.File; import java.lang.ref.WeakReference; @@ -11,6 +12,7 @@ public class FileUtils { * Task checking whether app's process can read a file. */ public static class CheckFileReadPermissionTask extends AsyncTask<File, Void, Boolean> { + @NonNull private final WeakReference<OnCheckFileReadPermissionListener> listenerWeakReference; public CheckFileReadPermissionTask(OnCheckFileReadPermissionListener listener) { @@ -67,6 +69,7 @@ public class FileUtils { * Task checking whether app's process can write to a file. */ public static class CheckFileWritePermissionTask extends AsyncTask<File, Void, Boolean> { + @NonNull private final WeakReference<OnCheckFileWritePermissionListener> listenerWeakReference; public CheckFileWritePermissionTask(OnCheckFileWritePermissionListener listener) { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/MapFragmentUtils.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/MapFragmentUtils.java index 08d39d6b3b..f3c8fd32cf 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/MapFragmentUtils.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/MapFragmentUtils.java @@ -3,6 +3,8 @@ package com.mapbox.mapboxsdk.utils; import android.content.Context; import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import com.mapbox.mapboxsdk.constants.MapboxConstants; import com.mapbox.mapboxsdk.maps.MapboxMapOptions; @@ -21,6 +23,7 @@ public class MapFragmentUtils { * @param options The MapboxMapOptions to convert * @return a bundle of converted fragment arguments */ + @NonNull public static Bundle createFragmentArgs(MapboxMapOptions options) { Bundle bundle = new Bundle(); bundle.putParcelable(MapboxConstants.FRAG_ARG_MAPBOXMAPOPTIONS, options); @@ -34,7 +37,8 @@ public class MapFragmentUtils { * @param args The fragment arguments * @return converted MapboxMapOptions */ - public static MapboxMapOptions resolveArgs(Context context, Bundle args) { + @Nullable + public static MapboxMapOptions resolveArgs(@NonNull Context context, @Nullable Bundle args) { MapboxMapOptions options; if (args != null && args.containsKey(MapboxConstants.FRAG_ARG_MAPBOXMAPOPTIONS)) { options = args.getParcelable(MapboxConstants.FRAG_ARG_MAPBOXMAPOPTIONS); diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/AnnotationTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/AnnotationTest.java index 605e159b84..0c61b01be6 100644 --- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/AnnotationTest.java +++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/AnnotationTest.java @@ -1,5 +1,6 @@ package com.mapbox.mapboxsdk.annotations; +import android.support.annotation.NonNull; import com.mapbox.mapboxsdk.maps.MapboxMap; import org.junit.Before; @@ -20,6 +21,7 @@ public class AnnotationTest { @InjectMocks private MapboxMap mapboxMap = mock(MapboxMap.class); private Annotation annotation; + @NonNull private Annotation compare = new Annotation() { @Override public long getId() { diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationComponentOptionsTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationComponentOptionsTest.java index 4c25fa840d..f228adcce7 100644 --- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationComponentOptionsTest.java +++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationComponentOptionsTest.java @@ -4,6 +4,7 @@ import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; +import android.support.annotation.NonNull; import com.mapbox.mapboxsdk.R; import org.junit.Before; @@ -27,6 +28,7 @@ public class LocationComponentOptionsTest { @Mock private Resources resources; + @NonNull @Rule public ExpectedException thrown = ExpectedException.none(); diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.java index cb6dcd8fe5..51fdf812e6 100644 --- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.java +++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.java @@ -2,6 +2,7 @@ package com.mapbox.mapboxsdk.location; import android.graphics.Bitmap; +import android.support.annotation.NonNull; import com.google.gson.JsonElement; import com.mapbox.geojson.Feature; import com.mapbox.mapboxsdk.geometry.LatLng; @@ -442,13 +443,13 @@ public class LocationLayerControllerTest { verify(locationFeature, times(0)).addNumberProperty(PROPERTY_ACCURACY_RADIUS, accuracyRadiusValue); } - private LayerFeatureProvider buildFeatureProvider(LocationComponentOptions options) { + private LayerFeatureProvider buildFeatureProvider(@NonNull LocationComponentOptions options) { LayerFeatureProvider provider = mock(LayerFeatureProvider.class); when(provider.generateLocationFeature(null, options)).thenReturn(mock(Feature.class)); return provider; } - private LayerFeatureProvider buildFeatureProvider(Feature feature, LocationComponentOptions options) { + private LayerFeatureProvider buildFeatureProvider(Feature feature, @NonNull LocationComponentOptions options) { LayerFeatureProvider provider = mock(LayerFeatureProvider.class); when(provider.generateLocationFeature(null, options)).thenReturn(feature); return provider; diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java index 9a323a1d75..83f10b6796 100644 --- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java +++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java @@ -1,5 +1,6 @@ package com.mapbox.mapboxsdk.maps; +import android.support.annotation.Nullable; import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; import com.mapbox.mapboxsdk.geometry.LatLng; @@ -11,6 +12,7 @@ import static org.mockito.Mockito.mock; public class MapboxMapTest { + @Nullable private MapboxMap mapboxMap; @Before diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/utils/MockParcel.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/utils/MockParcel.java index dd4c7b25ee..fac69826a1 100644 --- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/utils/MockParcel.java +++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/utils/MockParcel.java @@ -4,6 +4,7 @@ import android.os.Parcel; import android.os.Parcelable; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; @@ -28,10 +29,12 @@ import static org.mockito.Mockito.when; public class MockParcel { + @Nullable public static Parcelable obtain(@NonNull Parcelable object) { return obtain(object, 0); } + @Nullable public static Parcelable obtain(@NonNull Parcelable object, int describeContentsValue) { testDescribeContents(object, describeContentsValue); testParcelableArray(object); @@ -166,48 +169,56 @@ public class MockParcel { private void setupReads() { when(mockedParcel.readInt()).then(new Answer<Integer>() { + @NonNull @Override public Integer answer(InvocationOnMock invocation) throws Throwable { return (Integer) objects.get(position++); } }); when(mockedParcel.readByte()).thenAnswer(new Answer<Byte>() { + @NonNull @Override public Byte answer(InvocationOnMock invocation) throws Throwable { return (Byte) objects.get(position++); } }); when(mockedParcel.readLong()).thenAnswer(new Answer<Long>() { + @NonNull @Override public Long answer(InvocationOnMock invocation) throws Throwable { return (Long) objects.get(position++); } }); when(mockedParcel.readString()).thenAnswer(new Answer<String>() { + @NonNull @Override public String answer(InvocationOnMock invocation) throws Throwable { return (String) objects.get(position++); } }); when(mockedParcel.readDouble()).thenAnswer(new Answer<Double>() { + @NonNull @Override public Double answer(InvocationOnMock invocation) throws Throwable { return (Double) objects.get(position++); } }); when(mockedParcel.readFloat()).thenAnswer(new Answer<Float>() { + @NonNull @Override public Float answer(InvocationOnMock invocation) throws Throwable { return (Float) objects.get(position++); } }); when(mockedParcel.readParcelable(Parcelable.class.getClassLoader())).thenAnswer(new Answer<Parcelable>() { + @NonNull @Override public Parcelable answer(InvocationOnMock invocation) throws Throwable { return (Parcelable) objects.get(position++); } }); when(mockedParcel.readParcelableArray(Parcelable.class.getClassLoader())).thenAnswer(new Answer<Object[]>() { + @NonNull @Override public Object[] answer(InvocationOnMock invocation) throws Throwable { int size = (Integer) objects.get(position++); @@ -224,6 +235,7 @@ public class MockParcel { } }); when(mockedParcel.createIntArray()).then(new Answer<int[]>() { + @Nullable @Override public int[] answer(InvocationOnMock invocation) throws Throwable { int size = (Integer) objects.get(position++); @@ -243,8 +255,9 @@ public class MockParcel { private void setupOthers() { doAnswer(new Answer<Void>() { + @Nullable @Override - public Void answer(InvocationOnMock invocation) throws Throwable { + public Void answer(@NonNull InvocationOnMock invocation) throws Throwable { position = ((Integer) invocation.getArguments()[0]); return null; } |