[android] #3517 - recreating InfoWindow with correct MapView instance
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user