Skip to content

Commit

Permalink
permit android vector drawables to be used as markers (react-native-m…
Browse files Browse the repository at this point in the history
  • Loading branch information
mlc authored and rborn committed Mar 22, 2018
1 parent 43f4699 commit 35855f9
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.view.View;
import android.widget.LinearLayout;
Expand Down Expand Up @@ -283,7 +284,15 @@ public void setImage(String uri) {
} else {
iconBitmapDescriptor = getBitmapDescriptorByName(uri);
if (iconBitmapDescriptor != null) {
iconBitmap = BitmapFactory.decodeResource(getResources(), getDrawableResourceByName(uri));
int drawableId = getDrawableResourceByName(uri);
iconBitmap = BitmapFactory.decodeResource(getResources(), drawableId);
if (iconBitmap == null) { // VectorDrawable or similar
Drawable drawable = getResources().getDrawable(drawableId);
iconBitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
Canvas canvas = new Canvas(iconBitmap);
drawable.draw(canvas);
}
}
update();
}
Expand Down

0 comments on commit 35855f9

Please sign in to comment.