From 6efc7627907ac3fb71951a515aace7c6e0ef65d2 Mon Sep 17 00:00:00 2001 From: Tobias Zwick Date: Mon, 9 Oct 2017 19:01:09 +0200 Subject: [PATCH] Fully initialize each marker before setting the fields (follow-up of #638) --- .../streetcomplete/tangram/MapFragment.java | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/tangram/MapFragment.java b/app/src/main/java/de/westnordost/streetcomplete/tangram/MapFragment.java index a405106a3d..524670118c 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/tangram/MapFragment.java +++ b/app/src/main/java/de/westnordost/streetcomplete/tangram/MapFragment.java @@ -145,22 +145,38 @@ public void getMapAsync(String apiKey) private void initMarkers() { - locationMarker = controller.addMarker(); + locationMarker = createLocationMarker(3); + directionMarker = createDirectionMarker(2); + accuracyMarker = createAccuracyMarker(1); + } + + private Marker createLocationMarker(int order) + { + Marker marker = controller.addMarker(); BitmapDrawable dot = createBitmapDrawableFrom(R.drawable.location_dot); - locationMarker.setStylingFromString("{ style: 'points', color: 'white', size: ["+TextUtils.join(",",sizeInDp(dot))+"], order: 2000, flat: true, collide: false }"); - locationMarker.setDrawable(dot); - locationMarker.setDrawOrder(3); + marker.setStylingFromString("{ style: 'points', color: 'white', size: ["+TextUtils.join(",",sizeInDp(dot))+"], order: 2000, flat: true, collide: false }"); + marker.setDrawable(dot); + marker.setDrawOrder(order); + return marker; + } + private Marker createDirectionMarker(int order) + { BitmapDrawable directionImg = createBitmapDrawableFrom(R.drawable.location_direction); directionMarkerSize = sizeInDp(directionImg); - directionMarker = controller.addMarker(); - directionMarker.setDrawable(directionImg); - directionMarker.setDrawOrder(2); + Marker marker = controller.addMarker(); + marker.setDrawable(directionImg); + marker.setDrawOrder(order); + return marker; + } - accuracyMarker = controller.addMarker(); - accuracyMarker.setDrawable(createBitmapDrawableFrom(R.drawable.accuracy_circle)); - accuracyMarker.setDrawOrder(1); + private Marker createAccuracyMarker(int order) + { + Marker marker = controller.addMarker(); + marker.setDrawable(createBitmapDrawableFrom(R.drawable.accuracy_circle)); + marker.setDrawOrder(order); + return marker; } private String[] sizeInDp(Drawable drawable)