summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobrun <tobrun.van.nuland@gmail.com>2016-03-11 19:59:52 -0500
committerTobrun <tobrun.van.nuland@gmail.com>2016-03-11 22:29:48 -0500
commita980f725b88f1d6f05825dafff29dc6f422505d6 (patch)
tree4492041d0270482e64802ef458f6f8112588d31a
parent45e6ee13728b3006a38097d64bfac54b38b4ef35 (diff)
downloadqtlocation-mapboxgl-a980f725b88f1d6f05825dafff29dc6f422505d6.tar.gz
[android] #4252 - close concurrent window fix
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java27
1 files 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;