Skip to content

Commit

Permalink
fix vector drawables for < api 21 using app compat resources instead …
Browse files Browse the repository at this point in the history
…of context compat app to get drawables
  • Loading branch information
danesfeder authored and Guardiola31337 committed Jun 29, 2018
1 parent a15d644 commit 96b8578
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatDelegate;
import android.support.v7.content.res.AppCompatResources;
import android.util.AttributeSet;
import android.util.TypedValue;

Expand Down Expand Up @@ -60,14 +61,14 @@ public static Icon retrieveThemeMapMarker(Context context) {
public static Drawable retrieveThemeOverviewDrawable(Context context) {
TypedValue destinationMarkerResId = resolveAttributeFromId(context, R.attr.navigationViewRouteOverviewDrawable);
int overviewResId = destinationMarkerResId.resourceId;
return ContextCompat.getDrawable(context, overviewResId);
return AppCompatResources.getDrawable(context, overviewResId);
}

/**
* Looks are current theme and retrieves the style
* for the given resId set in the theme.
*
* @param context to retrieve the resolved attribute
* @param context to retrieve the resolved attribute
* @param styleResId for the given style
* @return resolved style resource Id
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.mapbox.services.android.navigation.ui.v5.feedback;

import android.support.v4.content.ContextCompat;
import android.support.v7.content.res.AppCompatResources;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
Expand All @@ -22,7 +22,7 @@ class FeedbackViewHolder extends RecyclerView.ViewHolder {
}

void setFeedbackImage(int feedbackImageId) {
feedbackImage.setImageDrawable(ContextCompat.getDrawable(feedbackImage.getContext(), feedbackImageId));
feedbackImage.setImageDrawable(AppCompatResources.getDrawable(feedbackImage.getContext(), feedbackImageId));
}

void setFeedbackText(String feedbackText) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import android.support.annotation.StyleRes;
import android.support.v4.content.ContextCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v7.content.res.AppCompatResources;

import com.mapbox.api.directions.v5.models.DirectionsRoute;
import com.mapbox.api.directions.v5.models.RouteLeg;
Expand Down Expand Up @@ -414,8 +415,8 @@ private void addDirectionWaypoints() {
MapUtils.updateMapSourceFromFeatureCollection(
mapboxMap, featureCollections.get(featureCollections.size() - 1), WAYPOINT_SOURCE_ID);
drawWaypointMarkers(mapboxMap,
ContextCompat.getDrawable(mapView.getContext(), originWaypointIcon),
ContextCompat.getDrawable(mapView.getContext(), destinationWaypointIcon)
AppCompatResources.getDrawable(mapView.getContext(), originWaypointIcon),
AppCompatResources.getDrawable(mapView.getContext(), destinationWaypointIcon)
);
}

Expand Down Expand Up @@ -516,14 +517,14 @@ private void initializeArrowHead() {
}

private void addArrowHeadIcon() {
Drawable head = DrawableCompat.wrap(ContextCompat.getDrawable(mapView.getContext(), R.drawable.ic_arrow_head));
Drawable head = DrawableCompat.wrap(AppCompatResources.getDrawable(mapView.getContext(), R.drawable.ic_arrow_head));
DrawableCompat.setTint(head.mutate(), arrowColor);
Bitmap icon = MapImageUtils.getBitmapFromDrawable(head);
mapboxMap.addImage(ARROW_HEAD_ICON, icon);
}

private void addArrowHeadIconCasing() {
Drawable headCasing = DrawableCompat.wrap(ContextCompat.getDrawable(mapView.getContext(),
Drawable headCasing = DrawableCompat.wrap(AppCompatResources.getDrawable(mapView.getContext(),
R.drawable.ic_arrow_head_casing));
DrawableCompat.setTint(headCasing.mutate(), arrowBorderColor);
Bitmap icon = MapImageUtils.getBitmapFromDrawable(headCasing);
Expand Down

0 comments on commit 96b8578

Please sign in to comment.