diff options
author | Tobrun <tobrun@mapbox.com> | 2016-01-15 13:14:13 +0100 |
---|---|---|
committer | Tobrun <tobrun@mapbox.com> | 2016-01-15 13:14:13 +0100 |
commit | 2631f5bf9358e386286129f984beda90c1b9010e (patch) | |
tree | 45155e206f21501cf7a3131ef6117b2f4333da40 /platform | |
parent | e22b0270f486cbece252f7faec55cd927403200d (diff) | |
download | qtlocation-mapboxgl-2631f5bf9358e386286129f984beda90c1b9010e.tar.gz |
[android] #3517 - recreating InfoWindow with correct MapView instance
Diffstat (limited to 'platform')
3 files changed, 10 insertions, 12 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 c74cf478d1..65f89c48e3 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 @@ -194,9 +194,11 @@ public class InfoWindow { * * @param overlayItem the tapped overlay item */ - void adaptDefaultMarker(Marker overlayItem) { + void adaptDefaultMarker(Marker overlayItem, MapView mapView) { View view = mView.get(); if (view != null) { + mMapView = new WeakReference<>(mapView); + overlayItem.setMapView(mapView); String title = overlayItem.getTitle(); ((TextView) view.findViewById(mTitleId /*R.id.title*/)).setText(title); String snippet = overlayItem.getSnippet(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Marker.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Marker.java index 8978d4be48..9482afaa26 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Marker.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Marker.java @@ -1,5 +1,6 @@ package com.mapbox.mapboxsdk.annotations; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; @@ -84,11 +85,8 @@ public final class Marker extends Annotation { /** * Do not use this method. Used internally by the SDK. */ - public InfoWindow showInfoWindow() { - if (getMapView() == null) { - return null; - } - + public InfoWindow showInfoWindow(@NonNull MapView mapView) { + setMapView(mapView); MapView.InfoWindowAdapter infoWindowAdapter = getMapView().getInfoWindowAdapter(); if (infoWindowAdapter != null) { // end developer is using a custom InfoWindowAdapter @@ -100,7 +98,7 @@ public final class Marker extends Annotation { } } - getInfoWindow().adaptDefaultMarker(this); + getInfoWindow().adaptDefaultMarker(this, mapView); return showInfoWindow(getInfoWindow()); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java index af81130474..c475eccf1e 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java @@ -2705,7 +2705,7 @@ public final class MapView extends FrameLayout { if (!handledDefaultClick) { if (isInfoWindowValidForMarker(marker)) { - mInfoWindows.add(marker.showInfoWindow()); + mInfoWindows.add(marker.showInfoWindow(this)); } } @@ -2888,10 +2888,8 @@ public final class MapView extends FrameLayout { for (Marker marker : mSelectedMarkers) { if (marker.isInfoWindowShown()) { - Marker temp = marker; - temp.hideInfoWindow(); - temp.showInfoWindow(); - marker = temp; + marker.hideInfoWindow(); + marker.showInfoWindow(this); } } } |