add compass drawable initialization in ui settings (#8695)

This commit is contained in:
Pablo Guardiola
2017-04-10 12:47:07 +02:00
committed by GitHub
parent 3172a9744f
commit df22b614af
2 changed files with 6 additions and 1 deletions

View File

@@ -14,6 +14,7 @@ import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.res.ResourcesCompat;
import android.util.AttributeSet;
import android.view.Gravity;
@@ -217,7 +218,7 @@ public class MapboxMapOptions implements Parcelable {
Drawable compassDrawable = typedArray.getDrawable(
R.styleable.mapbox_MapView_mapbox_uiCompassDrawable);
if (compassDrawable == null) {
compassDrawable = ContextCompat.getDrawable(context, R.drawable.mapbox_compass_icon);
compassDrawable = ResourcesCompat.getDrawable(context.getResources(), R.drawable.mapbox_compass_icon, null);
}
mapboxMapOptions.compassImage(compassDrawable);

View File

@@ -15,6 +15,7 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.UiThread;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.res.ResourcesCompat;
import android.view.Gravity;
import android.view.View;
import android.widget.FrameLayout;
@@ -149,6 +150,9 @@ public final class UiSettings {
setCompassMargins(tenDp, tenDp, tenDp, tenDp);
}
setCompassFadeFacingNorth(options.getCompassFadeFacingNorth());
if (options.getCompassImage() == null) {
options.compassImage(ResourcesCompat.getDrawable(resources, R.drawable.mapbox_compass_icon, null));
}
setCompassImage(options.getCompassImage());
}