From 1d66eda14b221496d9bf687e45e37f704f0778c7 Mon Sep 17 00:00:00 2001 From: Tobrun Date: Mon, 29 Aug 2016 13:43:22 +0200 Subject: [android] #5875 - MapboxMap options not parceling drawables (#5984) * [android] #5875 - MapboxMap options not parceling the MyLocationView drawables * [android] #5875 - disabled parceable test for bitmaps * [android] #5876 - correct restoration of bitmapdrawable for unit test * disable check for drawable type --- .../com/mapbox/mapboxsdk/maps/MapFragment.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapFragment.java') diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapFragment.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapFragment.java index 27ecb7520b..d321c3ec59 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapFragment.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapFragment.java @@ -4,14 +4,18 @@ import android.app.Fragment; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; +import android.graphics.drawable.Drawable; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.v4.content.ContextCompat; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; + import com.mapbox.mapboxsdk.MapboxAccountManager; +import com.mapbox.mapboxsdk.R; import com.mapbox.mapboxsdk.constants.MapboxConstants; import com.mapbox.mapboxsdk.exceptions.InvalidAccessTokenException; @@ -59,6 +63,7 @@ public final class MapFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); + Context context = inflater.getContext(); MapboxMapOptions options = null; // Get bundle @@ -84,6 +89,23 @@ public final class MapFragment extends Fragment { options.accessToken(token); } } + + Drawable foregroundDrawable = options.getMyLocationForegroundDrawable(); + Drawable foregroundBearingDrawable = options.getMyLocationForegroundBearingDrawable(); + if (foregroundDrawable == null || foregroundBearingDrawable == null) { + if (foregroundDrawable == null) { + foregroundDrawable = ContextCompat.getDrawable(context, R.drawable.ic_mylocationview_normal); + } + if (foregroundBearingDrawable == null) { + foregroundBearingDrawable = ContextCompat.getDrawable(context, R.drawable.ic_mylocationview_bearing); + } + options.myLocationForegroundDrawables(foregroundDrawable, foregroundBearingDrawable); + } + + if (options.getMyLocationBackgroundDrawable() == null) { + options.myLocationBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.ic_mylocationview_background)); + } + return mMap = new MapView(inflater.getContext(), options); } -- cgit v1.2.1