diff options
author | Tobrun <tobrun.van.nuland@gmail.com> | 2016-10-13 17:04:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-13 17:04:02 +0200 |
commit | 1898df606dd6ca3c8badcaa40cb17c2bce307055 (patch) | |
tree | 5cdeb1dfef24b48c479869389693427593f4e8f1 | |
parent | b722d5c3a914fc1fe7552e1bec38da677d09e2a1 (diff) | |
download | qtlocation-mapboxgl-1898df606dd6ca3c8badcaa40cb17c2bce307055.tar.gz |
[android] - add transparent image for MarkerViews ghosting SymbolAnnotations (#6675)
* [android] - add transparent image to core for MarkerView ghosting SymbolAnnotations. Removes logging messages: `Can't find sprite ... `. Cleanup MapView.
* [android] - use alpha_8 config to only allocate one byte, rename id for better readability.
3 files changed, 16 insertions, 12 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/IconFactory.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/IconFactory.java index 93c6deddc9..56c1b643a1 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/IconFactory.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/IconFactory.java @@ -24,11 +24,14 @@ import java.io.InputStream; /** * Factory for creating {@link Icon} objects. + * * @see Icon */ public final class IconFactory { private static final String ICON_ID_PREFIX = "com.mapbox.icons.icon_"; + public static final Bitmap ICON_MARKERVIEW_BITMAP = Bitmap.createBitmap(1, 1, Bitmap.Config.ALPHA_8); + public static final String ICON_MARKERVIEW_ID = ICON_ID_PREFIX + "marker_view"; private Context mContext; private static IconFactory sInstance; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerView.java index b1008e290b..5c84fb9992 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerView.java @@ -1,6 +1,5 @@ package com.mapbox.mapboxsdk.annotations; -import android.graphics.Bitmap; import android.support.annotation.FloatRange; import android.support.annotation.Nullable; @@ -302,10 +301,10 @@ public class MarkerView extends Marker { @Override public void setIcon(@Nullable Icon icon) { if (icon != null) { - markerViewIcon = IconFactory.recreate("icon", icon.getBitmap()); + markerViewIcon = IconFactory.recreate(IconFactory.ICON_MARKERVIEW_ID, icon.getBitmap()); } - Bitmap bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888); - Icon transparentIcon = IconFactory.recreate("markerViewSettings", bitmap); + Icon transparentIcon = IconFactory.recreate(IconFactory.ICON_MARKERVIEW_ID, + IconFactory.ICON_MARKERVIEW_BITMAP); if (markerViewManager != null) { markerViewManager.updateIcon(this); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java index b7c195eb71..0455d96f3e 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java @@ -212,6 +212,9 @@ public class MapView extends FrameLayout { nativeMapView = new NativeMapView(this); + // load transparent icon for MarkerView to trace actual markers, see #6352 + loadIcon(IconFactory.recreate(IconFactory.ICON_MARKERVIEW_ID, IconFactory.ICON_MARKERVIEW_BITMAP)); + // Ensure this view is interactable setClickable(true); setLongClickable(true); @@ -219,7 +222,6 @@ public class MapView extends FrameLayout { setFocusableInTouchMode(true); requestFocus(); - // Touch gesture detectors gestureDetector = new GestureDetectorCompat(context, new GestureListener()); gestureDetector.setIsLongpressEnabled(true); @@ -289,10 +291,10 @@ public class MapView extends FrameLayout { // MyLocationView MyLocationViewSettings myLocationViewSettings = mapboxMap.getMyLocationViewSettings(); myLocationViewSettings.setForegroundDrawable( - options.getMyLocationForegroundDrawable(), options.getMyLocationForegroundBearingDrawable()); + options.getMyLocationForegroundDrawable(), options.getMyLocationForegroundBearingDrawable()); myLocationViewSettings.setForegroundTintColor(options.getMyLocationForegroundTintColor()); myLocationViewSettings.setBackgroundDrawable( - options.getMyLocationBackgroundDrawable(), options.getMyLocationBackgroundPadding()); + options.getMyLocationBackgroundDrawable(), options.getMyLocationBackgroundPadding()); myLocationViewSettings.setBackgroundTintColor(options.getMyLocationBackgroundTintColor()); myLocationViewSettings.setAccuracyAlpha(options.getMyLocationAccuracyAlpha()); myLocationViewSettings.setAccuracyTintColor(options.getMyLocationAccuracyTintColor()); @@ -353,7 +355,7 @@ public class MapView extends FrameLayout { int attributionTintColor = options.getAttributionTintColor(); uiSettings.setAttributionTintColor(attributionTintColor != -1 - ? attributionTintColor : ColorUtils.getPrimaryColor(getContext())); + ? attributionTintColor : ColorUtils.getPrimaryColor(getContext())); } // @@ -408,9 +410,9 @@ public class MapView extends FrameLayout { uiSettings.setCompassEnabled(savedInstanceState.getBoolean(MapboxConstants.STATE_COMPASS_ENABLED)); uiSettings.setCompassGravity(savedInstanceState.getInt(MapboxConstants.STATE_COMPASS_GRAVITY)); uiSettings.setCompassMargins(savedInstanceState.getInt(MapboxConstants.STATE_COMPASS_MARGIN_LEFT), - savedInstanceState.getInt(MapboxConstants.STATE_COMPASS_MARGIN_TOP), - savedInstanceState.getInt(MapboxConstants.STATE_COMPASS_MARGIN_RIGHT), - savedInstanceState.getInt(MapboxConstants.STATE_COMPASS_MARGIN_BOTTOM)); + savedInstanceState.getInt(MapboxConstants.STATE_COMPASS_MARGIN_TOP), + savedInstanceState.getInt(MapboxConstants.STATE_COMPASS_MARGIN_RIGHT), + savedInstanceState.getInt(MapboxConstants.STATE_COMPASS_MARGIN_BOTTOM)); // Logo uiSettings.setLogoEnabled(savedInstanceState.getBoolean(MapboxConstants.STATE_LOGO_ENABLED)); @@ -441,7 +443,7 @@ public class MapView extends FrameLayout { TrackingSettings trackingSettings = mapboxMap.getTrackingSettings(); //noinspection ResourceType trackingSettings.setMyLocationTrackingMode( - savedInstanceState.getInt(MapboxConstants.STATE_MY_LOCATION_TRACKING_MODE, MyLocationTracking.TRACKING_NONE)); + savedInstanceState.getInt(MapboxConstants.STATE_MY_LOCATION_TRACKING_MODE, MyLocationTracking.TRACKING_NONE)); //noinspection ResourceType trackingSettings.setMyBearingTrackingMode( savedInstanceState.getInt(MapboxConstants.STATE_MY_BEARING_TRACKING_MODE, MyBearingTracking.NONE)); |