diff --git a/core/src/main/java/com/mapzen/android/core/ApiKeyChangeListener.java b/core/src/main/java/com/mapzen/android/core/ApiKeyChangeListener.java index c39d20d2..12a478b6 100644 --- a/core/src/main/java/com/mapzen/android/core/ApiKeyChangeListener.java +++ b/core/src/main/java/com/mapzen/android/core/ApiKeyChangeListener.java @@ -1,5 +1,7 @@ package com.mapzen.android.core; +import android.support.annotation.NonNull; + /** * Listener for handling changes to API key. */ @@ -8,5 +10,5 @@ public interface ApiKeyChangeListener { * Called when the {@link MapzenManager}'s API key is changed. * @param apiKey the current API key */ - void onApiKeyChanged(String apiKey); + void onApiKeyChanged(@NonNull String apiKey); } diff --git a/core/src/main/java/com/mapzen/android/core/GenericHttpHandler.java b/core/src/main/java/com/mapzen/android/core/GenericHttpHandler.java index 60eb12f8..58f1f600 100644 --- a/core/src/main/java/com/mapzen/android/core/GenericHttpHandler.java +++ b/core/src/main/java/com/mapzen/android/core/GenericHttpHandler.java @@ -1,6 +1,7 @@ package com.mapzen.android.core; import android.os.Build; +import android.support.annotation.Nullable; import java.util.Map; @@ -75,11 +76,11 @@ enum LogLevel { * Return query parameters to be appended to every request. * @return */ - Map queryParamsForRequest(); + @Nullable Map queryParamsForRequest(); /** * Return headers to be added to every request. * @return */ - Map headersForRequest(); + @Nullable Map headersForRequest(); } diff --git a/core/src/main/java/com/mapzen/android/core/MapzenManager.java b/core/src/main/java/com/mapzen/android/core/MapzenManager.java index edbb8ecb..e01d5864 100644 --- a/core/src/main/java/com/mapzen/android/core/MapzenManager.java +++ b/core/src/main/java/com/mapzen/android/core/MapzenManager.java @@ -4,6 +4,7 @@ import android.content.Context; import android.content.res.Resources; +import android.support.annotation.NonNull; import java.util.ArrayList; import java.util.Collections; @@ -42,7 +43,7 @@ public class MapzenManager { /** * Get singleton instance. */ - public static MapzenManager instance(Context context) { + public static @NonNull MapzenManager instance(@NonNull Context context) { if (instance == null) { instance = new MapzenManager(context.getApplicationContext()); } @@ -55,7 +56,7 @@ public static MapzenManager instance(Context context) { /** * Creates a new instance of the manager. */ - private MapzenManager(Context context) { + private MapzenManager(@NonNull Context context) { final Resources resources = context.getResources(); if (resources != null) { int id = resources.getIdentifier(API_KEY_RES_NAME, API_KEY_RES_TYPE, @@ -72,7 +73,7 @@ private MapzenManager(Context context) { * @throws IllegalStateException if a valid API key has not been set in code or as a string * resource. */ - public String getApiKey() { + public @NonNull String getApiKey() { if (apiKey == null || API_KEY_DEFAULT_VALUE.equals(apiKey)) { throw new IllegalStateException("A valid Mapzen API key has not been provided. Please visit " + "https://mapzen.com/documentation/android/getting-started/ to learn how."); @@ -84,7 +85,7 @@ public String getApiKey() { /** * Sets a new API key value. This will override any previous key including those declared in xml. */ - public void setApiKey(String apiKey) { + public void setApiKey(@NonNull String apiKey) { this.apiKey = apiKey; notifyListeners(); } @@ -93,7 +94,7 @@ public void setApiKey(String apiKey) { * Returns the maven artifact version. * @return */ - public static String getSdkVersion() { + public static @NonNull String getSdkVersion() { return BuildConfig.SDK_VERSION; } @@ -102,7 +103,7 @@ public static String getSdkVersion() { * occur. * @param listener */ - public void addApiKeyChangeListener(ApiKeyChangeListener listener) { + public void addApiKeyChangeListener(@NonNull ApiKeyChangeListener listener) { Collections.synchronizedList(listeners).add(listener); } @@ -110,7 +111,7 @@ public void addApiKeyChangeListener(ApiKeyChangeListener listener) { * Removes listener from list of managed callbacks. * @param listener */ - public void removeApiKeyChangeListener(ApiKeyChangeListener listener) { + public void removeApiKeyChangeListener(@NonNull ApiKeyChangeListener listener) { Collections.synchronizedList(listeners).remove(listener); } diff --git a/core/src/main/java/com/mapzen/android/graphics/DataLayerType.java b/core/src/main/java/com/mapzen/android/graphics/DataLayerType.java index 12e8eab4..64fcba6c 100644 --- a/core/src/main/java/com/mapzen/android/graphics/DataLayerType.java +++ b/core/src/main/java/com/mapzen/android/graphics/DataLayerType.java @@ -1,5 +1,7 @@ package com.mapzen.android.graphics; +import android.support.annotation.NonNull; + /** * Default data layers for bundled Mapzen stylesheets including Bubble Wrap, Cinnabar, and Refill. * Used to add client data layers to the map and optionally persist them on configuration change. @@ -32,7 +34,7 @@ public enum DataLayerType { * Returns the enum's name. * @return */ - public String toString() { + @NonNull public String toString() { return name; } } diff --git a/core/src/main/java/com/mapzen/android/graphics/FeaturePickListener.java b/core/src/main/java/com/mapzen/android/graphics/FeaturePickListener.java index ba8bc686..89465a00 100644 --- a/core/src/main/java/com/mapzen/android/graphics/FeaturePickListener.java +++ b/core/src/main/java/com/mapzen/android/graphics/FeaturePickListener.java @@ -1,5 +1,7 @@ package com.mapzen.android.graphics; +import android.support.annotation.NonNull; + import java.util.Map; /** @@ -22,5 +24,5 @@ public interface FeaturePickListener { * @param positionX The horizontal screen coordinate of the center of the feature * @param positionY The vertical screen coordinate of the center of the feature */ - void onFeaturePick(Map properties, float positionX, float positionY); + void onFeaturePick(@NonNull Map properties, float positionX, float positionY); } diff --git a/core/src/main/java/com/mapzen/android/graphics/LabelPickListener.java b/core/src/main/java/com/mapzen/android/graphics/LabelPickListener.java index 20c6cb01..c65d3bd0 100644 --- a/core/src/main/java/com/mapzen/android/graphics/LabelPickListener.java +++ b/core/src/main/java/com/mapzen/android/graphics/LabelPickListener.java @@ -2,6 +2,8 @@ import com.mapzen.tangram.LabelPickResult; +import android.support.annotation.NonNull; + /** * Listener invoked when a label on the map is selected. */ @@ -27,5 +29,5 @@ public interface LabelPickListener { * @param positionY The vertical screen coordinate of the center of the feature. Will be 0 if * {@link LabelPickResult} is null. */ - void onLabelPicked(LabelPickResult result, float positionX, float positionY); + void onLabelPicked(@NonNull LabelPickResult result, float positionX, float positionY); } diff --git a/core/src/main/java/com/mapzen/android/graphics/MapView.java b/core/src/main/java/com/mapzen/android/graphics/MapView.java index 8fbb4e6e..34e61c4e 100644 --- a/core/src/main/java/com/mapzen/android/graphics/MapView.java +++ b/core/src/main/java/com/mapzen/android/graphics/MapView.java @@ -106,7 +106,7 @@ private void initViews(Context context) { /** * Get the underlying Tangram map object. */ - public TangramMapView getTangramMapView() { + @NonNull public TangramMapView getTangramMapView() { return tangramMapView; } @@ -127,7 +127,7 @@ public void getMapAsync(@NonNull OnMapReadyCallback callback) { * @param mapStyle mapStyle that should be set. * @param callback listener to be invoked when map is initialized and ready to use. */ - public void getMapAsync(MapStyle mapStyle, @NonNull OnMapReadyCallback callback) { + public void getMapAsync(@NonNull MapStyle mapStyle, @NonNull OnMapReadyCallback callback) { mapInitializer.init(this, mapStyle, callback); } @@ -139,21 +139,22 @@ public void getMapAsync(MapStyle mapStyle, @NonNull OnMapReadyCallback callback) * @param locale used to determine language that should be used for map labels. * @param callback listener to be invoked when map is initialized and ready to use. */ - public void getMapAsync(MapStyle mapStyle, Locale locale, @NonNull OnMapReadyCallback callback) { + public void getMapAsync(@NonNull MapStyle mapStyle, @NonNull Locale locale, + @NonNull OnMapReadyCallback callback) { mapInitializer.init(this, mapStyle, locale, callback); } /** * Get the compass button. */ - public CompassView getCompass() { + @NonNull public CompassView getCompass() { return compass; } /** * Show compass button. */ - public CompassView showCompass() { + @NonNull public CompassView showCompass() { compass.setVisibility(View.VISIBLE); return compass; } @@ -168,14 +169,14 @@ public void hideCompass() { /** * Get the find me button. */ - public ImageButton getFindMe() { + @NonNull public ImageButton getFindMe() { return findMe; } /** * Show button for finding user's location on map. */ - public ImageButton showFindMe() { + @NonNull public ImageButton showFindMe() { findMe.setVisibility(View.VISIBLE); return findMe; } @@ -190,14 +191,14 @@ public void hideFindMe() { /** * Get the zoom in button. */ - public ImageButton getZoomIn() { + @NonNull public ImageButton getZoomIn() { return zoomIn; } /** * Show button for zooming in. */ - public ImageButton showZoomIn() { + @NonNull public ImageButton showZoomIn() { zoomIn.setVisibility(View.VISIBLE); return zoomIn; } @@ -212,14 +213,14 @@ public void hideZoomIn() { /** * Get the zoom out button. */ - public ImageButton getZoomOut() { + @NonNull public ImageButton getZoomOut() { return zoomOut; } /** * Show button for zooming out. */ - public ImageButton showZoomOut() { + @NonNull public ImageButton showZoomOut() { zoomOut.setVisibility(View.VISIBLE); return zoomOut; } @@ -234,7 +235,7 @@ public void hideZoomOut() { /** * Return the attribution text view. */ - public TextView getAttribution() { + @NonNull public TextView getAttribution() { return attribution; } @@ -250,7 +251,7 @@ public void onDestroy() { getTangramMapView().onDestroy(); } - void setMapzenMap(MapzenMap mapzenMap) { + void setMapzenMap(@NonNull MapzenMap mapzenMap) { this.mapzenMap = mapzenMap; } } diff --git a/core/src/main/java/com/mapzen/android/graphics/MapzenMap.java b/core/src/main/java/com/mapzen/android/graphics/MapzenMap.java index 96410862..59faeb5f 100644 --- a/core/src/main/java/com/mapzen/android/graphics/MapzenMap.java +++ b/core/src/main/java/com/mapzen/android/graphics/MapzenMap.java @@ -199,21 +199,21 @@ public boolean onRotate(float x, float y, float rotation) { /** * Provides access to the underlying Tangram {@link MapController}. */ - public MapController getMapController() { + @NonNull public MapController getMapController() { return mapController; } /** * Provides access to the underlying {@link OverlayManager}. */ - public OverlayManager getOverlayManager() { + @NonNull public OverlayManager getOverlayManager() { return overlayManager; } /** * Sets the map's underlying stylesheet asynchronously. */ - public void setStyleAsync(MapStyle mapStyle, OnStyleLoadedListener listener) { + public void setStyleAsync(@NonNull MapStyle mapStyle, @NonNull OnStyleLoadedListener listener) { styleLoadedListener = listener; currSceneId = internalSetStyle(mapStyle, true); } @@ -221,7 +221,7 @@ public void setStyleAsync(MapStyle mapStyle, OnStyleLoadedListener listener) { /** * Sets the map's underlying stylesheet. */ - public void setStyle(MapStyle mapStyle) { + public void setStyle(@NonNull MapStyle mapStyle) { internalSetStyle(mapStyle, false); } @@ -232,8 +232,8 @@ public void setStyle(MapStyle mapStyle) { * @param themedMapStyle * @param labelLevel */ - public void setStyleAndLabelLevelAsync(ThemedMapStyle themedMapStyle, int labelLevel, - OnStyleLoadedListener listener) { + public void setStyleAndLabelLevelAsync(@NonNull ThemedMapStyle themedMapStyle, int labelLevel, + @NonNull OnStyleLoadedListener listener) { setStyleLabelLevelLodThemeColorAsync(themedMapStyle, labelLevel, themedMapStyle.getDefaultLod(), themedMapStyle.getDefaultColor(), listener); } @@ -245,7 +245,7 @@ public void setStyleAndLabelLevelAsync(ThemedMapStyle themedMapStyle, int labelL * @param themedMapStyle * @param labelLevel */ - public void setStyleAndLabelLevel(ThemedMapStyle themedMapStyle, int labelLevel) { + public void setStyleAndLabelLevel(@NonNull ThemedMapStyle themedMapStyle, int labelLevel) { setStyleLabelLevelLodThemeColor(themedMapStyle, labelLevel, themedMapStyle.getDefaultLod(), themedMapStyle.getDefaultColor()); } @@ -257,8 +257,8 @@ public void setStyleAndLabelLevel(ThemedMapStyle themedMapStyle, int labelLevel) * @param themedMapStyle * @param detailLevel */ - public void setStyleAndLodAsync(ThemedMapStyle themedMapStyle, int detailLevel, - OnStyleLoadedListener listener) { + public void setStyleAndLodAsync(@NonNull ThemedMapStyle themedMapStyle, int detailLevel, + @NonNull OnStyleLoadedListener listener) { setStyleLabelLevelLodThemeColorAsync(themedMapStyle, themedMapStyle.getDefaultLabelLevel(), detailLevel, themedMapStyle.getDefaultColor(), listener); } @@ -270,7 +270,7 @@ public void setStyleAndLodAsync(ThemedMapStyle themedMapStyle, int detailLevel, * @param themedMapStyle * @param detailLevel */ - public void setStyleAndLod(ThemedMapStyle themedMapStyle, int detailLevel) { + public void setStyleAndLod(@NonNull ThemedMapStyle themedMapStyle, int detailLevel) { setStyleLabelLevelLodThemeColor(themedMapStyle, themedMapStyle.getDefaultLabelLevel(), detailLevel, themedMapStyle.getDefaultColor()); } @@ -280,8 +280,8 @@ public void setStyleAndLod(ThemedMapStyle themedMapStyle, int detailLevel) { * @param themedMapStyle * @param color */ - public void setStyleAndThemeColorAsync(ThemedMapStyle themedMapStyle, ThemeColor color, - OnStyleLoadedListener listener) { + public void setStyleAndThemeColorAsync(@NonNull ThemedMapStyle themedMapStyle, + @NonNull ThemeColor color, @NonNull OnStyleLoadedListener listener) { setStyleLabelLevelLodThemeColorAsync(themedMapStyle, themedMapStyle.getDefaultLabelLevel(), themedMapStyle.getDefaultLod(), color, listener); } @@ -291,7 +291,8 @@ public void setStyleAndThemeColorAsync(ThemedMapStyle themedMapStyle, ThemeColor * @param themedMapStyle * @param color */ - public void setStyleAndThemeColor(ThemedMapStyle themedMapStyle, ThemeColor color) { + public void setStyleAndThemeColor(@NonNull ThemedMapStyle themedMapStyle, + @NonNull ThemeColor color) { setStyleLabelLevelLodThemeColor(themedMapStyle, themedMapStyle.getDefaultLabelLevel(), themedMapStyle.getDefaultLod(), color); } @@ -304,8 +305,9 @@ public void setStyleAndThemeColor(ThemedMapStyle themedMapStyle, ThemeColor colo * @param detailLevel * @param color */ - public void setStyleLabelLevelLodThemeColorAsync(ThemedMapStyle themedMapStyle, int labelLevel, - int detailLevel, ThemeColor color, OnStyleLoadedListener listener) { + public void setStyleLabelLevelLodThemeColorAsync(@NonNull ThemedMapStyle themedMapStyle, + int labelLevel, int detailLevel, @NonNull ThemeColor color, + @NonNull OnStyleLoadedListener listener) { styleLoadedListener = listener; mapStateManager.setMapStyle(themedMapStyle); currSceneId = setLabelLevelLodThemeColor(labelLevel, detailLevel, color, true); @@ -319,8 +321,8 @@ public void setStyleLabelLevelLodThemeColorAsync(ThemedMapStyle themedMapStyle, * @param detailLevel * @param color */ - public void setStyleLabelLevelLodThemeColor(ThemedMapStyle themedMapStyle, int labelLevel, - int detailLevel, ThemeColor color) { + public void setStyleLabelLevelLodThemeColor(@NonNull ThemedMapStyle themedMapStyle, + int labelLevel, int detailLevel, @NonNull ThemeColor color) { mapStateManager.setMapStyle(themedMapStyle); setLabelLevelLodThemeColor(labelLevel, detailLevel, color, false); } @@ -350,7 +352,7 @@ public void setZoom(float zoom, int duration) { * @param duration animation duration in millis * @param easeType map ease type */ - public void setZoom(float zoom, int duration, EaseType easeType) { + public void setZoom(float zoom, int duration, @NonNull EaseType easeType) { mapStateManager.setZoom(zoom); mapController.setZoomEased(zoom, duration, EASE_TYPE_TO_MAP_CONTROLLER_EASE_TYPE.get(easeType)); } @@ -365,7 +367,7 @@ public float getZoom() { /** * Set map position without animation. */ - public void setPosition(LngLat lngLat) { + public void setPosition(@NonNull LngLat lngLat) { mapStateManager.setPosition(lngLat); mapController.setPosition(lngLat); } @@ -376,7 +378,7 @@ public void setPosition(LngLat lngLat) { * @param lngLat position to center map on * @param duration animation duration in millis */ - public void setPosition(LngLat lngLat, int duration) { + public void setPosition(@NonNull LngLat lngLat, int duration) { setPosition(lngLat, duration, EaseType.CUBIC); } @@ -387,7 +389,7 @@ public void setPosition(LngLat lngLat, int duration) { * @param duration animation duration in millis * @param easeType map ease type */ - public void setPosition(LngLat lngLat, int duration, EaseType easeType) { + public void setPosition(@NonNull LngLat lngLat, int duration, @NonNull EaseType easeType) { mapStateManager.setPosition(lngLat); mapController.setPositionEased(lngLat, duration, EASE_TYPE_TO_MAP_CONTROLLER_EASE_TYPE.get(easeType)); @@ -396,7 +398,7 @@ public void setPosition(LngLat lngLat, int duration, EaseType easeType) { /** * Returns map position. */ - public LngLat getPosition() { + @NonNull public LngLat getPosition() { return mapController.getPosition(); } @@ -428,7 +430,7 @@ public void setRotation(float radians, int duration) { * @param duration animation duration in millis * @param easeType map ease type */ - public void setRotation(float radians, int duration, EaseType easeType) { + public void setRotation(float radians, int duration, @NonNull EaseType easeType) { mapStateManager.setRotation(radians); mapController.setRotationEased(radians, duration, EASE_TYPE_TO_MAP_CONTROLLER_EASE_TYPE.get(easeType)); @@ -476,7 +478,7 @@ public void setTilt(float radians, int duration) { * @param duration duration in millis * @param easeType map ease type */ - public void setTilt(float radians, int duration, EaseType easeType) { + public void setTilt(float radians, int duration, @NonNull EaseType easeType) { mapStateManager.setTilt(radians); mapController.setTiltEased(radians, duration, EASE_TYPE_TO_MAP_CONTROLLER_EASE_TYPE.get(easeType)); @@ -493,7 +495,7 @@ public float getTilt() { * Set the camera type for the map view. * @param type A {@code CameraType} */ - public void setCameraType(CameraType type) { + public void setCameraType(@NonNull CameraType type) { mapStateManager.setCameraType(type); mapController.setCameraType(CAMERA_TYPE_TO_MAP_CONTROLLER_CAMERA_TYPE.get(type)); } @@ -502,7 +504,7 @@ public void setCameraType(CameraType type) { * Get the camera type currently in use for the map view. * @return A {@code CameraType} */ - public CameraType getCameraType() { + @NonNull public CameraType getCameraType() { return MAP_CONTROLLER_CAMERA_TYPE_TO_CAMERA_TYPE.get(mapController.getCameraType()); } @@ -529,35 +531,35 @@ public boolean isMyLocationEnabled() { /** * Set an external click listener to be invoked after the internal listener. */ - public void setCompassOnClickListener(View.OnClickListener listener) { + public void setCompassOnClickListener(@Nullable View.OnClickListener listener) { overlayManager.setCompassOnClickListener(listener); } /** * Set an external click listener to be invoked after the internal listener. */ - public void setFindMeOnClickListener(View.OnClickListener listener) { + public void setFindMeOnClickListener(@Nullable View.OnClickListener listener) { overlayManager.setFindMeOnClickListener(listener); } /** * Set an external click listener to be invoked after the internal listener. */ - public void setZoomInOnClickListener(View.OnClickListener listener) { + public void setZoomInOnClickListener(@Nullable View.OnClickListener listener) { overlayManager.setZoomInOnClickListener(listener); } /** * Set an external click listener to be invoked after the internal listener. */ - public void setZoomOutOnClickListener(View.OnClickListener listener) { + public void setZoomOutOnClickListener(@Nullable View.OnClickListener listener) { overlayManager.setZoomOutOnClickListener(listener); } /** * Adds marker overlay to map. Returned {@link MapData} should be removed from map */ - public MapData addMarker(Marker marker) { + @NonNull public MapData addMarker(@NonNull Marker marker) { return overlayManager.addMarker(marker); } @@ -571,7 +573,7 @@ public void removeMarker() { /** * Adds polyline overlay to map. */ - public MapData addPolyline(Polyline polyline) { + @NonNull public MapData addPolyline(@NonNull Polyline polyline) { return overlayManager.addPolyline(polyline); } @@ -585,7 +587,7 @@ public void removePolyline() { /** * Adds polygon overlay to map. */ - public MapData addPolygon(Polygon polygon) { + @NonNull public MapData addPolygon(@NonNull Polygon polygon) { return overlayManager.addPolygon(polygon); } @@ -602,7 +604,7 @@ public void removePolygon() { * @param position Pixels from the top-left edge of the screen * @return LngLat corresponding to the given point */ - public LngLat screenPositionToLngLat(PointF position) { + @NonNull public LngLat screenPositionToLngLat(@NonNull PointF position) { return mapController.screenPositionToLngLat(position); } @@ -612,14 +614,14 @@ public LngLat screenPositionToLngLat(PointF position) { * @return Position in pixels from the top-left corner of the map area (the point * may not lie within the viewable screen area) */ - public PointF lngLatToScreenPosition(LngLat lngLat) { + @NonNull public PointF lngLatToScreenPosition(@NonNull LngLat lngLat) { return mapController.lngLatToScreenPosition(lngLat); } /** * Set tap responder for tap gestures on map. */ - public void setTapResponder(final TouchInput.TapResponder tapResponder) { + public void setTapResponder(@Nullable TouchInput.TapResponder tapResponder) { this.tapResponder = tapResponder; mapController.setTapResponder(internalTapResponder); } @@ -627,14 +629,14 @@ public void setTapResponder(final TouchInput.TapResponder tapResponder) { /** * Get the map's tap responder. */ - public TouchInput.TapResponder getTapResponder() { + @Nullable public TouchInput.TapResponder getTapResponder() { return tapResponder; } /** * Set double tap responder for tap gestures on map. */ - public void setDoubleTapResponder(TouchInput.DoubleTapResponder doubleTapResponder) { + public void setDoubleTapResponder(@Nullable TouchInput.DoubleTapResponder doubleTapResponder) { this.doubleTapResponder = doubleTapResponder; mapController.setDoubleTapResponder(this.doubleTapResponder); } @@ -642,14 +644,14 @@ public void setDoubleTapResponder(TouchInput.DoubleTapResponder doubleTapRespond /** * Get the map's double tap responder. */ - public TouchInput.DoubleTapResponder getDoubleTapResponder() { + @Nullable public TouchInput.DoubleTapResponder getDoubleTapResponder() { return doubleTapResponder; } /** * Set long press responder for tap gestures on map. */ - public void setLongPressResponder(TouchInput.LongPressResponder longPressResponder) { + public void setLongPressResponder(@Nullable TouchInput.LongPressResponder longPressResponder) { this.longPressResponder = longPressResponder; mapController.setLongPressResponder(this.longPressResponder); } @@ -657,42 +659,42 @@ public void setLongPressResponder(TouchInput.LongPressResponder longPressRespond /** * Get the map's long press responder. */ - public TouchInput.LongPressResponder getLongPressResponder() { + @Nullable public TouchInput.LongPressResponder getLongPressResponder() { return longPressResponder; } /** * Set pan responder for tap gestures on map. */ - public void setPanResponder(TouchInput.PanResponder panResponder) { + public void setPanResponder(@Nullable TouchInput.PanResponder panResponder) { this.panResponder = panResponder; } /** * Get the map's pan responder. */ - public TouchInput.PanResponder getPanResponder() { + @Nullable public TouchInput.PanResponder getPanResponder() { return panResponder; } /** * Set rotate responder for tap gestures on map. */ - public void setRotateResponder(TouchInput.RotateResponder rotateResponder) { + public void setRotateResponder(@Nullable TouchInput.RotateResponder rotateResponder) { this.rotateResponder = rotateResponder; } /** * Get the map's rotate responder. */ - public TouchInput.RotateResponder getRotateResponder() { + @Nullable public TouchInput.RotateResponder getRotateResponder() { return rotateResponder; } /** * Set scale responder for tap gestures on map. */ - public void setScaleResponder(TouchInput.ScaleResponder scaleResponder) { + public void setScaleResponder(@Nullable TouchInput.ScaleResponder scaleResponder) { this.scaleResponder = scaleResponder; mapController.setScaleResponder(scaleResponder); } @@ -700,14 +702,14 @@ public void setScaleResponder(TouchInput.ScaleResponder scaleResponder) { /** * Get the map's scale responder. */ - public TouchInput.ScaleResponder getScaleResponder() { + @Nullable public TouchInput.ScaleResponder getScaleResponder() { return scaleResponder; } /** * Set shove responder for tap gestures on map. */ - public void setShoveResponder(TouchInput.ShoveResponder shoveResponder) { + public void setShoveResponder(@Nullable TouchInput.ShoveResponder shoveResponder) { this.shoveResponder = shoveResponder; mapController.setShoveResponder(this.shoveResponder); } @@ -715,7 +717,7 @@ public void setShoveResponder(TouchInput.ShoveResponder shoveResponder) { /** * Get the map's shove responder. */ - public TouchInput.ShoveResponder getShoveResponder() { + @Nullable public TouchInput.ShoveResponder getShoveResponder() { return shoveResponder; } @@ -726,8 +728,8 @@ public TouchInput.ShoveResponder getShoveResponder() { * @param second Subsequent gesture type * @param allowed True if {@code second} should be recognized, else false */ - public void setSimultaneousGestureAllowed(TouchInput.Gestures first, TouchInput.Gestures second, - boolean allowed) { + public void setSimultaneousGestureAllowed(@NonNull TouchInput.Gestures first, + @NonNull TouchInput.Gestures second, boolean allowed) { mapController.setSimultaneousGestureAllowed(first, second, allowed); } @@ -738,8 +740,8 @@ public void setSimultaneousGestureAllowed(TouchInput.Gestures first, TouchInput. * @param second Subsequent gesture type * @return True if {@code second} will be recognized, else false */ - public boolean isSimultaneousGestureAllowed(TouchInput.Gestures first, - TouchInput.Gestures second) { + public boolean isSimultaneousGestureAllowed(@NonNull TouchInput.Gestures first, + @NonNull TouchInput.Gestures second) { return mapController.isSimultaneousGestureAllowed(first, second); } @@ -748,7 +750,7 @@ public boolean isSimultaneousGestureAllowed(TouchInput.Gestures first, * * @param listener Listener to call when {@link Marker}s are selected. */ - public void setFeaturePickListener(final FeaturePickListener listener) { + public void setFeaturePickListener(@Nullable final FeaturePickListener listener) { mapController.setFeaturePickListener(new MapController.FeaturePickListener() { @Override public void onFeaturePick(final Map properties, final float positionX, final float positionY) { @@ -764,7 +766,7 @@ public void setFeaturePickListener(final FeaturePickListener listener) { * * @param listener Listener to receive callback when labels are selected. */ - public void setLabelPickListener(final LabelPickListener listener) { + public void setLabelPickListener(@Nullable final LabelPickListener listener) { labelPickHandler.setListener(listener); mapController.setLabelPickListener(labelPickHandler); pickLabelOnSingleTapConfirmed = (listener != null); @@ -776,7 +778,7 @@ public void setLabelPickListener(final LabelPickListener listener) { * * @param listener Listener to receive callback when {@link BitmapMarker}s are selected. */ - public void setMarkerPickListener(final MarkerPickListener listener) { + public void setMarkerPickListener(@Nullable final MarkerPickListener listener) { mapController.setMarkerPickListener(new MapController.MarkerPickListener() { @Override public void onMarkerPick(final MarkerPickResult markerPickResult, final float positionX, @@ -798,7 +800,7 @@ public void onMarkerPick(final MarkerPickResult markerPickResult, final float po /** * Set a listener for when view is fully loaded and no ease or label animations running. */ - public void setViewCompleteListener(final ViewCompleteListener listener) { + public void setViewCompleteListener(@Nullable final ViewCompleteListener listener) { mapController.setViewCompleteListener(new MapController.ViewCompleteListener() { @Override public void onViewComplete() { new Handler(Looper.getMainLooper()).post(new Runnable() { @@ -815,7 +817,7 @@ public void setViewCompleteListener(final ViewCompleteListener listener) { * * @param r Runnable to run */ - public void queueEvent(Runnable r) { + public void queueEvent(@NonNull Runnable r) { mapController.queueEvent(r); } @@ -826,7 +828,7 @@ public void queueEvent(Runnable r) { * @param value A YAML valid string (example "{ property: true }" or "true") */ @Deprecated - public void queueSceneUpdate(String componentPath, String value) { + public void queueSceneUpdate(@NonNull String componentPath, @NonNull String value) { queuedSceneUpdates.add(new SceneUpdate(componentPath, value)); } @@ -861,7 +863,7 @@ public void setCompassButtonEnabled(boolean enabled) { /** * Draws two pins on the map. The start pin is active and the end pin is inactive. */ - public void drawRoutePins(LngLat start, LngLat end) { + public void drawRoutePins(@NonNull LngLat start, @NonNull LngLat end) { overlayManager.drawRoutePins(start, end); } @@ -875,7 +877,7 @@ public void clearRoutePins() { /** * Draws a dropped pin on the map at the point supplied. */ - public void drawDroppedPin(LngLat point) { + public void drawDroppedPin(@NonNull LngLat point) { overlayManager.drawDroppedPin(point); } @@ -889,21 +891,21 @@ public void clearDroppedPins() { /** * Draws a search result on the map at the point supplied. The pin will be active. */ - public void drawSearchResult(LngLat point) { + public void drawSearchResult(@NonNull LngLat point) { drawSearchResult(point, true); } /** * Draws a search result on the map at the point supplied. */ - public void drawSearchResult(LngLat point, boolean active) { + public void drawSearchResult(@NonNull LngLat point, boolean active) { overlayManager.drawSearchResult(point, active); } /** * Draws search results on the map. All pins are displayed as active. */ - public void drawSearchResults(List points) { + public void drawSearchResults(@NonNull List points) { int index = 0; for (LngLat point : points) { overlayManager.drawSearchResult(point, true, index); @@ -915,7 +917,7 @@ public void drawSearchResults(List points) { * Draws search results on the map. All pins will be inactive except for the one at the active * index supplied. */ - public void drawSearchResults(List points, int... activeIndexes) { + public void drawSearchResults(@NonNull List points, int... activeIndexes) { int index = 0; for (LngLat point : points) { boolean status = false; @@ -940,7 +942,7 @@ public void clearSearchResults() { /** * Draws route pin at the point supplied. */ - public void drawRouteLocationMarker(LngLat point) { + public void drawRouteLocationMarker(@NonNull LngLat point) { overlayManager.drawRouteLocationMarker(point); } @@ -954,7 +956,7 @@ public void clearRouteLocationMarker() { /** * Draws route line on the map for the points supplied. */ - public void drawRouteLine(List points) { + public void drawRouteLine(@NonNull List points) { overlayManager.drawRouteLine(points); } @@ -1054,7 +1056,7 @@ public void setOverlaysEnabled(boolean transitOverlayEnabled, boolean bikeOverla * Sets the object used to add query parameters and headers to each request. * @param handler */ - public void setHttpHandler(MapzenMapHttpHandler handler) { + public void setHttpHandler(@NonNull MapzenMapHttpHandler handler) { mapController.setHttpHandler(handler.httpHandler()); } @@ -1074,7 +1076,7 @@ public BitmapMarker addBitmapMarker(MarkerOptions markerOptions) { * @param markerOptions options used to define marker appearance. * @return a new bitmap marker instance. */ - public BitmapMarker addBitmapMarker(BitmapMarkerOptions markerOptions) { + @NonNull public BitmapMarker addBitmapMarker(@NonNull BitmapMarkerOptions markerOptions) { return bitmapMarkerManager.addMarker(markerOptions); } diff --git a/core/src/main/java/com/mapzen/android/graphics/MapzenMapPeliasLocationProvider.java b/core/src/main/java/com/mapzen/android/graphics/MapzenMapPeliasLocationProvider.java index 379b2073..b1427133 100644 --- a/core/src/main/java/com/mapzen/android/graphics/MapzenMapPeliasLocationProvider.java +++ b/core/src/main/java/com/mapzen/android/graphics/MapzenMapPeliasLocationProvider.java @@ -6,6 +6,8 @@ import android.content.Context; import android.graphics.PointF; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.view.Display; import android.view.WindowManager; @@ -24,7 +26,7 @@ public class MapzenMapPeliasLocationProvider implements PeliasLocationProvider { * Public constructor. * @param context */ - public MapzenMapPeliasLocationProvider(Context context) { + public MapzenMapPeliasLocationProvider(@NonNull Context context) { this.context = context; } @@ -32,7 +34,7 @@ public MapzenMapPeliasLocationProvider(Context context) { * Set the map to use for retrieving lat/lon/bounding box. * @param map */ - public void setMapzenMap(MapzenMap map) { + public void setMapzenMap(@Nullable MapzenMap map) { this.mapzenMap = map; } @@ -58,7 +60,7 @@ public void setMapzenMap(MapzenMap map) { return midLatLon.longitude; } - @Override public BoundingBox getBoundingBox() { + @Override @Nullable public BoundingBox getBoundingBox() { if (mapzenMap == null) { return null; } diff --git a/core/src/main/java/com/mapzen/android/graphics/MarkerPickListener.java b/core/src/main/java/com/mapzen/android/graphics/MarkerPickListener.java index c3b89a3e..10db866b 100644 --- a/core/src/main/java/com/mapzen/android/graphics/MarkerPickListener.java +++ b/core/src/main/java/com/mapzen/android/graphics/MarkerPickListener.java @@ -2,6 +2,8 @@ import com.mapzen.android.graphics.model.BitmapMarker; +import android.support.annotation.NonNull; + /** * Listener invoked when a marker on the map is selected. Note that all * {@link com.mapzen.android.graphics.model.Polygon}s, @@ -14,5 +16,5 @@ public interface MarkerPickListener { * Receives information about markers found in a call to {@link * com.mapzen.tangram.MapController#pickMarker(float, float)} (float, float)}. */ - void onMarkerPick(BitmapMarker marker); + void onMarkerPick(@NonNull BitmapMarker marker); } diff --git a/core/src/main/java/com/mapzen/android/graphics/OnMapReadyCallback.java b/core/src/main/java/com/mapzen/android/graphics/OnMapReadyCallback.java index 900bfdfd..2b2fc105 100644 --- a/core/src/main/java/com/mapzen/android/graphics/OnMapReadyCallback.java +++ b/core/src/main/java/com/mapzen/android/graphics/OnMapReadyCallback.java @@ -1,5 +1,7 @@ package com.mapzen.android.graphics; +import android.support.annotation.NonNull; + /** * Interface for receiving a {@code MapController} once it is ready to be used. */ @@ -9,5 +11,5 @@ public interface OnMapReadyCallback { * * @param mapzenMap A non-null {@link MapzenMap} instance for this {@code MapView}. */ - void onMapReady(MapzenMap mapzenMap); + void onMapReady(@NonNull MapzenMap mapzenMap); } diff --git a/core/src/main/java/com/mapzen/android/graphics/ViewCompleteListener.java b/core/src/main/java/com/mapzen/android/graphics/ViewCompleteListener.java index 110289a7..ca0c64c0 100644 --- a/core/src/main/java/com/mapzen/android/graphics/ViewCompleteListener.java +++ b/core/src/main/java/com/mapzen/android/graphics/ViewCompleteListener.java @@ -8,5 +8,5 @@ public interface ViewCompleteListener { * Called on the render-thread at the end of whenever the view is fully loaded and * no ease- or label-animation is running. */ - public void onViewComplete(); + void onViewComplete(); } diff --git a/core/src/main/java/com/mapzen/android/graphics/model/BitmapMarker.java b/core/src/main/java/com/mapzen/android/graphics/model/BitmapMarker.java index 953a3065..cbe0e024 100644 --- a/core/src/main/java/com/mapzen/android/graphics/model/BitmapMarker.java +++ b/core/src/main/java/com/mapzen/android/graphics/model/BitmapMarker.java @@ -6,6 +6,8 @@ import com.mapzen.tangram.Marker; import android.graphics.drawable.Drawable; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; /** * Dynamic marker overlay constructed using a local bitmap. @@ -50,7 +52,7 @@ public void remove() { * Sets the marker's coordinate position. * @param position */ - public void setPosition(LngLat position) { + public void setPosition(@NonNull LngLat position) { this.position = position; this.tangramMarker.setPoint(position); } @@ -61,7 +63,7 @@ public void setPosition(LngLat position) { * @param duration * @param easeType */ - public void setPosition(LngLat position, int duration, EaseType easeType) { + public void setPosition(@NonNull LngLat position, int duration, EaseType easeType) { this.position = position; this.tangramMarker.setPointEased(position, duration, EaseTypeConverter.EASE_TYPE_TO_MAP_CONTROLLER_EASE_TYPE.get(easeType)); @@ -71,7 +73,7 @@ public void setPosition(LngLat position, int duration, EaseType easeType) { * Returns the marker's coordinate position. * @return */ - public LngLat getPosition() { + public @NonNull LngLat getPosition() { return this.position; } @@ -99,7 +101,7 @@ public int getIcon() { * icon resource id values set via {@link BitmapMarker#setIcon(int)}. * @param drawable */ - public void setIcon(Drawable drawable) { + public void setIcon(@Nullable Drawable drawable) { this.resourceId = Integer.MIN_VALUE; this.drawable = drawable; this.tangramMarker.setDrawable(drawable); @@ -109,7 +111,7 @@ public void setIcon(Drawable drawable) { * Returns the marker's icon drawable. * @return */ - public Drawable getIconDrawable() { + public @Nullable Drawable getIconDrawable() { return this.drawable; } @@ -178,7 +180,7 @@ public int getDrawOrder() { * Sets extra data to be associated with this marker. * @param userData */ - public void setUserData(Object userData) { + public void setUserData(@Nullable Object userData) { this.tangramMarker.setUserData(userData); } @@ -186,7 +188,7 @@ public void setUserData(Object userData) { * Gets extra data associated with this marker. * @return */ - public Object getUserData() { + public @Nullable Object getUserData() { return this.tangramMarker.getUserData(); } @@ -214,7 +216,7 @@ public int getColor() { * color int values set via {@link BitmapMarker#setColor(int)}. * @param hex */ - public void setColor(String hex) { + public void setColor(@NonNull String hex) { this.colorHex = hex; this.colorInt = Integer.MIN_VALUE; updateStyleString(); @@ -224,7 +226,7 @@ public void setColor(String hex) { * Returns the marker's color hex. * @return */ - public String getColorHex() { + public @NonNull String getColorHex() { return this.colorHex; } diff --git a/core/src/main/java/com/mapzen/android/graphics/model/BitmapMarkerOptions.java b/core/src/main/java/com/mapzen/android/graphics/model/BitmapMarkerOptions.java index e9afb8a4..af2a1f3c 100644 --- a/core/src/main/java/com/mapzen/android/graphics/model/BitmapMarkerOptions.java +++ b/core/src/main/java/com/mapzen/android/graphics/model/BitmapMarkerOptions.java @@ -4,6 +4,8 @@ import com.mapzen.tangram.LngLat; import android.graphics.drawable.Drawable; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; /** * Defines options for a {@link BitmapMarker}. @@ -35,7 +37,7 @@ public class BitmapMarkerOptions { * @param position coordinate to display the marker. * @return this marker options instance. */ - public BitmapMarkerOptions position(LngLat position) { + public @NonNull BitmapMarkerOptions position(@NonNull LngLat position) { this.position = position; return this; } @@ -47,7 +49,7 @@ public BitmapMarkerOptions position(LngLat position) { * @param resId drawable resource ID for the marker to display. * @return this marker options instance. */ - public BitmapMarkerOptions icon(int resId) { + public @NonNull BitmapMarkerOptions icon(int resId) { this.resId = resId; this.res = null; return this; @@ -60,7 +62,7 @@ public BitmapMarkerOptions icon(int resId) { * @param res drawable resource for the marker to display. * @return this marker options instance. */ - public BitmapMarkerOptions icon(Drawable res) { + public @NonNull BitmapMarkerOptions icon(@NonNull Drawable res) { this.res = res; this.resId = RES_NONE; return this; @@ -73,7 +75,7 @@ public BitmapMarkerOptions icon(Drawable res) { * @param height in pixels * @return this marker options instance. */ - public BitmapMarkerOptions size(int width, int height) { + public @NonNull BitmapMarkerOptions size(int width, int height) { this.width = width; this.height = height; return this; @@ -84,7 +86,7 @@ public BitmapMarkerOptions size(int width, int height) { * @param isVisible * @return */ - public BitmapMarkerOptions visible(boolean isVisible) { + public @NonNull BitmapMarkerOptions visible(boolean isVisible) { this.isVisible = isVisible; return this; } @@ -92,7 +94,7 @@ public BitmapMarkerOptions visible(boolean isVisible) { /** * Sets marker z-axis draw order. */ - public BitmapMarkerOptions drawOrder(int drawOrder) { + public @NonNull BitmapMarkerOptions drawOrder(int drawOrder) { this.drawOrder = drawOrder; return this; } @@ -102,7 +104,7 @@ public BitmapMarkerOptions drawOrder(int drawOrder) { * @param userData * @return */ - public BitmapMarkerOptions userData(Object userData) { + public @NonNull BitmapMarkerOptions userData(@NonNull Object userData) { this.userData = userData; return this; } @@ -113,7 +115,7 @@ public BitmapMarkerOptions userData(Object userData) { * @param colorInt * @return */ - public BitmapMarkerOptions colorInt(int colorInt) { + public @NonNull BitmapMarkerOptions colorInt(int colorInt) { this.colorInt = colorInt; this.colorHex = null; return this; @@ -125,7 +127,7 @@ public BitmapMarkerOptions colorInt(int colorInt) { * @param colorHex * @return */ - public BitmapMarkerOptions colorHex(String colorHex) { + public @NonNull BitmapMarkerOptions colorHex(@NonNull String colorHex) { this.colorHex = colorHex; this.colorInt = Integer.MIN_VALUE; return this; @@ -136,14 +138,14 @@ public BitmapMarkerOptions colorHex(String colorHex) { * @param isInteractive * @return */ - public BitmapMarkerOptions interactive(boolean isInteractive) { + public @NonNull BitmapMarkerOptions interactive(boolean isInteractive) { this.isInteractive = isInteractive; return this; } // Getters - public LngLat getPosition() { + public @NonNull LngLat getPosition() { return position; } @@ -151,7 +153,7 @@ public int getIcon() { return resId; } - public Drawable getIconDrawable() { + public @Nullable Drawable getIconDrawable() { return res; } @@ -171,7 +173,7 @@ public int getDrawOrder() { return drawOrder; } - public Object getUserData() { + public @Nullable Object getUserData() { return userData; } @@ -179,7 +181,7 @@ public int getColorInt() { return colorInt; } - public String getColorHex() { + public @NonNull String getColorHex() { return colorHex; } diff --git a/core/src/main/java/com/mapzen/android/graphics/model/BubbleWrapStyle.java b/core/src/main/java/com/mapzen/android/graphics/model/BubbleWrapStyle.java index b4c0e4ef..bba6dd40 100644 --- a/core/src/main/java/com/mapzen/android/graphics/model/BubbleWrapStyle.java +++ b/core/src/main/java/com/mapzen/android/graphics/model/BubbleWrapStyle.java @@ -1,5 +1,8 @@ package com.mapzen.android.graphics.model; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + import java.util.Set; /** @@ -14,15 +17,15 @@ public BubbleWrapStyle() { super("bubble-wrap/bubble-wrap-style.yaml"); } - @Override public String getBaseStyleFilename() { + @NonNull @Override public String getBaseStyleFilename() { return "bubble-wrap-style.yaml"; } - @Override public String getStyleRootPath() { + @NonNull @Override public String getStyleRootPath() { return "bubble-wrap/"; } - @Override public String getThemesPath() { + @NonNull @Override public String getThemesPath() { return "themes/"; } @@ -42,11 +45,11 @@ public BubbleWrapStyle() { return 12; } - @Override public ThemeColor getDefaultColor() { + @NonNull @Override public ThemeColor getDefaultColor() { return ThemeColor.NONE; } - @Override public Set getColors() { + @Nullable @Override public Set getColors() { return null; } } diff --git a/core/src/main/java/com/mapzen/android/graphics/model/CinnabarStyle.java b/core/src/main/java/com/mapzen/android/graphics/model/CinnabarStyle.java index 6fd1d51c..bfdfdad2 100644 --- a/core/src/main/java/com/mapzen/android/graphics/model/CinnabarStyle.java +++ b/core/src/main/java/com/mapzen/android/graphics/model/CinnabarStyle.java @@ -1,5 +1,8 @@ package com.mapzen.android.graphics.model; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + import java.util.HashSet; import java.util.Set; @@ -21,15 +24,15 @@ public CinnabarStyle() { super("cinnabar-style/cinnabar-style.yaml"); } - @Override public String getBaseStyleFilename() { + @NonNull @Override public String getBaseStyleFilename() { return "cinnabar-style.yaml"; } - @Override public String getStyleRootPath() { + @NonNull @Override public String getStyleRootPath() { return "cinnabar-style/"; } - @Override public String getThemesPath() { + @NonNull @Override public String getThemesPath() { return "themes/"; } @@ -49,11 +52,11 @@ public CinnabarStyle() { return 12; } - @Override public ThemeColor getDefaultColor() { + @NonNull @Override public ThemeColor getDefaultColor() { return CINNABAR; } - @Override public Set getColors() { + @Nullable @Override public Set getColors() { return supportedColors; } } diff --git a/core/src/main/java/com/mapzen/android/graphics/model/MapStyle.java b/core/src/main/java/com/mapzen/android/graphics/model/MapStyle.java index 2d06b3f5..a660a8b0 100644 --- a/core/src/main/java/com/mapzen/android/graphics/model/MapStyle.java +++ b/core/src/main/java/com/mapzen/android/graphics/model/MapStyle.java @@ -1,5 +1,7 @@ package com.mapzen.android.graphics.model; +import android.support.annotation.NonNull; + /** * Map style given a scene file. */ @@ -10,14 +12,14 @@ public class MapStyle { /** * Creates a new instance. */ - public MapStyle(String sceneFile) { + public MapStyle(@NonNull String sceneFile) { this.sceneFile = sceneFile; } /** * Get the underlying scene filename. */ - public String getSceneFile() { + @NonNull public String getSceneFile() { return sceneFile; } } diff --git a/core/src/main/java/com/mapzen/android/graphics/model/Marker.java b/core/src/main/java/com/mapzen/android/graphics/model/Marker.java index 6e828fba..ca2cfcce 100644 --- a/core/src/main/java/com/mapzen/android/graphics/model/Marker.java +++ b/core/src/main/java/com/mapzen/android/graphics/model/Marker.java @@ -2,6 +2,8 @@ import com.mapzen.tangram.LngLat; +import android.support.annotation.NonNull; + /** * Represents a pin marker on a map backed by {@link com.mapzen.tangram.MapData} objects. */ @@ -19,7 +21,7 @@ public Marker(double longitude, double latitude) { /** * Return the marker's coordinate location. */ - public LngLat getLocation() { + public @NonNull LngLat getLocation() { return latLng; } diff --git a/core/src/main/java/com/mapzen/android/graphics/model/Polygon.java b/core/src/main/java/com/mapzen/android/graphics/model/Polygon.java index 3bbbfd18..549d9d0e 100644 --- a/core/src/main/java/com/mapzen/android/graphics/model/Polygon.java +++ b/core/src/main/java/com/mapzen/android/graphics/model/Polygon.java @@ -2,6 +2,8 @@ import com.mapzen.tangram.LngLat; +import android.support.annotation.NonNull; + import java.util.ArrayList; import java.util.List; @@ -32,7 +34,7 @@ public Builder() { /** * Add a new coordinate pair to the {@link Polygon}. */ - public Builder add(LngLat c) { + @NonNull public Builder add(@NonNull LngLat c) { coordinates.add(c); return this; } @@ -42,7 +44,7 @@ public Builder add(LngLat c) { * * @return the configured {@link Polygon} */ - public Polygon build() { + @NonNull public Polygon build() { return new Polygon(coordinates); } } diff --git a/core/src/main/java/com/mapzen/android/graphics/model/Polyline.java b/core/src/main/java/com/mapzen/android/graphics/model/Polyline.java index d3352694..a7a18c71 100644 --- a/core/src/main/java/com/mapzen/android/graphics/model/Polyline.java +++ b/core/src/main/java/com/mapzen/android/graphics/model/Polyline.java @@ -2,6 +2,8 @@ import com.mapzen.tangram.LngLat; +import android.support.annotation.NonNull; + import java.util.ArrayList; import java.util.List; @@ -15,7 +17,7 @@ public class Polyline { /** * Constructs a new {@link Polyline} object. */ - public Polyline(List coordinates) { + public Polyline(@NonNull List coordinates) { this.coordinates = coordinates; } @@ -34,7 +36,7 @@ public Builder() { /** * Add a coordinate pair to the {@link Polyline}. */ - public Builder add(LngLat c) { + @NonNull public Builder add(@NonNull LngLat c) { coordinates.add(c); return this; } @@ -44,7 +46,7 @@ public Builder add(LngLat c) { * * @return the newly created {@link Polyline} */ - public Polyline build() { + @NonNull public Polyline build() { return new Polyline(coordinates); } } @@ -52,7 +54,7 @@ public Polyline build() { /** * The {@link Polyline}'s coordinates. */ - public List getCoordinates() { + @NonNull public List getCoordinates() { return coordinates; } diff --git a/core/src/main/java/com/mapzen/android/graphics/model/RefillStyle.java b/core/src/main/java/com/mapzen/android/graphics/model/RefillStyle.java index 32031d72..4ce67d2c 100644 --- a/core/src/main/java/com/mapzen/android/graphics/model/RefillStyle.java +++ b/core/src/main/java/com/mapzen/android/graphics/model/RefillStyle.java @@ -1,5 +1,8 @@ package com.mapzen.android.graphics.model; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + import java.util.HashSet; import java.util.Set; @@ -47,15 +50,15 @@ public RefillStyle() { super("refill-style/refill-style.yaml"); } - @Override public String getBaseStyleFilename() { + @NonNull @Override public String getBaseStyleFilename() { return "refill-style.yaml"; } - @Override public String getStyleRootPath() { + @NonNull @Override public String getStyleRootPath() { return "refill-style/"; } - @Override public String getThemesPath() { + @NonNull @Override public String getThemesPath() { return "themes/"; } @@ -75,11 +78,11 @@ public RefillStyle() { return 12; } - @Override public ThemeColor getDefaultColor() { + @NonNull @Override public ThemeColor getDefaultColor() { return BLACK; } - @Override public Set getColors() { + @Nullable @Override public Set getColors() { return supportedColors; } } diff --git a/core/src/main/java/com/mapzen/android/graphics/model/ThemeColor.java b/core/src/main/java/com/mapzen/android/graphics/model/ThemeColor.java index 204c0b65..c128491d 100644 --- a/core/src/main/java/com/mapzen/android/graphics/model/ThemeColor.java +++ b/core/src/main/java/com/mapzen/android/graphics/model/ThemeColor.java @@ -1,5 +1,7 @@ package com.mapzen.android.graphics.model; +import android.support.annotation.NonNull; + /** * Available color themes for {@link RefillStyle}. */ @@ -35,7 +37,7 @@ public enum ThemeColor { * Returns string value of theme color. * @return */ - public String toString() { + @NonNull public String toString() { return color; } } diff --git a/core/src/main/java/com/mapzen/android/graphics/model/ThemedMapStyle.java b/core/src/main/java/com/mapzen/android/graphics/model/ThemedMapStyle.java index efc9ffba..7a8be9a9 100644 --- a/core/src/main/java/com/mapzen/android/graphics/model/ThemedMapStyle.java +++ b/core/src/main/java/com/mapzen/android/graphics/model/ThemedMapStyle.java @@ -1,5 +1,8 @@ package com.mapzen.android.graphics.model; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + import java.util.Set; /** @@ -22,21 +25,21 @@ public ThemedMapStyle(String baseSceneFile) { * ie. "styles/refill-style/" * @return */ - public abstract String getStyleRootPath(); + @NonNull public abstract String getStyleRootPath(); /** * Returns the style's base file. * ie. "refill-style.yaml" * @return */ - public abstract String getBaseStyleFilename(); + @NonNull public abstract String getBaseStyleFilename(); /** * Returns the themes directory path. * ie "themes/" * @return */ - public abstract String getThemesPath(); + @NonNull public abstract String getThemesPath(); /** * Returns the default detail level for the style. @@ -70,7 +73,7 @@ public ThemedMapStyle(String baseSceneFile) { * Returns the default color for the style. * @return */ - public abstract ThemeColor getDefaultColor(); + @NonNull public abstract ThemeColor getDefaultColor(); /** * Returns colors the theme supports. Color theme filenames should follow the format @@ -78,5 +81,5 @@ public ThemedMapStyle(String baseSceneFile) { * ie. "color-pink.yaml" * @return */ - public abstract Set getColors(); + @Nullable public abstract Set getColors(); } diff --git a/core/src/main/java/com/mapzen/android/graphics/model/TronStyle.java b/core/src/main/java/com/mapzen/android/graphics/model/TronStyle.java index 175627c0..dd405f41 100644 --- a/core/src/main/java/com/mapzen/android/graphics/model/TronStyle.java +++ b/core/src/main/java/com/mapzen/android/graphics/model/TronStyle.java @@ -1,5 +1,8 @@ package com.mapzen.android.graphics.model; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + import java.util.Set; /** @@ -14,15 +17,15 @@ public TronStyle() { super("tron-style/tron-style.yaml"); } - @Override public String getBaseStyleFilename() { + @NonNull @Override public String getBaseStyleFilename() { return "tron-style.yaml"; } - @Override public String getStyleRootPath() { + @NonNull @Override public String getStyleRootPath() { return "tron-style/"; } - @Override public String getThemesPath() { + @NonNull @Override public String getThemesPath() { return "themes/"; } @@ -42,11 +45,11 @@ public TronStyle() { return 12; } - @Override public ThemeColor getDefaultColor() { + @NonNull @Override public ThemeColor getDefaultColor() { return ThemeColor.NONE; } - @Override public Set getColors() { + @Nullable @Override public Set getColors() { return null; } } diff --git a/core/src/main/java/com/mapzen/android/graphics/model/WalkaboutStyle.java b/core/src/main/java/com/mapzen/android/graphics/model/WalkaboutStyle.java index 56a22e1f..dcd166b7 100644 --- a/core/src/main/java/com/mapzen/android/graphics/model/WalkaboutStyle.java +++ b/core/src/main/java/com/mapzen/android/graphics/model/WalkaboutStyle.java @@ -1,5 +1,8 @@ package com.mapzen.android.graphics.model; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + import java.util.Set; /** @@ -14,15 +17,15 @@ public WalkaboutStyle() { super("walkabout-style/walkabout-style.yaml"); } - @Override public String getBaseStyleFilename() { + @NonNull @Override public String getBaseStyleFilename() { return "walkabout-style.yaml"; } - @Override public String getStyleRootPath() { + @NonNull @Override public String getStyleRootPath() { return "walkabout-style/"; } - @Override public String getThemesPath() { + @NonNull @Override public String getThemesPath() { return "themes/"; } @@ -42,11 +45,11 @@ public WalkaboutStyle() { return 12; } - @Override public ThemeColor getDefaultColor() { + @NonNull @Override public ThemeColor getDefaultColor() { return ThemeColor.NONE; } - @Override public Set getColors() { + @Nullable @Override public Set getColors() { return null; } } diff --git a/core/src/main/java/com/mapzen/android/search/MapzenSearch.java b/core/src/main/java/com/mapzen/android/search/MapzenSearch.java index 66893c47..f254321e 100644 --- a/core/src/main/java/com/mapzen/android/search/MapzenSearch.java +++ b/core/src/main/java/com/mapzen/android/search/MapzenSearch.java @@ -9,6 +9,8 @@ import com.mapzen.pelias.gson.Result; import android.content.Context; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import javax.inject.Inject; @@ -26,7 +28,7 @@ public class MapzenSearch { /** * Creates a new {@link MapzenSearch} with api key set from mapzen.xml. */ - public MapzenSearch(Context context) { + public MapzenSearch(@NonNull Context context) { initDI(context); internalSearch = new Pelias(); searchInitializer.initSearch(this); @@ -36,7 +38,7 @@ public MapzenSearch(Context context) { * Creates a new {@link MapzenSearch} with the {@link Pelias} object used for underlying * search/autocomplete queries. */ - public MapzenSearch(Context context, Pelias pelias) { + public MapzenSearch(@NonNull Context context, @NonNull Pelias pelias) { initDI(context); internalSearch = pelias; searchInitializer.initSearch(this); @@ -54,7 +56,7 @@ private void initDI(Context context) { * @param query * @param callback */ - public Request suggest(String query, Callback callback) { + public Request suggest(@NonNull String query, @Nullable Callback callback) { return new CallRequest(internalSearch.suggest(query, callback)); } @@ -64,7 +66,8 @@ public Request suggest(String query, Callback callback) { * @param query * @param callback */ - public Request suggest(String query, double lat, double lon, Callback callback) { + public Request suggest(@NonNull String query, double lat, double lon, + @Nullable Callback callback) { return new CallRequest(internalSearch.suggest(query, lat, lon, callback)); } @@ -75,8 +78,8 @@ public Request suggest(String query, double lat, double lon, Callback ca * @param query * @param callback */ - public Request search(String query, Callback callback) { - return new CallRequest(internalSearch.search(query, callback)); + public Request search(@NonNull String query, @Nullable Callback callback) { + return new CallRequest(internalSearch.search(query, callback)); } /** @@ -86,7 +89,8 @@ public Request search(String query, Callback callback) { * @param query * @param callback */ - public Request search(String query, BoundingBox box, Callback callback) { + public Request search(@NonNull String query, @NonNull BoundingBox box, + @Nullable Callback callback) { return new CallRequest(internalSearch.search(query, box, callback)); } @@ -97,8 +101,9 @@ public Request search(String query, BoundingBox box, Callback callback) * @param query * @param callback */ - public Request search(String query, double lat, double lon, Callback callback) { - return new CallRequest(internalSearch.search(query, lat, lon, callback)); + public Request search(@NonNull String query, double lat, double lon, + @Nullable Callback callback) { + return new CallRequest(internalSearch.search(query, lat, lon, callback)); } /** @@ -108,7 +113,7 @@ public Request search(String query, double lat, double lon, Callback cal * @param lon * @param callback */ - public Request reverse(double lat, double lon, Callback callback) { + public Request reverse(double lat, double lon, @Nullable Callback callback) { return new CallRequest(internalSearch.reverse(lat, lon, callback)); } @@ -118,7 +123,7 @@ public Request reverse(double lat, double lon, Callback callback) { * @param gid * @param callback */ - public Request place(String gid, Callback callback) { + public Request place(@NonNull String gid, @Nullable Callback callback) { return new CallRequest(internalSearch.place(gid, callback)); } @@ -127,7 +132,7 @@ public Request place(String gid, Callback callback) { * more relevant results for given positions and areas * @param locationProvider */ - public void setLocationProvider(PeliasLocationProvider locationProvider) { + public void setLocationProvider(@NonNull PeliasLocationProvider locationProvider) { internalSearch.setLocationProvider(locationProvider); } @@ -136,7 +141,7 @@ public void setLocationProvider(PeliasLocationProvider locationProvider) { * requests. * @param handler */ - public void setHttpHandler(MapzenSearchHttpHandler handler) { + public void setHttpHandler(@Nullable MapzenSearchHttpHandler handler) { internalSearch.setRequestHandler(handler.searchHandler()); } @@ -144,7 +149,7 @@ public void setHttpHandler(MapzenSearchHttpHandler handler) { * Return the underlying {@link Pelias} object. * @return */ - public Pelias getPelias() { + @NonNull public Pelias getPelias() { return internalSearch; } } diff --git a/core/src/main/java/com/mapzen/android/search/MapzenSearchHttpHandler.java b/core/src/main/java/com/mapzen/android/search/MapzenSearchHttpHandler.java index f7646f8a..5bf969b0 100644 --- a/core/src/main/java/com/mapzen/android/search/MapzenSearchHttpHandler.java +++ b/core/src/main/java/com/mapzen/android/search/MapzenSearchHttpHandler.java @@ -6,6 +6,7 @@ import com.mapzen.pelias.PeliasRequestHandler; import android.content.Context; +import android.support.annotation.NonNull; import java.util.HashMap; import java.util.Map; @@ -25,7 +26,7 @@ public abstract class MapzenSearchHttpHandler implements GenericHttpHandler { /** * Public constructor. */ - public MapzenSearchHttpHandler(Context context) { + public MapzenSearchHttpHandler(@NonNull Context context) { searchHandler = new SearchRequestHandler(); MapzenManager mapzenManager = MapzenManager.instance(context); mapzenManager.addApiKeyChangeListener(apiKeyChangeListener); @@ -36,7 +37,7 @@ public MapzenSearchHttpHandler(Context context) { * Returns the internal handler. * @return */ - SearchRequestHandler searchHandler() { + @NonNull SearchRequestHandler searchHandler() { return searchHandler; } diff --git a/core/src/main/java/com/mapzen/android/search/SearchInitializer.java b/core/src/main/java/com/mapzen/android/search/SearchInitializer.java index 2d601484..549757cc 100644 --- a/core/src/main/java/com/mapzen/android/search/SearchInitializer.java +++ b/core/src/main/java/com/mapzen/android/search/SearchInitializer.java @@ -1,6 +1,7 @@ package com.mapzen.android.search; import android.content.Context; +import android.support.annotation.NonNull; import java.util.Map; @@ -14,7 +15,7 @@ public class SearchInitializer { * Constructor. * @param context */ - public SearchInitializer(Context context) { + public SearchInitializer(@NonNull Context context) { requestHandler = new MapzenSearchHttpHandler(context) { @Override public Map queryParamsForRequest() { return null; @@ -30,7 +31,7 @@ public SearchInitializer(Context context) { * Set the {@link MapzenSearch}'s {@link MapzenSearchHttpHandler}. * @param search */ - public void initSearch(MapzenSearch search) { + public void initSearch(@NonNull MapzenSearch search) { search.getPelias().setRequestHandler(requestHandler.searchHandler()); } @@ -39,7 +40,7 @@ public void initSearch(MapzenSearch search) { * Returns the request handler. * @return */ - public MapzenSearchHttpHandler getRequestHandler() { + @NonNull public MapzenSearchHttpHandler getRequestHandler() { return requestHandler; } } diff --git a/mapzen-android-sdk/src/main/java/com/mapzen/android/routing/Converter.java b/mapzen-android-sdk/src/main/java/com/mapzen/android/routing/Converter.java index c867fab9..96f3c55e 100644 --- a/mapzen-android-sdk/src/main/java/com/mapzen/android/routing/Converter.java +++ b/mapzen-android-sdk/src/main/java/com/mapzen/android/routing/Converter.java @@ -2,6 +2,8 @@ import com.mapzen.valhalla.Router; +import android.support.annotation.NonNull; + import java.util.HashMap; /** @@ -10,7 +12,7 @@ */ public class Converter { - public static final HashMap UNITS_TO_ROUTER_UNITS = new HashMap<>(); static { UNITS_TO_ROUTER_UNITS.put(MapzenRouter.DistanceUnits.MILES, Router.DistanceUnits.MILES); diff --git a/mapzen-android-sdk/src/main/java/com/mapzen/android/routing/MapzenDistanceFormatter.java b/mapzen-android-sdk/src/main/java/com/mapzen/android/routing/MapzenDistanceFormatter.java index 108c4377..07cbd089 100644 --- a/mapzen-android-sdk/src/main/java/com/mapzen/android/routing/MapzenDistanceFormatter.java +++ b/mapzen-android-sdk/src/main/java/com/mapzen/android/routing/MapzenDistanceFormatter.java @@ -3,6 +3,8 @@ import com.mapzen.helpers.DistanceFormatter; import com.mapzen.valhalla.Router; +import android.support.annotation.NonNull; + /** * Formatter for dealing with {@link MapzenRouter.DistanceUnits}. */ @@ -16,7 +18,7 @@ public class MapzenDistanceFormatter { * @param units miles or kilometers. * @return distance string formatted according to the rules of the formatter. */ - public static String format(int distanceInMeters, boolean realTime, + @NonNull public static String format(int distanceInMeters, boolean realTime, MapzenRouter.DistanceUnits units) { Router.DistanceUnits routerUnits = Converter.UNITS_TO_ROUTER_UNITS.get(units); return DistanceFormatter.format(distanceInMeters, realTime, routerUnits); diff --git a/mapzen-android-sdk/src/main/java/com/mapzen/android/routing/MapzenRouter.java b/mapzen-android-sdk/src/main/java/com/mapzen/android/routing/MapzenRouter.java index 972d9bde..6e52a2ae 100644 --- a/mapzen-android-sdk/src/main/java/com/mapzen/android/routing/MapzenRouter.java +++ b/mapzen-android-sdk/src/main/java/com/mapzen/android/routing/MapzenRouter.java @@ -8,6 +8,8 @@ import com.mapzen.valhalla.ValhallaRouter; import android.content.Context; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import javax.inject.Inject; @@ -26,7 +28,7 @@ public class MapzenRouter { /** * Creates a new {@link MapzenRouter} with api key set from mapzen.xml. */ - public MapzenRouter(Context context) { + public MapzenRouter(@NonNull Context context) { initDI(context); routerInitializer.initRouter(this); } @@ -48,7 +50,7 @@ public Request fetch() { * @param callback * @return */ - public MapzenRouter setCallback(RouteCallback callback) { + @NonNull public MapzenRouter setCallback(@Nullable RouteCallback callback) { internalRouter.setCallback(callback); return this; } @@ -58,7 +60,7 @@ public MapzenRouter setCallback(RouteCallback callback) { * @param units * @return */ - public MapzenRouter setDistanceUnits(DistanceUnits units) { + @NonNull public MapzenRouter setDistanceUnits(@NonNull DistanceUnits units) { internalRouter.setDistanceUnits(UNITS_TO_ROUTER_UNITS.get(units)); return this; } @@ -71,7 +73,7 @@ public MapzenRouter setDistanceUnits(DistanceUnits units) { *

* https://github.com/valhalla/valhalla-docs/blob/master/api-reference.md#directions-options. */ - public MapzenRouter setLanguage(Router.Language language) { + @NonNull public MapzenRouter setLanguage(Router.Language language) { internalRouter.setLanguage(language); return this; } @@ -80,7 +82,7 @@ public MapzenRouter setLanguage(Router.Language language) { * The router can fetch different types of directions. Set the type to be biking. * @return */ - public MapzenRouter setBiking() { + @NonNull public MapzenRouter setBiking() { internalRouter.setBiking(); return this; } @@ -89,7 +91,7 @@ public MapzenRouter setBiking() { * The router can fetch different types of directions. Set the type to be driving. * @return */ - public MapzenRouter setDriving() { + @NonNull public MapzenRouter setDriving() { internalRouter.setDriving(); return this; } @@ -98,7 +100,7 @@ public MapzenRouter setDriving() { * The router can fetch different types of directions. Set the type to be walking. * @return */ - public MapzenRouter setWalking() { + @NonNull public MapzenRouter setWalking() { internalRouter.setWalking(); return this; } @@ -107,7 +109,7 @@ public MapzenRouter setWalking() { * The router can fetch different types of directions. Set the type to be multimodal. * @return */ - public MapzenRouter setMultimodal() { + @NonNull public MapzenRouter setMultimodal() { internalRouter.setMultimodal(); return this; } @@ -117,7 +119,7 @@ public MapzenRouter setMultimodal() { * @param point * @return */ - public MapzenRouter setLocation(double[] point) { + @NonNull public MapzenRouter setLocation(double[] point) { internalRouter.setLocation(point); return this; } @@ -127,7 +129,7 @@ public MapzenRouter setLocation(double[] point) { * @param point * @return */ - public MapzenRouter setLocation(double[] point, int heading) { + @NonNull public MapzenRouter setLocation(double[] point, int heading) { internalRouter.setLocation(point, heading); return this; } @@ -137,8 +139,8 @@ public MapzenRouter setLocation(double[] point, int heading) { * @param point * @return */ - public MapzenRouter setLocation(double[] point, String name, String street, String city, - String state) { + @NonNull public MapzenRouter setLocation(double[] point, @Nullable String name, + @Nullable String street, @Nullable String city, @Nullable String state) { internalRouter.setLocation(point, name, street, city, state); return this; } @@ -147,7 +149,7 @@ public MapzenRouter setLocation(double[] point, String name, String street, Stri * Remove all locations from the route. * @return */ - public MapzenRouter clearLocations() { + @NonNull public MapzenRouter clearLocations() { internalRouter.clearLocations(); return this; } @@ -157,11 +159,11 @@ public MapzenRouter clearLocations() { * requests. * @param handler */ - public void setHttpHandler(MapzenRouterHttpHandler handler) { + public void setHttpHandler(@Nullable MapzenRouterHttpHandler handler) { internalRouter.setHttpHandler(handler.turnByTurnHandler()); } - public Router getRouter() { + @NonNull public Router getRouter() { return internalRouter; } @@ -184,7 +186,7 @@ public enum DistanceUnits { /** * Returns string value. */ - public String toString() { + @NonNull public String toString() { return name; } } diff --git a/mapzen-android-sdk/src/main/java/com/mapzen/android/routing/MapzenRouterHttpHandler.java b/mapzen-android-sdk/src/main/java/com/mapzen/android/routing/MapzenRouterHttpHandler.java index f61b1b78..d7b82edb 100644 --- a/mapzen-android-sdk/src/main/java/com/mapzen/android/routing/MapzenRouterHttpHandler.java +++ b/mapzen-android-sdk/src/main/java/com/mapzen/android/routing/MapzenRouterHttpHandler.java @@ -7,6 +7,7 @@ import com.mapzen.valhalla.HttpHandler; import android.content.Context; +import android.support.annotation.NonNull; import java.io.IOException; import java.lang.ref.WeakReference; @@ -41,14 +42,15 @@ public abstract class MapzenRouterHttpHandler implements GenericHttpHandler { /** * Construct handler with default url and log levels. */ - public MapzenRouterHttpHandler(Context context) { + public MapzenRouterHttpHandler(@NonNull Context context) { this(context, DEFAULT_URL, DEFAULT_LOG_LEVEL); } /** * Construct handler with custom url and log levels. */ - public MapzenRouterHttpHandler(Context context, String url, LogLevel logLevel) { + public MapzenRouterHttpHandler(@NonNull Context context, @NonNull String url, + @NonNull LogLevel logLevel) { handler = new TurnByTurnHttpHandler(url, logLevel); MapzenManager mapzenManager = MapzenManager.instance(context); mapzenManager.addApiKeyChangeListener(apiKeyChangeListener); @@ -59,11 +61,11 @@ public MapzenRouterHttpHandler(Context context, String url, LogLevel logLevel) { * Returns the internal handler. * @return */ - TurnByTurnHttpHandler turnByTurnHandler() { + @NonNull TurnByTurnHttpHandler turnByTurnHandler() { return handler; } - private static LogLevel getDefaultLogLevel() { + @NonNull private static LogLevel getDefaultLogLevel() { return BASIC; } diff --git a/mapzen-android-sdk/src/main/java/com/mapzen/android/routing/RouterInitializer.java b/mapzen-android-sdk/src/main/java/com/mapzen/android/routing/RouterInitializer.java index e7019629..0d216b88 100644 --- a/mapzen-android-sdk/src/main/java/com/mapzen/android/routing/RouterInitializer.java +++ b/mapzen-android-sdk/src/main/java/com/mapzen/android/routing/RouterInitializer.java @@ -1,6 +1,7 @@ package com.mapzen.android.routing; import android.content.Context; +import android.support.annotation.NonNull; import java.util.Map; @@ -15,7 +16,7 @@ public class RouterInitializer { * Constructor. * @param context */ - public RouterInitializer(Context context) { + public RouterInitializer(@NonNull Context context) { requestHandler = new MapzenRouterHttpHandler(context) { @Override public Map queryParamsForRequest() { return null; @@ -31,7 +32,7 @@ public RouterInitializer(Context context) { * Set the {@link MapzenRouter}'s {@link MapzenRouterHttpHandler}. * @param router */ - public void initRouter(MapzenRouter router) { + public void initRouter(@NonNull MapzenRouter router) { router.getRouter().setHttpHandler(requestHandler.turnByTurnHandler()); } @@ -39,7 +40,7 @@ public void initRouter(MapzenRouter router) { * Returns the request handler. * @return */ - public MapzenRouterHttpHandler getRequestHandler() { + @NonNull public MapzenRouterHttpHandler getRequestHandler() { return requestHandler; } } diff --git a/mapzen-places-api/src/main/java/com/mapzen/places/api/AutocompleteFilter.java b/mapzen-places-api/src/main/java/com/mapzen/places/api/AutocompleteFilter.java index 172346f2..163bcd0e 100644 --- a/mapzen-places-api/src/main/java/com/mapzen/places/api/AutocompleteFilter.java +++ b/mapzen-places-api/src/main/java/com/mapzen/places/api/AutocompleteFilter.java @@ -2,6 +2,8 @@ import android.os.Parcel; import android.os.Parcelable; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; /** * Filter for customizing autocomplete results from {@link GeoDataApi}. @@ -39,7 +41,7 @@ public class AutocompleteFilter implements Parcelable { /** * Constructs a new object. */ - AutocompleteFilter(String country, int typeFilter) { + AutocompleteFilter(@Nullable String country, int typeFilter) { this.country = country; this.typeFilter = typeFilter; } @@ -49,7 +51,7 @@ public class AutocompleteFilter implements Parcelable { * code or null. * @return */ - public String getCountry() { + @Nullable public String getCountry() { return country; } @@ -85,7 +87,7 @@ public static class Builder { * @param country * @return */ - public Builder setCountry(String country) { + @NonNull public Builder setCountry(@Nullable String country) { this.country = country; return this; } @@ -106,7 +108,7 @@ public Builder setCountry(String country) { * @param typeFilter * @return */ - public Builder setTypeFilter(int typeFilter) { + @NonNull public Builder setTypeFilter(int typeFilter) { this.typeFilter = typeFilter; return this; } @@ -117,7 +119,7 @@ public Builder setTypeFilter(int typeFilter) { * String, LatLngBounds, AutocompleteFilter}. * @return */ - public AutocompleteFilter build() { + @NonNull public AutocompleteFilter build() { return new AutocompleteFilter(country, typeFilter); } } diff --git a/mapzen-places-api/src/main/java/com/mapzen/places/api/AutocompletePrediction.java b/mapzen-places-api/src/main/java/com/mapzen/places/api/AutocompletePrediction.java index 8f26edbc..2b535f35 100644 --- a/mapzen-places-api/src/main/java/com/mapzen/places/api/AutocompletePrediction.java +++ b/mapzen-places-api/src/main/java/com/mapzen/places/api/AutocompletePrediction.java @@ -19,7 +19,7 @@ public class AutocompletePrediction { * @param id * @param text */ - public AutocompletePrediction(String id, String text) { + public AutocompletePrediction(@Nullable String id, @Nullable String text) { placeId = id; primaryText = text; } diff --git a/mapzen-places-api/src/main/java/com/mapzen/places/api/AutocompletePredictionBuffer.java b/mapzen-places-api/src/main/java/com/mapzen/places/api/AutocompletePredictionBuffer.java index cda1c32f..d1ff4059 100644 --- a/mapzen-places-api/src/main/java/com/mapzen/places/api/AutocompletePredictionBuffer.java +++ b/mapzen-places-api/src/main/java/com/mapzen/places/api/AutocompletePredictionBuffer.java @@ -3,6 +3,9 @@ import com.mapzen.android.lost.api.Result; import com.mapzen.android.lost.api.Status; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + import java.util.List; /** @@ -18,12 +21,13 @@ public class AutocompletePredictionBuffer implements Result, DataBuffer predictions) { + public AutocompletePredictionBuffer(@NonNull Status status, + @Nullable List predictions) { this.status = status; this.predictions = predictions; } - @Override public Status getStatus() { + @NonNull @Override public Status getStatus() { return status; } @@ -34,7 +38,7 @@ public AutocompletePredictionBuffer(Status status, List return predictions.size(); } - @Override public AutocompletePrediction get(int index) { + @Nullable @Override public AutocompletePrediction get(int index) { if (predictions == null || index < 0 || index > predictions.size() - 1) { return null; } diff --git a/mapzen-places-api/src/main/java/com/mapzen/places/api/GeoDataApi.java b/mapzen-places-api/src/main/java/com/mapzen/places/api/GeoDataApi.java index 1639ecf8..a4a68cc4 100644 --- a/mapzen-places-api/src/main/java/com/mapzen/places/api/GeoDataApi.java +++ b/mapzen-places-api/src/main/java/com/mapzen/places/api/GeoDataApi.java @@ -3,6 +3,8 @@ import com.mapzen.android.lost.api.LostApiClient; import com.mapzen.android.lost.api.PendingResult; +import android.support.annotation.NonNull; + /** * Main entry point for the Mapzen Places Geo Data API. */ @@ -15,6 +17,7 @@ public interface GeoDataApi { * @param filter * @return */ - PendingResult getAutocompletePredictions(LostApiClient client, - String query, LatLngBounds bounds, AutocompleteFilter filter); + @NonNull PendingResult getAutocompletePredictions( + @NonNull LostApiClient client, @NonNull String query, @NonNull LatLngBounds bounds, + @NonNull AutocompleteFilter filter); } diff --git a/mapzen-places-api/src/main/java/com/mapzen/places/api/LatLngBounds.java b/mapzen-places-api/src/main/java/com/mapzen/places/api/LatLngBounds.java index 5499d7e4..6c3d4da5 100644 --- a/mapzen-places-api/src/main/java/com/mapzen/places/api/LatLngBounds.java +++ b/mapzen-places-api/src/main/java/com/mapzen/places/api/LatLngBounds.java @@ -2,6 +2,7 @@ import android.os.Parcel; import android.os.Parcelable; +import android.support.annotation.NonNull; /** * Represents a rectangular area. @@ -16,16 +17,16 @@ public class LatLngBounds implements Parcelable { * @param southwest * @param northeast */ - public LatLngBounds(LatLng southwest, LatLng northeast) { + public LatLngBounds(@NonNull LatLng southwest, @NonNull LatLng northeast) { this.southwest = southwest; this.northeast = northeast; } - public LatLng getSouthwest() { + @NonNull public LatLng getSouthwest() { return southwest; } - public LatLng getNortheast() { + @NonNull public LatLng getNortheast() { return northeast; } @@ -43,7 +44,7 @@ public boolean contains(LatLng point) { * @param point * @return */ - public LatLngBounds including(LatLng point) { + @NonNull public LatLngBounds including(@NonNull LatLng point) { double swLat = Math.min(this.southwest.getLatitude(), point.getLatitude()); double neLat = Math.max(this.northeast.getLatitude(), point.getLatitude()); double neLng = this.northeast.getLongitude(); @@ -64,7 +65,7 @@ public LatLngBounds including(LatLng point) { * Returns the center of the lat/lng bounds. * @return */ - public LatLng getCenter() { + @NonNull public LatLng getCenter() { double midLat = (this.southwest.getLatitude() + this.northeast.getLatitude()) / 2.0D; double neLng = this.northeast.getLongitude(); double swLng = this.southwest.getLongitude(); @@ -137,7 +138,7 @@ public static class Builder { * @param point * @return builder object */ - public Builder include(LatLng point) { + @NonNull public Builder include(@NonNull LatLng point) { if (northeastLat == 0) { northeastLat = point.getLatitude(); northeastLng = point.getLongitude(); @@ -161,7 +162,7 @@ public Builder include(LatLng point) { * Constructs a new {@link LatLngBounds} from current boundaries. * @return */ - public LatLngBounds build() { + @NonNull public LatLngBounds build() { LatLng sw = new LatLng(southwestLat, southwestLng); LatLng ne = new LatLng(northeastLat, northeastLng); return new LatLngBounds(sw, ne); diff --git a/mapzen-places-api/src/main/java/com/mapzen/places/api/Place.java b/mapzen-places-api/src/main/java/com/mapzen/places/api/Place.java index b1d23569..51daec66 100644 --- a/mapzen-places-api/src/main/java/com/mapzen/places/api/Place.java +++ b/mapzen-places-api/src/main/java/com/mapzen/places/api/Place.java @@ -2,6 +2,8 @@ import android.net.Uri; import android.os.Parcelable; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import java.util.List; import java.util.Locale; @@ -28,7 +30,7 @@ public interface Place extends Parcelable { * Returns human readable address for this place. * @return */ - abstract CharSequence getAddress(); + @NonNull CharSequence getAddress(); /** * Returns the attributions to be shown to the user if data from the Place is used. @@ -37,31 +39,31 @@ public interface Place extends Parcelable { * {@link UnsupportedOperationException} if accessed * @return */ - abstract CharSequence getAttributions(); + @Nullable CharSequence getAttributions(); /** * Returns the unique id of this Place. * @return */ - abstract String getId(); + @NonNull String getId(); /** * Returns the location of this Place. * @return */ - abstract LatLng getLatLng(); + @NonNull LatLng getLatLng(); /** * Returns the locale in which the names and addresses were localized. * @return */ - abstract Locale getLocale(); + @Nullable Locale getLocale(); /** * Returns the name of this Place. * @return */ - abstract CharSequence getName(); + @Nullable CharSequence getName(); /** * Returns the place's phone number in international format. @@ -70,13 +72,13 @@ public interface Place extends Parcelable { * {@link UnsupportedOperationException} if accessed * @return */ - abstract CharSequence getPhoneNumber(); + @Nullable CharSequence getPhoneNumber(); /** * Returns a list of place types for this Place. * @return */ - abstract List getPlaceTypes(); + @Nullable List getPlaceTypes(); /** * Returns the price level for this place on a scale from 0 (cheapest) to 4. @@ -85,7 +87,7 @@ public interface Place extends Parcelable { * {@link UnsupportedOperationException} if accessed * @return */ - abstract int getPriceLevel(); + int getPriceLevel(); /** * Returns the place's rating, from 1.0 to 5.0, based on aggregated user reviews. @@ -94,13 +96,13 @@ public interface Place extends Parcelable { * {@link UnsupportedOperationException} if accessed * @return */ - abstract float getRating(); + float getRating(); /** * Returns a viewport for displaying this Place. * @return */ - abstract LatLngBounds getViewport(); + @Nullable LatLngBounds getViewport(); /** * Returns website uri for this place. @@ -109,5 +111,5 @@ public interface Place extends Parcelable { * {@link UnsupportedOperationException} if accessed * @return */ - abstract Uri getWebsiteUri(); + @Nullable Uri getWebsiteUri(); } diff --git a/mapzen-places-api/src/main/java/com/mapzen/places/api/Places.java b/mapzen-places-api/src/main/java/com/mapzen/places/api/Places.java index 41cb2fed..c8dfc727 100644 --- a/mapzen-places-api/src/main/java/com/mapzen/places/api/Places.java +++ b/mapzen-places-api/src/main/java/com/mapzen/places/api/Places.java @@ -2,9 +2,11 @@ import com.mapzen.places.api.internal.GeoDataApiImpl; +import android.support.annotation.NonNull; + /** * Main entry point for Mapzen Places API. */ public class Places { - public static final GeoDataApi GeoDataApi = new GeoDataApiImpl(); + @NonNull public static final GeoDataApi GeoDataApi = new GeoDataApiImpl(); } diff --git a/mapzen-places-api/src/main/java/com/mapzen/places/api/ui/PlaceAutocomplete.java b/mapzen-places-api/src/main/java/com/mapzen/places/api/ui/PlaceAutocomplete.java index 4c7280a0..81614fdd 100644 --- a/mapzen-places-api/src/main/java/com/mapzen/places/api/ui/PlaceAutocomplete.java +++ b/mapzen-places-api/src/main/java/com/mapzen/places/api/ui/PlaceAutocomplete.java @@ -9,6 +9,8 @@ import android.app.Activity; import android.content.Context; import android.content.Intent; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import static com.mapzen.places.api.internal.PlaceIntentConsts.EXTRA_BOUNDS; import static com.mapzen.places.api.internal.PlaceIntentConsts.EXTRA_FILTER; @@ -31,7 +33,7 @@ public class PlaceAutocomplete { * @param intent * @return */ - public static Place getPlace(Context context, Intent intent) { + @Nullable public static Place getPlace(@Nullable Context context, @Nullable Intent intent) { if (intent == null) { return null; } @@ -44,7 +46,7 @@ public static Place getPlace(Context context, Intent intent) { * @param intent * @return */ - public static Status getStatus(Context context, Intent intent) { + @Nullable public static Status getStatus(@Nullable Context context, @Nullable Intent intent) { if (intent == null) { return null; } @@ -74,7 +76,7 @@ public IntentBuilder(int mode) { * @param activity * @return */ - public Intent build(Activity activity) { + @NonNull public Intent build(@NonNull Activity activity) { Intent intent = new Intent(activity, PlaceAutocompleteActivity.class); intent.putExtra(EXTRA_BOUNDS, bounds); intent.putExtra(EXTRA_FILTER, filter); @@ -90,7 +92,7 @@ public Intent build(Activity activity) { * @param latLngBounds * @return */ - public IntentBuilder setBoundsBias(LatLngBounds latLngBounds) { + @NonNull public IntentBuilder setBoundsBias(@Nullable LatLngBounds latLngBounds) { this.bounds = latLngBounds; return this; } @@ -100,7 +102,7 @@ public IntentBuilder setBoundsBias(LatLngBounds latLngBounds) { * @param filter * @return */ - public IntentBuilder setFilter(AutocompleteFilter filter) { + @NonNull public IntentBuilder setFilter(@Nullable AutocompleteFilter filter) { this.filter = filter; return this; } diff --git a/mapzen-places-api/src/main/java/com/mapzen/places/api/ui/PlaceAutocompleteFragment.java b/mapzen-places-api/src/main/java/com/mapzen/places/api/ui/PlaceAutocompleteFragment.java index 824d9590..0f54cb12 100644 --- a/mapzen-places-api/src/main/java/com/mapzen/places/api/ui/PlaceAutocompleteFragment.java +++ b/mapzen-places-api/src/main/java/com/mapzen/places/api/ui/PlaceAutocompleteFragment.java @@ -9,6 +9,7 @@ import android.app.Fragment; import android.content.Intent; import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.LayoutInflater; import android.view.View; @@ -24,15 +25,15 @@ public class PlaceAutocompleteFragment extends Fragment { private PlaceAutocompleteView autocompleteView; private PlaceSelectionListener listener; - @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { + @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, + @NonNull ViewGroup container, Bundle savedInstanceState) { autocompleteView = (PlaceAutocompleteView) inflater.inflate( R.layout.place_autocomplete_fragment, container, false); autocompleteView.setFragment(this); return autocompleteView; } - @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { + @Override public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { if (resultCode == RESULT_OK) { Place place = PlaceAutocomplete.getPlace(this.getActivity(), data); String address = null; @@ -46,7 +47,7 @@ public class PlaceAutocompleteFragment extends Fragment { } } - public void setPlaceSelectionListener(PlaceSelectionListener listener) { + public void setPlaceSelectionListener(@Nullable PlaceSelectionListener listener) { this.listener = listener; } @@ -57,7 +58,7 @@ public void setPlaceSelectionListener(PlaceSelectionListener listener) { * be limited by any bounds. * @param boundsBias */ - public void setBoundsBias(LatLngBounds boundsBias) { + public void setBoundsBias(@Nullable LatLngBounds boundsBias) { autocompleteView.setBoundsBias(boundsBias); } @@ -65,7 +66,7 @@ public void setBoundsBias(LatLngBounds boundsBias) { * Set the {@link PlaceAutocompleteView}'s filter. * @param filter */ - public void setFilter(AutocompleteFilter filter) { + public void setFilter(@Nullable AutocompleteFilter filter) { autocompleteView.setFilter(filter); } @@ -73,7 +74,7 @@ public void setFilter(AutocompleteFilter filter) { * Set the {@link PlaceAutocompleteView}'s hint. * @param hint */ - public void setHint(CharSequence hint) { + public void setHint(@Nullable CharSequence hint) { autocompleteView.setHint(hint); } @@ -81,7 +82,7 @@ public void setHint(CharSequence hint) { * Set the {@link PlaceAutocompleteView}'s text. * @param text */ - public void setText(CharSequence text) { + public void setText(@Nullable CharSequence text) { autocompleteView.setText(text); } } diff --git a/mapzen-places-api/src/main/java/com/mapzen/places/api/ui/PlacePicker.java b/mapzen-places-api/src/main/java/com/mapzen/places/api/ui/PlacePicker.java index 5be2c60b..c4b1f00a 100644 --- a/mapzen-places-api/src/main/java/com/mapzen/places/api/ui/PlacePicker.java +++ b/mapzen-places-api/src/main/java/com/mapzen/places/api/ui/PlacePicker.java @@ -7,6 +7,8 @@ import android.app.Activity; import android.content.Context; import android.content.Intent; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import static com.mapzen.places.api.internal.PlaceIntentConsts.EXTRA_BOUNDS; import static com.mapzen.places.api.internal.PlaceIntentConsts.EXTRA_PLACE; @@ -25,7 +27,7 @@ public class PlacePicker { * @param intent intent returned in {@link Activity#onActivityResult(int, int, Intent)} * @return */ - public static String getAttributions(Intent intent) { + @Nullable public static String getAttributions(@Nullable Intent intent) { if (intent == null) { return null; } @@ -41,7 +43,7 @@ public static String getAttributions(Intent intent) { * @param intent intent returned in {@link Activity#onActivityResult(int, int, Intent)} * @return */ - public static LatLngBounds getLatLngBounds(Intent intent) { + @Nullable public static LatLngBounds getLatLngBounds(@Nullable Intent intent) { if (intent == null) { return null; } @@ -55,7 +57,7 @@ public static LatLngBounds getLatLngBounds(Intent intent) { * @param intent intent returned in {@link Activity#onActivityResult(int, int, Intent)} * @return */ - public static Place getPlace(Context context, Intent intent) { + @Nullable public static Place getPlace(@Nullable Context context, @Nullable Intent intent) { if (intent == null) { return null; } @@ -74,7 +76,7 @@ public static class IntentBuilder { * @param activity * @return */ - public Intent build(Activity activity) { + @Nullable public Intent build(@NonNull Activity activity) { Intent intent = new Intent(activity, PlacePickerActivity.class); intent.putExtra(EXTRA_BOUNDS, bounds); return intent; @@ -86,7 +88,7 @@ public Intent build(Activity activity) { * @param latLngBounds * @return */ - public PlacePicker.IntentBuilder setLatLngBounds(LatLngBounds latLngBounds) { + @NonNull public PlacePicker.IntentBuilder setLatLngBounds(@Nullable LatLngBounds latLngBounds) { this.bounds = latLngBounds; return this; } diff --git a/mapzen-places-api/src/main/java/com/mapzen/places/api/ui/PlaceSelectionListener.java b/mapzen-places-api/src/main/java/com/mapzen/places/api/ui/PlaceSelectionListener.java index f80b3fdd..b5319afd 100644 --- a/mapzen-places-api/src/main/java/com/mapzen/places/api/ui/PlaceSelectionListener.java +++ b/mapzen-places-api/src/main/java/com/mapzen/places/api/ui/PlaceSelectionListener.java @@ -3,6 +3,8 @@ import com.mapzen.android.lost.api.Status; import com.mapzen.places.api.Place; +import android.support.annotation.NonNull; + /** * Interface for receiving information about a {@link Place} after it is selected from a * {@link PlaceAutocompleteFragment}. @@ -13,11 +15,11 @@ public interface PlaceSelectionListener { * Called when the user selects a {@link Place}. * @param place */ - void onPlaceSelected(Place place); + void onPlaceSelected(@NonNull Place place); /** * Called when an error occurs while trying to select a {@link Place}. * @param status */ - void onError(Status status); + void onError(@NonNull Status status); } diff --git a/samples/mapzen-sample/src/main/java/mapzen/com/sdksampleapp/fragments/RoutePinsFragment.kt b/samples/mapzen-sample/src/main/java/mapzen/com/sdksampleapp/fragments/RoutePinsFragment.kt index 9c6bbfd6..af90da63 100644 --- a/samples/mapzen-sample/src/main/java/mapzen/com/sdksampleapp/fragments/RoutePinsFragment.kt +++ b/samples/mapzen-sample/src/main/java/mapzen/com/sdksampleapp/fragments/RoutePinsFragment.kt @@ -41,6 +41,6 @@ class RoutePinsFragment : BaseFragment() { private fun addPin(x: Float, y: Float) { val lngLat = map?.screenPositionToLngLat(PointF(x, y)) val marker = lngLat?.let { Marker(it.longitude, it.latitude) } - map?.addMarker(marker) + marker?.let { map?.addMarker(it) } } } diff --git a/samples/mapzen-sample/src/main/java/mapzen/com/sdksampleapp/presenters/RoutingPresenterImpl.kt b/samples/mapzen-sample/src/main/java/mapzen/com/sdksampleapp/presenters/RoutingPresenterImpl.kt index 05d0e38a..32fcb555 100644 --- a/samples/mapzen-sample/src/main/java/mapzen/com/sdksampleapp/presenters/RoutingPresenterImpl.kt +++ b/samples/mapzen-sample/src/main/java/mapzen/com/sdksampleapp/presenters/RoutingPresenterImpl.kt @@ -69,7 +69,7 @@ class RoutingPresenterImpl(val router: MapzenRouter) : RoutingPresenter, RouteCa count++ val lngLat = controller?.getMapzenMap()?.screenPositionToLngLat(PointF(x, y)) val marker = lngLat?.let { Marker(it.longitude, it.latitude) } - controller?.getMapzenMap()?.addMarker(marker) + marker?.let { controller?.getMapzenMap()?.addMarker(it) } lngLat?.let { addToRouter(doubleArrayOf(it.latitude, it.longitude)) } getRoute() }