From a980f725b88f1d6f05825dafff29dc6f422505d6 Mon Sep 17 00:00:00 2001 From: Tobrun Date: Fri, 11 Mar 2016 19:59:52 -0500 Subject: [android] #4252 - close concurrent window fix --- .../mapbox/mapboxsdk/annotations/InfoWindow.java | 27 +++++++++------------- 1 file changed, 11 insertions(+), 16 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 d8763e321d..c1fc9bb0ab 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,15 +4,14 @@ import android.content.res.Resources; import android.graphics.PointF; import android.support.annotation.LayoutRes; import android.view.LayoutInflater; -import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; -import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.R; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.maps.MapView; +import com.mapbox.mapboxsdk.maps.MapboxMap; import java.lang.ref.WeakReference; @@ -189,13 +188,21 @@ public class InfoWindow { * @return this info window */ InfoWindow close() { - if (mIsVisible) { + MapboxMap mapboxMap = mMapboxMap.get(); + if (mIsVisible && mapboxMap != null) { mIsVisible = false; View view = mView.get(); if (view != null && view.getParent() != null) { ((ViewGroup) view.getParent()).removeView(view); } - onClose(); + + Marker marker = getBoundMarker(); + MapboxMap.OnInfoWindowCloseListener listener = mapboxMap.getOnInfoWindowCloseListener(); + if (listener != null) { + listener.onInfoWindowClose(marker); + } + + setBoundMarker(null); } return this; } @@ -219,18 +226,6 @@ public class InfoWindow { ((TextView) view.findViewById(R.id.infowindow_description)).setText(snippet); } - private void onClose() { - MapboxMap mapboxMap = mMapboxMap.get(); - if (mapboxMap != null) { - MapboxMap.OnInfoWindowCloseListener listener = mapboxMap.getOnInfoWindowCloseListener(); - if (listener != null) { - listener.onInfoWindowClose(getBoundMarker()); - } - mapboxMap.deselectMarker(getBoundMarker()); - setBoundMarker(null); - } - } - InfoWindow setBoundMarker(Marker boundMarker) { mBoundMarker = new WeakReference<>(boundMarker); return this; -- cgit v1.2.1