diff options
author | Tobrun <tobrun.van.nuland@gmail.com> | 2016-08-29 13:31:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-29 13:31:17 +0200 |
commit | 7af5542226e908989f2ded7eab46d4b09ec22f18 (patch) | |
tree | 925d81945d802ac7ba0a84cdc0a1b355b598ccbf /platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations | |
parent | ed431c925c425eb9f4cfa1793255238a5708f468 (diff) | |
download | qtlocation-mapboxgl-7af5542226e908989f2ded7eab46d4b09ec22f18.tar.gz |
[android] Anchoring was only set once while it was still unmeasured. There are times that a view is still unmeasured even after a measure call. We need to validate again before setting the offset. (#6154)
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 | 11 |
1 files changed, 7 insertions, 4 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 9631bc4ca8..eb6d6d6647 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 @@ -12,6 +12,7 @@ import android.view.ViewGroup; import android.widget.ImageView; import com.mapbox.mapboxsdk.R; +import com.mapbox.mapboxsdk.constants.MapboxConstants; import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.Projection; @@ -115,14 +116,16 @@ public class MarkerViewManager { final View convertView = markerViewMap.get(marker); if (convertView != null) { PointF point = mapboxMap.getProjection().toScreenLocation(marker.getPosition()); - if (marker.getOffsetX() == -1) { + if (marker.getOffsetX() == MapboxConstants.UNMEASURED) { // ensure view is measured first if (convertView.getMeasuredWidth() == 0) { convertView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); } - int x = (int) (marker.getAnchorU() * convertView.getMeasuredWidth()); - int y = (int) (marker.getAnchorV() * convertView.getMeasuredHeight()); - marker.setOffset(x, y); + if (convertView.getMeasuredWidth() != 0) { + int x = (int) (marker.getAnchorU() * convertView.getMeasuredWidth()); + int y = (int) (marker.getAnchorV() * convertView.getMeasuredHeight()); + marker.setOffset(x, y); + } } convertView.setX(point.x - marker.getOffsetX()); |