diff --git a/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/MainActivity.java b/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/MainActivity.java index ffef7a4dca..7b9ae80fbf 100644 --- a/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/MainActivity.java +++ b/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/MainActivity.java @@ -341,7 +341,8 @@ public class MainActivity extends AppCompatActivity implements SampleLocationLis public void initMapMarkers() { // Create my location marker - Drawable myLocationDrawable = OsmandResources.getDrawable("map_pedestrian_location"); + String locIconId = "map_pedestrian_location"; + Drawable myLocationDrawable = OsmandResources.getDrawable(locIconId); myMarkersCollection = new MapMarkersCollection(); myLocationMarker = new MapMarkerBuilder() .setMarkerId(MARKER_ID_MY_LOCATION) @@ -354,13 +355,14 @@ public class MainActivity extends AppCompatActivity implements SampleLocationLis // SampleUtils.getDrawableAsByteArray(myLocationDrawable))) .setPinIcon(SwigUtilities.createSkBitmapARGB888With( myLocationDrawable.getIntrinsicWidth(), myLocationDrawable.getIntrinsicHeight(), - SampleUtils.getDrawableAsByteArray(myLocationDrawable))) + SampleUtils.getBitmapAsByteArray(OsmandResources.getBitmap(locIconId)))) .buildAndAddToCollection(myMarkersCollection); mapView.addSymbolsProvider(myMarkersCollection); // Create context pin marker - Drawable pinDrawable = OsmandResources.getDrawable("map_pin_context_menu"); + String pinIconId = "map_pin_context_menu"; + Drawable pinDrawable = OsmandResources.getDrawable(pinIconId); contextPinMarkersCollection = new MapMarkersCollection(); contextPinMarker = new MapMarkerBuilder() .setMarkerId(MARKER_ID_CONTEXT_PIN) @@ -369,7 +371,7 @@ public class MainActivity extends AppCompatActivity implements SampleLocationLis .setIsHidden(true) .setPinIcon(SwigUtilities.createSkBitmapARGB888With( pinDrawable.getIntrinsicWidth(), pinDrawable.getIntrinsicHeight(), - SampleUtils.getDrawableAsByteArray(pinDrawable))) + SampleUtils.getBitmapAsByteArray(OsmandResources.getBitmap(pinIconId)))) .setPinIconVerticalAlignment(MapMarker.PinIconVerticalAlignment.Top) .setPinIconHorisontalAlignment(MapMarker.PinIconHorisontalAlignment.CenterHorizontal) .buildAndAddToCollection(contextPinMarkersCollection); diff --git a/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/OsmandResources.java b/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/OsmandResources.java index dc1c2cf9c3..7e04e93d15 100644 --- a/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/OsmandResources.java +++ b/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/OsmandResources.java @@ -3,6 +3,8 @@ package net.osmand.core.samples.android.sample1; import android.content.Context; import android.content.pm.PackageManager; import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.graphics.drawable.Drawable; import android.support.v4.graphics.drawable.DrawableCompat; @@ -78,6 +80,13 @@ public class OsmandResources { return getDrawableInternal(id); } + public static Bitmap getBitmap(String id) { + if (osmandResources != null) { + return BitmapFactory.decodeResource(osmandResources, resolveDrawableId(id)); + } + return null; + } + public static Drawable getDrawableNonCached(int id) { if (osmandResources != null && id != 0) { Drawable d = osmandResources.getDrawable(id);