Skip to content

Commit

Permalink
add nullability annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahsnow1 committed Dec 6, 2017
1 parent 61773e3 commit db83ba6
Show file tree
Hide file tree
Showing 46 changed files with 349 additions and 261 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.mapzen.android.core;

import android.support.annotation.NonNull;

/**
* Listener for handling changes to API key.
*/
Expand All @@ -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);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mapzen.android.core;

import android.os.Build;
import android.support.annotation.Nullable;

import java.util.Map;

Expand Down Expand Up @@ -75,11 +76,11 @@ enum LogLevel {
* Return query parameters to be appended to every request.
* @return
*/
Map<String, String> queryParamsForRequest();
@Nullable Map<String, String> queryParamsForRequest();

/**
* Return headers to be added to every request.
* @return
*/
Map<String, String> headersForRequest();
@Nullable Map<String, String> headersForRequest();
}
15 changes: 8 additions & 7 deletions core/src/main/java/com/mapzen/android/core/MapzenManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}
Expand All @@ -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,
Expand All @@ -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.");
Expand All @@ -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();
}
Expand All @@ -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;
}

Expand All @@ -102,15 +103,15 @@ public static String getSdkVersion() {
* occur.
* @param listener
*/
public void addApiKeyChangeListener(ApiKeyChangeListener listener) {
public void addApiKeyChangeListener(@NonNull ApiKeyChangeListener listener) {
Collections.synchronizedList(listeners).add(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);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -32,7 +34,7 @@ public enum DataLayerType {
* Returns the enum's name.
* @return
*/
public String toString() {
@NonNull public String toString() {
return name;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.mapzen.android.graphics;

import android.support.annotation.NonNull;

import java.util.Map;

/**
Expand All @@ -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<String, String> properties, float positionX, float positionY);
void onFeaturePick(@NonNull Map<String, String> properties, float positionX, float positionY);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.mapzen.tangram.LabelPickResult;

import android.support.annotation.NonNull;

/**
* Listener invoked when a label on the map is selected.
*/
Expand All @@ -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);
}
27 changes: 14 additions & 13 deletions core/src/main/java/com/mapzen/android/graphics/MapView.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private void initViews(Context context) {
/**
* Get the underlying Tangram map object.
*/
public TangramMapView getTangramMapView() {
@NonNull public TangramMapView getTangramMapView() {
return tangramMapView;
}

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

Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -234,7 +235,7 @@ public void hideZoomOut() {
/**
* Return the attribution text view.
*/
public TextView getAttribution() {
@NonNull public TextView getAttribution() {
return attribution;
}

Expand All @@ -250,7 +251,7 @@ public void onDestroy() {
getTangramMapView().onDestroy();
}

void setMapzenMap(MapzenMap mapzenMap) {
void setMapzenMap(@NonNull MapzenMap mapzenMap) {
this.mapzenMap = mapzenMap;
}
}
Loading

0 comments on commit db83ba6

Please sign in to comment.