[android] - nullify codebase with annotations

This commit is contained in:
Tobrun
2018-11-02 15:53:31 +01:00
committed by Tobrun
parent c8f59d3692
commit 81258a2553
133 changed files with 1371 additions and 408 deletions

View File

@@ -28,13 +28,14 @@ import com.mapbox.mapboxsdk.utils.ThreadUtils;
public final class Mapbox {
private static final String TAG = "Mbgl-Mapbox";
private static ModuleProvider moduleProvider;
private static Mapbox INSTANCE;
private Context context;
@Nullable
private String accessToken;
private Boolean connected;
@Nullable
private TelemetryDefinition telemetry;
/**
@@ -48,6 +49,7 @@ public final class Mapbox {
* @return the single instance of Mapbox
*/
@UiThread
@NonNull
public static synchronized Mapbox getInstance(@NonNull Context context, @Nullable String accessToken) {
ThreadUtils.checkThread("Mapbox");
if (INSTANCE == null) {
@@ -171,7 +173,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;
}

View File

@@ -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,7 +122,7 @@ 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;
}

View File

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

View File

@@ -8,6 +8,7 @@ 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 {
@@ -16,14 +17,16 @@ class Bubble extends Drawable {
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 +52,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 +84,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) {
@@ -138,7 +141,7 @@ class Bubble extends Drawable {
}
}
private void initLeftSquarePath(RectF rect, Path path, float strokeWidth) {
private void initLeftSquarePath(@NonNull RectF rect, @NonNull Path path, float strokeWidth) {
path.moveTo(arrowWidth + rect.left + strokeWidth, rect.top + strokeWidth);
path.lineTo(rect.width() - strokeWidth, rect.top + strokeWidth);
@@ -155,7 +158,7 @@ class Bubble extends Drawable {
path.close();
}
private void initLeftRoundedPath(RectF rect, Path path, float strokeWidth) {
private void initLeftRoundedPath(@NonNull RectF rect, @NonNull Path path, float strokeWidth) {
path.moveTo(arrowWidth + rect.left + cornersRadius + strokeWidth, rect.top + strokeWidth);
path.lineTo(rect.width() - cornersRadius - strokeWidth, rect.top + strokeWidth);
path.arcTo(new RectF(rect.right - cornersRadius, rect.top + strokeWidth, rect.right - strokeWidth,
@@ -184,7 +187,7 @@ class Bubble extends Drawable {
path.close();
}
private void initTopSquarePath(RectF rect, Path path, float strokeWidth) {
private void initTopSquarePath(@NonNull RectF rect, @NonNull Path path, float strokeWidth) {
path.moveTo(rect.left + arrowPosition + strokeWidth, rect.top + arrowHeight + strokeWidth);
path.lineTo(rect.left + arrowPosition + (strokeWidth / 2), rect.top + arrowHeight + strokeWidth);
@@ -203,7 +206,7 @@ class Bubble extends Drawable {
path.close();
}
private void initTopRoundedPath(RectF rect, Path path, float strokeWidth) {
private void initTopRoundedPath(@NonNull RectF rect, @NonNull Path path, float strokeWidth) {
path.moveTo(rect.left + Math.min(arrowPosition, cornersRadius) + strokeWidth, rect.top + arrowHeight
+ strokeWidth);
path.lineTo(rect.left + arrowPosition + (strokeWidth / 2), rect.top + arrowHeight + strokeWidth);
@@ -231,7 +234,7 @@ class Bubble extends Drawable {
path.close();
}
private void initRightSquarePath(RectF rect, Path path, float strokeWidth) {
private void initRightSquarePath(@NonNull RectF rect, @NonNull Path path, float strokeWidth) {
path.moveTo(rect.left + strokeWidth, rect.top + strokeWidth);
path.lineTo(rect.width() - arrowWidth - strokeWidth, rect.top + strokeWidth);
@@ -247,7 +250,7 @@ class Bubble extends Drawable {
path.close();
}
private void initRightRoundedPath(RectF rect, Path path, float strokeWidth) {
private void initRightRoundedPath(@NonNull RectF rect, @NonNull Path path, float strokeWidth) {
path.moveTo(rect.left + cornersRadius + strokeWidth, rect.top + strokeWidth);
path.lineTo(rect.width() - cornersRadius - arrowWidth - strokeWidth, rect.top + strokeWidth);
path.arcTo(new RectF(rect.right - cornersRadius - arrowWidth,
@@ -270,7 +273,7 @@ class Bubble extends Drawable {
path.close();
}
private void initBottomSquarePath(RectF rect, Path path, float strokeWidth) {
private void initBottomSquarePath(@NonNull RectF rect, @NonNull Path path, float strokeWidth) {
path.moveTo(rect.left + strokeWidth, rect.top + strokeWidth);
path.lineTo(rect.right - strokeWidth, rect.top + strokeWidth);
path.lineTo(rect.right - strokeWidth, rect.bottom - arrowHeight - strokeWidth);
@@ -285,7 +288,7 @@ class Bubble extends Drawable {
path.close();
}
private void initBottomRoundedPath(RectF rect, Path path, float strokeWidth) {
private void initBottomRoundedPath(@NonNull RectF rect, @NonNull Path path, float strokeWidth) {
path.moveTo(rect.left + cornersRadius + strokeWidth, rect.top + strokeWidth);
path.lineTo(rect.width() - cornersRadius - strokeWidth, rect.top + strokeWidth);
path.arcTo(new RectF(rect.right - cornersRadius,

View File

@@ -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;
@@ -32,7 +33,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 +43,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 +54,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 +85,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,6 +112,7 @@ public class BubbleLayout extends LinearLayout {
* @param arrowDirection The direction of the arrow
* @return this
*/
@NonNull
public BubbleLayout setArrowDirection(ArrowDirection arrowDirection) {
resetPadding();
this.arrowDirection = arrowDirection;
@@ -133,6 +135,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 +158,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 +181,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 +204,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 +226,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 +248,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 +271,7 @@ public class BubbleLayout extends LinearLayout {
* @param strokeColor The stroke color
* @return this
*/
@NonNull
public BubbleLayout setStrokeColor(int strokeColor) {
this.strokeColor = strokeColor;
requestLayout();

View File

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

View File

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

View File

@@ -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;
@@ -53,11 +55,11 @@ public class InfoWindow {
initialize(view, mapboxMap);
}
InfoWindow(View view, MapboxMap mapboxMap) {
InfoWindow(@NonNull View view, MapboxMap mapboxMap) {
initialize(view, mapboxMap);
}
private void initialize(View view, MapboxMap mapboxMap) {
private void initialize(@NonNull View view, 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;
}

View File

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

View File

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

View File

@@ -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() + "]]";

View File

@@ -36,6 +36,7 @@ import java.util.Map;
@Deprecated
public class MarkerViewManager implements MapView.OnDidFinishRenderingFrameListener {
@NonNull
private final ViewGroup markerViewContainer;
private final ViewTreeObserver.OnPreDrawListener markerViewPreDrawObserver =
new ViewTreeObserver.OnPreDrawListener() {
@@ -56,6 +57,7 @@ public class MarkerViewManager implements MapView.OnDidFinishRenderingFrameListe
private boolean enabled;
private long updateTime;
@Nullable
private MapboxMap.OnMarkerViewClickListener onMarkerViewClickListener;
private boolean isWaitingForRenderInvoke;
@@ -330,7 +332,7 @@ public class MarkerViewManager implements MapView.OnDidFinishRenderingFrameListe
* @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.OnDidFinishRenderingFrameListe
* @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.OnDidFinishRenderingFrameListe
* @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.OnDidFinishRenderingFrameListe
*
* @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.OnDidFinishRenderingFrameListe
*
* @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.OnDidFinishRenderingFrameListe
*
* @return a List of MarkerViewAdapters.
*/
@NonNull
public List<MapboxMap.MarkerViewAdapter> getMarkerViewAdapters() {
return markerViewAdapters;
}
@@ -559,7 +562,7 @@ public class MarkerViewManager implements MapView.OnDidFinishRenderingFrameListe
* @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.OnDidFinishRenderingFrameListe
*
* @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,11 +623,13 @@ public class MarkerViewManager implements MapView.OnDidFinishRenderingFrameListe
}
}
@NonNull
public ViewGroup getMarkerViewContainer() {
return markerViewContainer;
}
public void addOnMarkerViewAddedListener(MarkerView markerView, OnMarkerViewAddedListener onMarkerViewAddedListener) {
public void addOnMarkerViewAddedListener(@NonNull MarkerView markerView,
OnMarkerViewAddedListener onMarkerViewAddedListener) {
markerViewAddedListenerMap.put(markerView.getId(), onMarkerViewAddedListener);
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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{"

View File

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

View File

@@ -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, @NonNull 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");

View File

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

View File

@@ -5,6 +5,7 @@ import android.graphics.PointF;
import android.support.annotation.IntDef;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.maps.MapboxMap;
@@ -217,7 +218,7 @@ public final class CameraUpdateFactory {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}
@@ -292,7 +293,7 @@ public final class CameraUpdateFactory {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}
@@ -362,7 +363,7 @@ public final class CameraUpdateFactory {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}
@@ -487,7 +488,7 @@ public final class CameraUpdateFactory {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}

View File

@@ -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 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);
}
@@ -204,6 +206,7 @@ public class LatLng implements Parcelable {
*
* @return new LatLng object with wrapped Longitude
*/
@NonNull
public LatLng wrap() {
return new LatLng(latitude, wrap(longitude, GeometryConstants.MIN_LONGITUDE, GeometryConstants.MAX_LONGITUDE));
}
@@ -241,7 +244,7 @@ public class LatLng implements 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;
}
@@ -278,6 +281,7 @@ public class LatLng implements Parcelable {
*
* @return the string representation
*/
@NonNull
@Override
public String toString() {
return "LatLng [latitude=" + latitude + ", longitude=" + longitude + ", altitude=" + altitude + "]";
@@ -300,7 +304,7 @@ public class LatLng 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(latitude);
out.writeDouble(longitude);
out.writeDouble(altitude);
@@ -312,7 +316,7 @@ public class LatLng implements 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;

View File

@@ -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 LatLng latLng) {
public boolean contains(@NonNull final LatLng 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;

View File

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

View File

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

View File

@@ -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 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);
}
@@ -88,7 +90,7 @@ public class ProjectedMeters implements 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;
}
@@ -123,6 +125,7 @@ public class ProjectedMeters implements Parcelable {
*
* @return the string representation of this
*/
@NonNull
@Override
public String toString() {
return "ProjectedMeters [northing=" + northing + ", easting=" + easting + "]";
@@ -145,7 +148,7 @@ public class ProjectedMeters 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(northing);
out.writeDouble(easting);
}

View File

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

View File

@@ -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 + "?";

View File

@@ -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;
InputStream input = null;
try {

View File

@@ -1,6 +1,7 @@
package com.mapbox.mapboxsdk.http;
import android.support.annotation.Keep;
import android.support.annotation.Nullable;
import com.mapbox.mapboxsdk.Mapbox;
import java.util.concurrent.locks.ReentrantLock;
@@ -60,7 +61,7 @@ public class NativeHttpRequest implements HttpResponder {
private void executeLocalRequest(String resourceUrl) {
new LocalRequestTask(new LocalRequestTask.OnLocalRequestResponse() {
@Override
public void onResponse(byte[] bytes) {
public void onResponse(@Nullable byte[] bytes) {
if (bytes != null) {
lock.lock();
if (nativePtr != 0) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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(

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -74,9 +74,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;
@@ -89,6 +92,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;
@@ -338,7 +342,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);
@@ -838,7 +842,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) {
@@ -909,6 +913,7 @@ public final class LocationComponent {
locationAnimatorCoordinator.feedNewAccuracyRadius(Utils.calculateZoomLevelRadius(mapboxMap, location), noAnimation);
}
@NonNull
private OnCameraMoveListener onCameraMoveListener = new OnCameraMoveListener() {
@Override
public void onCameraMove() {
@@ -916,6 +921,7 @@ public final class LocationComponent {
}
};
@NonNull
private OnCameraIdleListener onCameraIdleListener = new OnCameraIdleListener() {
@Override
public void onCameraIdle() {
@@ -923,6 +929,7 @@ public final class LocationComponent {
}
};
@NonNull
private OnMapClickListener onMapClickListener = new OnMapClickListener() {
@Override
public boolean onMapClick(@NonNull LatLng point) {
@@ -936,6 +943,7 @@ public final class LocationComponent {
}
};
@NonNull
private MapboxMap.OnMapLongClickListener onMapLongClickListener = new MapboxMap.OnMapLongClickListener() {
@Override
public boolean onMapLongClick(@NonNull LatLng point) {
@@ -949,6 +957,7 @@ public final class LocationComponent {
}
};
@NonNull
private OnLocationStaleListener onLocationStaleListener = new OnLocationStaleListener() {
@Override
public void onStaleStateChange(boolean isStale) {
@@ -960,6 +969,7 @@ public final class LocationComponent {
}
};
@NonNull
private OnCameraMoveInvalidateListener onCameraMoveInvalidateListener = new OnCameraMoveInvalidateListener() {
@Override
public void onInvalidateCameraMove() {
@@ -967,6 +977,7 @@ public final class LocationComponent {
}
};
@NonNull
private CompassListener compassListener = new CompassListener() {
@Override
public void onCompassChanged(float userHeading) {
@@ -979,6 +990,7 @@ public final class LocationComponent {
}
};
@NonNull
private LocationEngineListener locationEngineListener = new LocationEngineListener() {
@Override
@SuppressWarnings( {"MissingPermission"})
@@ -994,6 +1006,7 @@ public final class LocationComponent {
}
};
@NonNull
private OnCameraTrackingChangedListener cameraTrackingChangedListener = new OnCameraTrackingChangedListener() {
@Override
public void onCameraTrackingDismissed() {

View File

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

View File

@@ -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;
@@ -722,6 +738,7 @@ public class LocationComponentOptions implements Parcelable {
return trackingAnimationDurationMultiplier;
}
@NonNull
@Override
public String toString() {
return "LocationComponentOptions{"
@@ -931,7 +948,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());
@@ -1036,6 +1053,7 @@ public class LocationComponentOptions implements Parcelable {
*
* @return a new instance of {@link LocationComponentOptions}
*/
@NonNull
public LocationComponentOptions build() {
LocationComponentOptions locationComponentOptions = autoBuild();
if (locationComponentOptions.accuracyAlpha() < 0 || locationComponentOptions.accuracyAlpha() > 1) {
@@ -1054,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;
@@ -1130,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;
@@ -1142,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;
@@ -1154,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;
@@ -1171,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;
@@ -1183,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;
@@ -1200,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;
@@ -1212,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;
@@ -1229,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;
@@ -1241,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;
@@ -1258,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;
@@ -1270,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;
@@ -1287,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;
@@ -1299,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;
@@ -1316,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;
@@ -1328,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;
@@ -1340,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;
@@ -1352,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;
@@ -1364,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;
@@ -1376,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;
@@ -1388,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;
@@ -1401,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;
@@ -1416,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;
@@ -1435,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");
}
@@ -1450,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;
@@ -1460,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;
@@ -1474,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;
@@ -1488,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;
@@ -1507,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;
@@ -1517,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;
@@ -1528,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;
@@ -1538,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;
@@ -1548,12 +1609,14 @@ public class LocationComponentOptions implements Parcelable {
*
* @param trackingAnimationDurationMultiplier the tracking animation duration multiplier
*/
@NonNull
public LocationComponentOptions.Builder trackingAnimationDurationMultiplier(
float trackingAnimationDurationMultiplier) {
this.trackingAnimationDurationMultiplier = trackingAnimationDurationMultiplier;
return this;
}
@Nullable
LocationComponentOptions autoBuild() {
String missing = "";
if (this.accuracyAlpha == null) {

View File

@@ -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,

View File

@@ -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,

View File

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

View File

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

View File

@@ -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() {

View File

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

View File

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

View File

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

View File

@@ -27,6 +27,7 @@ class AnnotationContainer implements Annotations {
return annotations.get(id);
}
@NonNull
@Override
public List<Annotation> obtainAll() {
List<Annotation> annotations = new ArrayList<>();

View File

@@ -42,6 +42,7 @@ class AnnotationManager {
private static final long NO_ANNOTATION_ID = -1;
@Nullable
private final MapView mapView;
private final IconManager iconManager;
private final InfoWindowManager infoWindowManager = new InfoWindowManager();
@@ -50,8 +51,11 @@ class AnnotationManager {
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,7 +64,7 @@ class AnnotationManager {
private Polygons polygons;
private Polylines polylines;
AnnotationManager(MapView mapView, LongSparseArray<Annotation> annotationsArray,
AnnotationManager(@Nullable MapView mapView, LongSparseArray<Annotation> annotationsArray,
MarkerViewManager markerViewManager, IconManager iconManager, Annotations annotations,
Markers markers, Polygons polygons, Polylines polylines, ShapeAnnotations shapeAnnotations) {
this.mapView = mapView;
@@ -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,10 +338,12 @@ class AnnotationManager {
selectedMarkers.remove(marker);
}
@NonNull
List<Marker> getSelectedMarkers() {
return selectedMarkers;
}
@NonNull
InfoWindowManager getInfoWindowManager() {
return infoWindowManager;
}
@@ -345,7 +352,7 @@ class AnnotationManager {
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 +371,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 +385,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 +447,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 +467,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 +480,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 +508,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 +523,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 +532,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 +554,7 @@ class AnnotationManager {
hitTestMarker(markerHit, marker, hitRectMarker);
}
private void hitTestMarker(MarkerHit markerHit, Marker marker, RectF hitRectMarker) {
private void hitTestMarker(MarkerHit markerHit, @NonNull Marker marker, RectF hitRectMarker) {
if (hitRectMarker.contains(markerHit.getTapPointX(), markerHit.getTapPointY())) {
hitRectMarker.intersect(markerHit.tapRect);
if (isRectangleHighestSurfaceIntersection(hitRectMarker)) {

View File

@@ -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) {

View File

@@ -152,7 +152,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) {

View File

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

View File

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

View File

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

View File

@@ -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;
@@ -72,6 +73,7 @@ final class MapGestureDetector {
/**
* User-set focal point.
*/
@Nullable
private PointF focalPoint;
private AndroidGesturesManager gesturesManager;
@@ -85,9 +87,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;
@@ -106,7 +109,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();
@@ -128,7 +131,7 @@ final class MapGestureDetector {
}
}
private void initializeGesturesManager(AndroidGesturesManager androidGesturesManager,
private void initializeGesturesManager(@NonNull AndroidGesturesManager androidGesturesManager,
boolean setDefaultMutuallyExclusives) {
if (setDefaultMutuallyExclusives) {
Set<Integer> shoveScaleSet = new HashSet<>();
@@ -158,7 +161,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) {
@@ -193,7 +196,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;
@@ -244,7 +247,7 @@ final class MapGestureDetector {
dispatchCameraIdle();
}
private void cancelAnimator(Animator animator) {
private void cancelAnimator(@Nullable Animator animator) {
if (animator != null && animator.isStarted()) {
animator.cancel();
}
@@ -253,6 +256,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() {
@@ -427,7 +431,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;
}
@@ -439,7 +443,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
@@ -454,7 +458,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);
}
@@ -464,6 +468,7 @@ final class MapGestureDetector {
private final float minimumVelocity;
@Nullable
private PointF scaleFocalPoint;
private boolean quickZoom;
@@ -472,7 +477,7 @@ final class MapGestureDetector {
}
@Override
public boolean onScaleBegin(StandardScaleGestureDetector detector) {
public boolean onScaleBegin(@NonNull StandardScaleGestureDetector detector) {
if (!uiSettings.isZoomGesturesEnabled()) {
return false;
}
@@ -505,7 +510,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);
@@ -521,7 +526,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);
@@ -551,7 +556,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;
@@ -587,6 +592,7 @@ final class MapGestureDetector {
}
private final class RotateGestureListener extends RotateGestureDetector.SimpleOnRotateGestureListener {
@Nullable
private PointF rotateFocalPoint;
private final float minimumScaleSpanWhenRotating;
private final float minimumAngularVelocity;
@@ -600,7 +606,7 @@ final class MapGestureDetector {
}
@Override
public boolean onRotateBegin(RotateGestureDetector detector) {
public boolean onRotateBegin(@NonNull RotateGestureDetector detector) {
if (!uiSettings.isRotateGesturesEnabled()) {
return false;
}
@@ -625,7 +631,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);
@@ -644,7 +650,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);
@@ -673,7 +680,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;
@@ -689,7 +696,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,
@@ -723,7 +730,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;
}
@@ -741,7 +748,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);
@@ -759,7 +767,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
@@ -771,7 +779,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;
}
@@ -797,15 +805,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);
}
});
@@ -838,7 +846,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);
}
@@ -849,11 +857,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);
@@ -891,7 +899,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();
@@ -909,7 +917,7 @@ final class MapGestureDetector {
return mapZoom >= MapboxConstants.MINIMUM_ZOOM && mapZoom <= MapboxConstants.MAXIMUM_ZOOM;
}
void notifyOnMapClickListeners(PointF tapPoint) {
void notifyOnMapClickListeners(@NonNull PointF tapPoint) {
for (MapboxMap.OnMapClickListener listener : onMapClickListenerList) {
if (listener.onMapClick(projection.fromScreenLocation(tapPoint))) {
return;
@@ -917,7 +925,7 @@ final class MapGestureDetector {
}
}
void notifyOnMapLongClickListeners(PointF longClickPoint) {
void notifyOnMapLongClickListeners(@NonNull PointF longClickPoint) {
for (MapboxMap.OnMapLongClickListener listener : onMapLongClickListenerList) {
if (listener.onMapLongClick(projection.fromScreenLocation(longClickPoint))) {
return;
@@ -931,73 +939,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);
}
@@ -1063,8 +1071,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);
}

View File

@@ -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) {

View File

@@ -69,7 +69,9 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
private final MapCallback mapCallback = new MapCallback();
private final InitialRenderCallback initialRenderCallback = new InitialRenderCallback();
@Nullable
private NativeMapView nativeMapView;
@Nullable
private MapboxMap mapboxMap;
private MapboxMapOptions mapboxMapOptions;
private MapRenderer mapRenderer;
@@ -81,8 +83,11 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
private ImageView attrView;
private ImageView logoView;
@Nullable
private MapGestureDetector mapGestureDetector;
@Nullable
private MapKeyListener mapKeyListener;
@Nullable
private Bundle savedInstanceState;
@UiThread
@@ -211,7 +216,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
@@ -227,7 +232,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) {
@@ -438,7 +443,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);
}
@@ -448,17 +453,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);
}
@@ -517,7 +522,7 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
* @param definition the offline region definition
* @see OfflineRegionDefinition
*/
public void setOfflineRegionDefinition(OfflineRegionDefinition definition) {
public void setOfflineRegionDefinition(@NonNull OfflineRegionDefinition definition) {
double minZoom = definition.getMinZoom();
double maxZoom = definition.getMaxZoom();
@@ -564,6 +569,7 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
// ViewCallback
//
@Nullable
@Override
public Bitmap getViewContent() {
return BitmapUtils.createBitmapFromView(this);
@@ -973,6 +979,7 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
return mapGestureDetector != null;
}
@Nullable
MapboxMap getMapboxMap() {
return mapboxMap;
}
@@ -1240,10 +1247,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();
}

View File

@@ -78,6 +78,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,
@@ -681,7 +682,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);
}
@@ -698,7 +699,7 @@ public final class MapboxMap {
* Do not update or ease the camera from within onCancel().
* @see com.mapbox.mapboxsdk.camera.CameraUpdateFactory for a set of updates.
*/
public final void easeCamera(CameraUpdate update, @Nullable final MapboxMap.CancelableCallback callback) {
public final void easeCamera(@NonNull CameraUpdate update, @Nullable final MapboxMap.CancelableCallback callback) {
easeCamera(update, MapboxConstants.ANIMATION_DURATION, callback);
}
@@ -1074,7 +1075,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);
}
@@ -1090,7 +1091,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);
}
@@ -1769,7 +1770,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());
}
@@ -2556,6 +2557,7 @@ public final class MapboxMap {
private Context context;
private final Class<U> persistentClass;
@NonNull
private final Pools.SimplePool<View> viewReusePool;
/**
@@ -2639,6 +2641,7 @@ public final class MapboxMap {
*
* @return the pool associated to this adapter
*/
@NonNull
public final Pools.SimplePool<View> getViewReusePool() {
return viewReusePool;
}

View File

@@ -142,6 +142,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;
@@ -247,6 +248,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;
@@ -258,6 +260,7 @@ public class MapboxMapOptions implements Parcelable {
* @param cameraPosition Inital camera position
* @return This
*/
@NonNull
public MapboxMapOptions camera(CameraPosition cameraPosition) {
this.cameraPosition = cameraPosition;
return this;
@@ -269,6 +272,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;
@@ -280,6 +284,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;
@@ -291,6 +296,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;
@@ -302,6 +308,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;
@@ -313,6 +320,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;
@@ -324,6 +332,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;
@@ -335,6 +344,7 @@ public class MapboxMapOptions implements Parcelable {
* @param gravity Android SDK Gravity.
* @return This
*/
@NonNull
public MapboxMapOptions compassGravity(int gravity) {
compassGravity = gravity;
return this;
@@ -346,6 +356,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;
@@ -360,6 +371,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;
@@ -374,6 +386,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;
@@ -385,6 +398,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;
@@ -396,6 +410,7 @@ public class MapboxMapOptions implements Parcelable {
* @param gravity Android SDK Gravity.
* @return This
*/
@NonNull
public MapboxMapOptions logoGravity(int gravity) {
logoGravity = gravity;
return this;
@@ -407,6 +422,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;
@@ -418,6 +434,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;
@@ -429,6 +446,7 @@ public class MapboxMapOptions implements Parcelable {
* @param gravity Android SDK Gravity.
* @return This
*/
@NonNull
public MapboxMapOptions attributionGravity(int gravity) {
attributionGravity = gravity;
return this;
@@ -440,6 +458,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;
@@ -451,6 +470,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;
@@ -462,6 +482,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;
@@ -473,6 +494,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;
@@ -484,6 +506,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;
@@ -495,6 +518,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;
@@ -506,6 +530,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;
@@ -524,11 +549,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;
@@ -540,6 +567,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;
@@ -553,6 +581,7 @@ public class MapboxMapOptions implements Parcelable {
* @param enable true to enable
* @return This
*/
@NonNull
public MapboxMapOptions setPrefetchesTiles(boolean enable) {
this.prefetchesTiles = enable;
return this;
@@ -568,6 +597,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;
@@ -583,6 +613,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;
@@ -595,6 +626,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;
@@ -896,7 +928,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);
}
@@ -911,7 +943,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));
@@ -954,7 +986,7 @@ public class MapboxMapOptions implements Parcelable {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}

View File

@@ -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++) {

View File

@@ -25,6 +25,7 @@ interface Markers {
List<Marker> obtainAll();
@NonNull
List<Marker> obtainAllIn(@NonNull RectF rectangle);
MarkerView addViewBy(@NonNull BaseMarkerViewOptions markerOptions, @NonNull MapboxMap mapboxMap,

View File

@@ -55,9 +55,11 @@ final class NativeMapView {
private final MapRenderer mapRenderer;
// Used to validate if methods are called from the correct thread
@NonNull
private final Thread thread;
// Used for view callbacks
@Nullable
private ViewCallback viewCallback;
// Used for map change callbacks
@@ -84,8 +86,9 @@ final class NativeMapView {
// Constructors
//
public NativeMapView(final Context context, final boolean crossSourceCollisions, final ViewCallback viewCallback,
final StateCallback stateCallback, final MapRenderer mapRenderer) {
public NativeMapView(@NonNull 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);
}
@@ -239,14 +242,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;
}
@@ -312,7 +315,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;
}
@@ -437,7 +440,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[] {};
}
@@ -452,7 +456,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[] {};
}
@@ -467,14 +472,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;
}
@@ -483,14 +489,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;
}
@@ -512,6 +518,7 @@ final class NativeMapView {
nativeRemoveAnnotations(ids);
}
@NonNull
public long[] queryPointAnnotations(RectF rect) {
if (checkState("queryPointAnnotations")) {
return new long[] {};
@@ -519,6 +526,7 @@ final class NativeMapView {
return nativeQueryPointAnnotations(rect);
}
@NonNull
public long[] queryShapeAnnotations(RectF rectF) {
if (checkState("queryShapeAnnotations")) {
return new long[] {};
@@ -596,14 +604,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();
}
@@ -611,7 +619,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();
}
@@ -620,7 +629,7 @@ final class NativeMapView {
return pointF;
}
public LatLng latLngForPixel(PointF pixel) {
public LatLng latLngForPixel(@NonNull PointF pixel) {
if (checkState("latLngForPixel")) {
return new LatLng();
}
@@ -634,14 +643,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;
@@ -650,13 +659,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();
@@ -967,7 +977,7 @@ final class NativeMapView {
}
@Keep
protected void onSnapshotReady(Bitmap mapContent) {
protected void onSnapshotReady(@Nullable Bitmap mapContent) {
if (checkState("OnSnapshotReady")) {
return;
}
@@ -998,12 +1008,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();
@@ -1022,13 +1034,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);
@@ -1084,21 +1099,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);
@@ -1133,15 +1153,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);
@@ -1160,6 +1184,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();
@@ -1175,9 +1200,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);
@@ -1190,18 +1217,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);
@@ -1220,6 +1251,7 @@ final class NativeMapView {
@Keep
private native void nativeRemoveImage(String name);
@NonNull
@Keep
private native Bitmap nativeGetImage(String name);
@@ -1232,17 +1264,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();
@@ -1278,7 +1313,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() {
@@ -1316,6 +1351,7 @@ final class NativeMapView {
this.sdf = sdf;
}
@NonNull
@Override
protected List<Image> doInBackground(HashMap<String, Bitmap>... params) {
HashMap<String, Bitmap> bitmapHashMap = params[0];
@@ -1345,7 +1381,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()]));
@@ -1358,6 +1394,7 @@ final class NativeMapView {
int getHeight();
@Nullable
Bitmap getViewContent();
}

View File

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

View File

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

View File

@@ -21,6 +21,7 @@ import java.util.List;
*/
public class Projection {
@NonNull
private final NativeMapView nativeMapView;
private int[] contentPadding;

View File

@@ -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) {

View File

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

View File

@@ -30,7 +30,9 @@ final class Transform implements MapView.OnCameraDidChangeListener {
private final MarkerViewManager markerViewManager;
private final Handler handler = new Handler();
@Nullable
private CameraPosition cameraPosition;
@Nullable
private MapboxMap.CancelableCallback cameraCancelableCallback;
private CameraChangeDispatcher cameraChangeDispatcher;
@@ -66,6 +68,7 @@ final class Transform implements MapView.OnCameraDidChangeListener {
// Camera API
//
@Nullable
@UiThread
public final CameraPosition getCameraPosition() {
if (cameraPosition == null) {
@@ -100,7 +103,8 @@ final class Transform implements MapView.OnCameraDidChangeListener {
}
@UiThread
final void moveCamera(MapboxMap mapboxMap, CameraUpdate update, final MapboxMap.CancelableCallback callback) {
final void moveCamera(@NonNull MapboxMap mapboxMap, CameraUpdate update,
@Nullable final MapboxMap.CancelableCallback callback) {
CameraPosition cameraPosition = update.getCameraPosition(mapboxMap);
if (isValidCameraPosition(cameraPosition)) {
cancelTransitions();
@@ -120,8 +124,8 @@ final class Transform implements MapView.OnCameraDidChangeListener {
}
@UiThread
final void easeCamera(MapboxMap mapboxMap, CameraUpdate update, int durationMs, boolean easingInterpolator,
final MapboxMap.CancelableCallback callback) {
final void easeCamera(@NonNull MapboxMap mapboxMap, CameraUpdate update, int durationMs, boolean easingInterpolator,
@Nullable final MapboxMap.CancelableCallback callback) {
CameraPosition cameraPosition = update.getCameraPosition(mapboxMap);
if (isValidCameraPosition(cameraPosition)) {
cancelTransitions();
@@ -137,8 +141,8 @@ final class Transform implements MapView.OnCameraDidChangeListener {
}
@UiThread
final void animateCamera(MapboxMap mapboxMap, CameraUpdate update, int durationMs,
final MapboxMap.CancelableCallback callback) {
final void animateCamera(@NonNull MapboxMap mapboxMap, CameraUpdate update, int durationMs,
@Nullable final MapboxMap.CancelableCallback callback) {
CameraPosition cameraPosition = update.getCameraPosition(mapboxMap);
if (isValidCameraPosition(cameraPosition)) {
cancelTransitions();

View File

@@ -29,15 +29,20 @@ 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];
private AttributionDialogManager attributionDialogManager;
@NonNull
private final View logoView;
private final int[] logoMargins = new int[4];
@@ -62,6 +67,7 @@ public final class UiSettings {
private boolean deselectMarkersOnTap = true;
@Nullable
private PointF userProvidedFocalPoint;
UiSettings(@NonNull Projection projection, @NonNull FocalPointChangeListener listener,
@@ -83,7 +89,7 @@ public final class UiSettings {
initialiseAttribution(context, options);
}
void onSaveInstanceState(Bundle outState) {
void onSaveInstanceState(@NonNull Bundle outState) {
saveGestures(outState);
saveCompass(outState);
saveLogo(outState);
@@ -137,7 +143,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();
@@ -178,13 +184,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 {
@@ -212,7 +218,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());
@@ -221,7 +227,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]);
@@ -928,6 +934,7 @@ public final class UiSettings {
*
* @return The focal point
*/
@Nullable
public PointF getFocalPoint() {
return userProvidedFocalPoint;
}

View File

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

View File

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

View File

@@ -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,

View File

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

View File

@@ -3,6 +3,7 @@ package com.mapbox.mapboxsdk.maps.widgets;
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;
@@ -30,21 +31,22 @@ public final class CompassView extends AppCompatImageView 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);
}

View File

@@ -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

View File

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

View File

@@ -2,6 +2,7 @@ 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;
@@ -18,6 +19,7 @@ import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition;
public class TelemetryImpl implements TelemetryDefinition {
@Nullable
private MapboxTelemetry telemetry;
public TelemetryImpl() {

View File

@@ -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

View File

@@ -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
@@ -71,6 +74,7 @@ public class OfflineGeometryRegionDefinition implements OfflineRegionDefinition,
return styleURL;
}
@Nullable
public Geometry getGeometry() {
return geometry;
}
@@ -80,6 +84,7 @@ public class OfflineGeometryRegionDefinition implements OfflineRegionDefinition,
* to retain backwards compatibility
* @return the {@link LatLngBounds} or null
*/
@Nullable
@Override
public LatLngBounds getBounds() {
if (geometry == null) {
@@ -105,6 +110,7 @@ public class OfflineGeometryRegionDefinition implements OfflineRegionDefinition,
return pixelRatio;
}
@NonNull
@Override
public String getType() {
return "shaperegion";
@@ -120,7 +126,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);
@@ -129,7 +135,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);
}

View File

@@ -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),

View File

@@ -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;
@@ -93,6 +94,7 @@ public class OfflineTilePyramidRegionDefinition implements OfflineRegionDefiniti
return pixelRatio;
}
@NonNull
@Override
public String getType() {
return "tileregion";
@@ -108,7 +110,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());
@@ -120,7 +122,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);
}

View File

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

View File

@@ -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,23 @@ 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, AttributionLayout layout) {
// draw attribution
PointF anchorPoint = layout.getAnchorPoint();
if (anchorPoint != null) {
@@ -373,7 +386,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 +413,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 +472,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() {

View File

@@ -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 isExternalStorageConfiguration = MapboxConstants.DEFAULT_SET_STORAGE_EXTERNAL;
@@ -162,6 +165,7 @@ public class FileSource {
unlockPathLoaders();
}
@NonNull
@Override
protected String[] doInBackground(Context... contexts) {
return new String[] {
@@ -184,7 +188,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) {
@@ -202,7 +207,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) {
@@ -243,6 +248,7 @@ public class FileSource {
@Keep
public native void setAccessToken(@NonNull String accessToken);
@NonNull
@Keep
public native String getAccessToken();

View File

@@ -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));
}
@@ -2906,7 +2908,7 @@ public class 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));
}
@@ -3617,7 +3619,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));
}
@@ -3844,7 +3846,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));
}
@@ -4051,6 +4053,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);
@@ -4132,7 +4135,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;
@@ -4232,7 +4235,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;
}
@@ -4260,6 +4263,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) == '\"') {
@@ -4312,6 +4316,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;
@@ -4555,6 +4560,7 @@ public class Expression {
*
* @return the string representation of the expression array
*/
@NonNull
@Override
public String toString() {
Object[] array = (Object[]) literal;
@@ -4576,7 +4582,7 @@ public class Expression {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}
@@ -4600,6 +4606,7 @@ public class Expression {
this.map = map;
}
@NonNull
@Override
public Object toValue() {
Map<String, Object> unwrappedMap = new HashMap<>();
@@ -4615,6 +4622,7 @@ public class Expression {
return unwrappedMap;
}
@NonNull
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
@@ -4634,7 +4642,7 @@ public class Expression {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}
@@ -4669,6 +4677,7 @@ public class Expression {
* @param object the object to convert to an object array
* @return the converted object array
*/
@NonNull
private static Object[] toObjectArray(Object object) {
// object is a primitive array
int len = java.lang.reflect.Array.getLength(object);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

Some files were not shown because too many files have changed in this diff Show More