From de5357c95f1158d610a958bb0d40029fc73629d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Paczos?= Date: Tue, 19 Dec 2017 16:59:02 +0100 Subject: Saving/restoring MyLocationViewSettings (#10746) [android] saving/restoring MyLocationViewSettings, updated BitmapUtils --- .../mapbox/mapboxsdk/maps/MapboxMapOptions.java | 23 +++++----------------- 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java') diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java index 48c83628d6..2719d7f016 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java @@ -3,7 +3,6 @@ package com.mapbox.mapboxsdk.maps; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Bitmap; -import android.graphics.Canvas; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.os.Parcel; @@ -20,6 +19,7 @@ import android.view.Gravity; import com.mapbox.mapboxsdk.R; import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.constants.MapboxConstants; +import com.mapbox.mapboxsdk.utils.BitmapUtils; import com.mapbox.mapboxsdk.utils.ColorUtils; import java.util.Arrays; @@ -161,19 +161,6 @@ public class MapboxMapOptions implements Parcelable { localIdeographFontFamily = in.readString(); } - static Bitmap getBitmapFromDrawable(Drawable drawable) { - if (drawable instanceof BitmapDrawable) { - return ((BitmapDrawable) drawable).getBitmap(); - } else { - Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), - Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(bitmap); - drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); - drawable.draw(canvas); - return bitmap; - } - } - /** * Creates a MapboxMapsOptions from the attribute set.s * @@ -1130,7 +1117,7 @@ public class MapboxMapOptions implements Parcelable { dest.writeIntArray(compassMargins); dest.writeByte((byte) (fadeCompassFacingNorth ? 1 : 0)); dest.writeParcelable(compassImage != null - ? getBitmapFromDrawable(compassImage) : null, flags); + ? BitmapUtils.getBitmapFromDrawable(compassImage) : null, flags); dest.writeByte((byte) (logoEnabled ? 1 : 0)); dest.writeInt(logoGravity); @@ -1154,11 +1141,11 @@ public class MapboxMapOptions implements Parcelable { dest.writeByte((byte) (myLocationEnabled ? 1 : 0)); dest.writeParcelable(myLocationForegroundDrawable != null - ? getBitmapFromDrawable(myLocationForegroundDrawable) : null, flags); + ? BitmapUtils.getBitmapFromDrawable(myLocationForegroundDrawable) : null, flags); dest.writeParcelable(myLocationForegroundBearingDrawable != null - ? getBitmapFromDrawable(myLocationForegroundBearingDrawable) : null, flags); + ? BitmapUtils.getBitmapFromDrawable(myLocationForegroundBearingDrawable) : null, flags); dest.writeParcelable(myLocationBackgroundDrawable != null - ? getBitmapFromDrawable(myLocationBackgroundDrawable) : null, flags); + ? BitmapUtils.getBitmapFromDrawable(myLocationBackgroundDrawable) : null, flags); dest.writeInt(myLocationForegroundTintColor); dest.writeInt(myLocationBackgroundTintColor); dest.writeIntArray(myLocationBackgroundPadding); -- cgit v1.2.1