diff options
author | Tobrun Van Nuland <tobrun.van.nuland@gmail.com> | 2016-06-03 14:29:20 +0200 |
---|---|---|
committer | Tobrun <tobrun.van.nuland@gmail.com> | 2016-06-05 14:23:24 +0200 |
commit | 436c23c40b37c4863ddfbc25c6463ae2f2767a06 (patch) | |
tree | f5f78cd7d9deaaa8e16be10a8480e73f5f93b977 /platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps | |
parent | 4094987fa09561c4c69b1b4cf8a6cbf9d3dd0433 (diff) | |
download | qtlocation-mapboxgl-436c23c40b37c4863ddfbc25c6463ae2f2767a06.tar.gz |
[android] #5171 - introduce new select/deselect animation system for view markers
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps')
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java | 67 |
1 files changed, 61 insertions, 6 deletions
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 81b56cbd4c..bc0924c4f3 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 @@ -951,7 +951,7 @@ public class MapboxMap { Marker marker = (Marker) annotation; marker.hideInfoWindow(); if (marker instanceof MarkerView) { - mMarkerViewManager.removeMarkerView((MarkerView) marker, true); + mMarkerViewManager.removeMarkerView((MarkerView) marker); } } long id = annotation.getId(); @@ -985,7 +985,7 @@ public class MapboxMap { Marker marker = (Marker) annotation; marker.hideInfoWindow(); if (marker instanceof MarkerView) { - mMarkerViewManager.removeMarkerView((MarkerView) marker, true); + mMarkerViewManager.removeMarkerView((MarkerView) marker); } } ids[i] = annotationList.get(i).getId(); @@ -1011,7 +1011,7 @@ public class MapboxMap { Marker marker = (Marker) annotation; marker.hideInfoWindow(); if (marker instanceof MarkerView) { - mMarkerViewManager.removeMarkerView((MarkerView) marker, true); + mMarkerViewManager.removeMarkerView((MarkerView) marker); } } } @@ -1841,11 +1841,56 @@ public class MapboxMap { public abstract View getView(@NonNull U marker, @NonNull View convertView, @NonNull ViewGroup parent); /** + * Called when an MarkerView is removed from the MapView or the View object is going to be reused. + * <p> + * <p> + * This method should be used to reset an animated view back to it's original state for view reuse. + * </p> + * <p> + * Returning true indicates you want to the view reuse to be handled automatically. + * Returning false indicates you want to perform an animation and you are required calling {@link #releaseView(View)} yourself. + * </p> + * + * @param marker the model representing the MarkerView + * @param convertView the reusable view + * @return true if you want reuse to occur automatically, false if you want to manage this yourself. + */ + public boolean prepareViewForReuse(@NonNull MarkerView marker, @NonNull View convertView) { + return true; + } + + /** + * Called when a MarkerView is selected from the MapView. + * <p> + * Returning true from this method indicates you want to move the MarkerView to the selected state. + * Returning false indicates you want to animate the View first an manually select the MarkerView when appropriate. + * </p> + * + * @param marker the model representing the MarkerView + * @param convertView the reusable view + * @param reselectionFromRecycling indicates if the onSelect callback is the initial selection + * callback or that selection occurs due to recreation of selected marker + * @return true if you want to select the Marker immediately, false if you want to manage this yourself. + */ + public boolean onSelect(@NonNull U marker, @NonNull View convertView, boolean reselectionFromRecycling) { + return true; + } + + /** + * Called when a MarkerView is deselected from the MapView. + * + * @param marker the model representing the MarkerView + * @param convertView the reusable view + */ + public void onDeselect(@NonNull U marker, @NonNull View convertView) { + } + + /** * Returns the generic type of the used MarkerView. * * @return the generic type */ - public Class<U> getMarkerClass() { + public final Class<U> getMarkerClass() { return persistentClass; } @@ -1854,7 +1899,7 @@ public class MapboxMap { * * @return the pool associated to this adapter */ - public Pools.SimplePool<View> getViewReusePool() { + public final Pools.SimplePool<View> getViewReusePool() { return mViewReusePool; } @@ -1863,9 +1908,19 @@ public class MapboxMap { * * @return the context used */ - public Context getContext() { + public final Context getContext() { return context; } + + /** + * Release a View to the ViewPool. + * + * @param view the view to be released + */ + public final void releaseView(View view) { + view.setVisibility(View.GONE); + mViewReusePool.release(view); + } } /** |