[android] #5745 - allow selectMarker on MapboxMap to be called with a MarkerView

This commit is contained in:
Tobrun Van Nuland
2016-07-22 16:16:59 +02:00
committed by Tobrun
parent ea2ee649fa
commit 82478e2ea7
2 changed files with 31 additions and 3 deletions

View File

@@ -191,10 +191,20 @@ public class MarkerViewManager {
* @param marker the MarkerView object to select
*/
public void select(@NonNull MarkerView marker) {
select(marker, true);
}
/**
* Animate a MarkerView to a selected state.
*
* @param marker the MarkerView object to select
* @param callbackToMap indicates if select marker must be called on MapboxMap
*/
public void select(@NonNull MarkerView marker, boolean callbackToMap) {
final View convertView = markerViewMap.get(marker);
for (MapboxMap.MarkerViewAdapter adapter : markerViewAdapters) {
if (adapter.getMarkerClass().equals(marker.getClass())) {
select(marker, convertView, adapter);
select(marker, convertView, adapter, callbackToMap);
}
}
}
@@ -210,9 +220,27 @@ public class MarkerViewManager {
* @param adapter the adapter used to adapt the marker to the convertView
*/
public void select(@NonNull MarkerView marker, View convertView, MapboxMap.MarkerViewAdapter adapter) {
select(marker, convertView, adapter, true);
}
/**
* Animate a MarkerView to a selected state.
* <p>
* The {@link com.mapbox.mapboxsdk.maps.MapboxMap.MarkerViewAdapter#onSelect(MarkerView, View, boolean)} will be called to execute an animation.
* </p>
*
* @param marker the MarkerView object to select
* @param convertView the View presentation of the MarkerView
* @param adapter the adapter used to adapt the marker to the convertView
* @param callbackToMap indicates if select marker must be called on MapboxMap
*/
public void select(@NonNull MarkerView marker, View convertView, MapboxMap.MarkerViewAdapter adapter, boolean callbackToMap) {
if (convertView != null) {
if (adapter.onSelect(marker, convertView, false)) {
mapboxMap.selectMarker(marker);
if (callbackToMap) {
mapboxMap.selectMarker(marker);
}
}
marker.setSelected(true);
convertView.bringToFront();

View File

@@ -1142,8 +1142,8 @@ public class MapboxMap {
}
if (!handledDefaultClick) {
if (marker instanceof MarkerView) {
mMarkerViewManager.select((MarkerView) marker, false);
mMarkerViewManager.ensureInfoWindowOffset((MarkerView) marker);
}