diff options
author | Tobrun Van Nuland <tobrun.van.nuland@gmail.com> | 2016-07-22 16:16:59 +0200 |
---|---|---|
committer | Tobrun <tobrun.van.nuland@gmail.com> | 2016-07-24 09:43:49 +0200 |
commit | 82478e2ea74765f23bc2983cde515228b0badb0d (patch) | |
tree | b65917d215ed3510c4afad833f82335b3b4506ec /platform | |
parent | ea2ee649fab5852cfb630a944224d15b8eb677b6 (diff) | |
download | qtlocation-mapboxgl-82478e2ea74765f23bc2983cde515228b0badb0d.tar.gz |
[android] #5745 - allow selectMarker on MapboxMap to be called with a MarkerView
Diffstat (limited to 'platform')
2 files changed, 31 insertions, 3 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java index 44de157e6b..c9ced6546b 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java @@ -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(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java index c86a6fc4ec..a5558be883 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java @@ -1142,8 +1142,8 @@ public class MapboxMap { } if (!handledDefaultClick) { - if (marker instanceof MarkerView) { + mMarkerViewManager.select((MarkerView) marker, false); mMarkerViewManager.ensureInfoWindowOffset((MarkerView) marker); } |