[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.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user