diff options
author | Tobrun <tobrun.van.nuland@gmail.com> | 2016-12-06 13:46:49 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-06 13:46:49 +0100 |
commit | 9a9e7978db67276cfaab97e00f2b56eeb0222b12 (patch) | |
tree | 0da54e64117a64195ee46060e01d270a86c1e45d /platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations | |
parent | 890b681b182f7d538237604307da487f3619d1b1 (diff) | |
download | qtlocation-mapboxgl-9a9e7978db67276cfaab97e00f2b56eeb0222b12.tar.gz |
[android] - Refactor dependencies, introduce focused components (#7189)
* [android] - refactor dependencies
* ignore tests
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations')
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java | 43 |
1 files changed, 26 insertions, 17 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 1073818ca4..ce2d3d1577 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 @@ -9,6 +9,7 @@ import android.support.annotation.Nullable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.FrameLayout; import android.widget.ImageView; import com.mapbox.mapboxsdk.R; @@ -31,27 +32,31 @@ import java.util.Map; */ public class MarkerViewManager { - private Map<MarkerView, View> markerViewMap; + private final ViewGroup markerViewContainer; + private final Map<MarkerView, View> markerViewMap = new HashMap<>(); + private final List<MapboxMap.MarkerViewAdapter> markerViewAdapters = new ArrayList<>(); + + // TODO refactor MapboxMap out for Projection and Transform + // Requires removing MapboxMap from Annotations by using Peer model from #6912 private MapboxMap mapboxMap; - private MapView mapView; - private List<MapboxMap.MarkerViewAdapter> markerViewAdapters; + private long viewMarkerBoundsUpdateTime; private MapboxMap.OnMarkerViewClickListener onMarkerViewClickListener; - private ImageMarkerViewAdapter defaultMarkerViewAdapter; /** * Creates an instance of MarkerViewManager. * - * @param mapboxMap the MapboxMap associated with the MarkerViewManager - * @param mapView the MapView associated with the MarkerViewManager + * @param container the ViewGroup associated with the MarkerViewManager */ - public MarkerViewManager(@NonNull MapboxMap mapboxMap, @NonNull MapView mapView) { + public MarkerViewManager(@NonNull ViewGroup container) { + this.markerViewContainer = container; + this.markerViewAdapters.add(new ImageMarkerViewAdapter(container.getContext())); + } + + // TODO refactor MapboxMap out for Projection and Transform + // Requires removing MapboxMap from Annotations by using Peer model from #6912 + public void bind(MapboxMap mapboxMap){ this.mapboxMap = mapboxMap; - this.markerViewAdapters = new ArrayList<>(); - this.mapView = mapView; - this.markerViewMap = new HashMap<>(); - this.defaultMarkerViewAdapter = new ImageMarkerViewAdapter(mapView.getContext()); - this.markerViewAdapters.add(defaultMarkerViewAdapter); } /** @@ -415,7 +420,7 @@ public class MarkerViewManager { * </p> */ public void invalidateViewMarkersInVisibleRegion() { - RectF mapViewRect = new RectF(0, 0, mapView.getWidth(), mapView.getHeight()); + RectF mapViewRect = new RectF(0, 0, markerViewContainer.getWidth(), markerViewContainer.getHeight()); List<MarkerView> markers = mapboxMap.getMarkerViewsInRect(mapViewRect); View convertView; @@ -445,7 +450,7 @@ public class MarkerViewManager { // Inflate View convertView = (View) adapter.getViewReusePool().acquire(); - final View adaptedView = adapter.getView(marker, convertView, mapView); + final View adaptedView = adapter.getView(marker, convertView, markerViewContainer); if (adaptedView != null) { adaptedView.setRotationX(marker.getTilt()); adaptedView.setRotation(marker.getRotation()); @@ -464,7 +469,7 @@ public class MarkerViewManager { markerViewMap.put(marker, adaptedView); if (convertView == null) { adaptedView.setVisibility(View.GONE); - mapView.getMarkerViewContainer().addView(adaptedView); + markerViewContainer.addView(adaptedView); } } } @@ -515,7 +520,7 @@ public class MarkerViewManager { for (final MapboxMap.MarkerViewAdapter adapter : markerViewAdapters) { if (adapter.getMarkerClass().equals(marker.getClass())) { View convertView = (View) adapter.getViewReusePool().acquire(); - view = adapter.getView(marker, convertView, mapView); + view = adapter.getView(marker, convertView, markerViewContainer); break; } } @@ -523,7 +528,7 @@ public class MarkerViewManager { if (view != null) { if (marker.getWidth() == 0) { - if(view.getMeasuredWidth()==0) { + if (view.getMeasuredWidth() == 0) { //Ensure the marker's view is measured first view.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); } @@ -546,6 +551,10 @@ public class MarkerViewManager { } } + public ViewGroup getMarkerViewContainer() { + return markerViewContainer; + } + /** * Default MarkerViewAdapter used for base class of {@link MarkerView} to adapt a MarkerView to * an ImageView. |