diff options
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java')
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java index f81922097e..66cd934d8d 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java @@ -4,6 +4,8 @@ import android.content.res.Resources; import android.graphics.PointF; import android.os.Build; import android.support.annotation.LayoutRes; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; @@ -53,11 +55,11 @@ public class InfoWindow { initialize(view, mapboxMap); } - InfoWindow(View view, MapboxMap mapboxMap) { + InfoWindow(@NonNull View view, MapboxMap mapboxMap) { initialize(view, mapboxMap); } - private void initialize(View view, MapboxMap mapboxMap) { + private void initialize(@NonNull View view, MapboxMap mapboxMap) { this.mapboxMap = new WeakReference<>(mapboxMap); isVisible = false; this.view = new WeakReference<>(view); @@ -116,7 +118,8 @@ public class InfoWindow { * the view from the object position. * @return this {@link InfoWindow}. */ - InfoWindow open(MapView mapView, Marker boundMarker, LatLng position, int offsetX, int offsetY) { + @NonNull + InfoWindow open(@NonNull MapView mapView, Marker boundMarker, @NonNull LatLng position, int offsetX, int offsetY) { setBoundMarker(boundMarker); MapView.LayoutParams lp = new MapView.LayoutParams(MapView.LayoutParams.WRAP_CONTENT, @@ -213,6 +216,7 @@ public class InfoWindow { * * @return This {@link InfoWindow} */ + @NonNull InfoWindow close() { MapboxMap mapboxMap = this.mapboxMap.get(); if (isVisible && mapboxMap != null) { @@ -239,7 +243,7 @@ public class InfoWindow { * * @param overlayItem the tapped overlay item */ - void adaptDefaultMarker(Marker overlayItem, MapboxMap mapboxMap, MapView mapView) { + void adaptDefaultMarker(@NonNull Marker overlayItem, MapboxMap mapboxMap, @NonNull MapView mapView) { View view = this.view.get(); if (view == null) { view = LayoutInflater.from(mapView.getContext()).inflate(layoutRes, mapView, false); @@ -265,11 +269,13 @@ public class InfoWindow { } } + @NonNull InfoWindow setBoundMarker(Marker boundMarker) { this.boundMarker = new WeakReference<>(boundMarker); return this; } + @Nullable Marker getBoundMarker() { if (boundMarker == null) { return null; @@ -307,6 +313,7 @@ public class InfoWindow { } } + @Nullable private final ViewTreeObserver.OnGlobalLayoutListener contentUpdateListener = new ViewTreeObserver.OnGlobalLayoutListener() { @Override @@ -329,6 +336,7 @@ public class InfoWindow { * * @return This {@link InfoWindow}'s current View. */ + @Nullable public View getView() { return view != null ? view.get() : null; } |