[android] #4252 - close concurrent window fix

This commit is contained in:
Tobrun
2016-03-11 19:59:52 -05:00
parent 45e6ee1372
commit a980f725b8

View File

@@ -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;