Skip to content

Commit 25c7a16

Browse files
committed
Merge pull request #4 from ac-opensource/feature/support-for-vector-drawables
Add support for Vector Drawables
2 parents 186517a + bc6101d commit 25c7a16

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

library/src/main/java/com/gigamole/library/NavigationTabBar.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,9 +1240,18 @@ public static class Model {
12401240

12411241
public Model(final Drawable icon, final int color) {
12421242
mColor = color;
1243-
mIcon = icon != null ? ((BitmapDrawable) icon).getBitmap() :
1244-
Bitmap.createBitmap(1, 1, Bitmap.Config.RGB_565);
1245-
1243+
if (icon != null) {
1244+
if(icon instanceof BitmapDrawable) {
1245+
mIcon = ((BitmapDrawable) icon).getBitmap();
1246+
} else {
1247+
mIcon = Bitmap.createBitmap(icon.getIntrinsicWidth(),icon.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
1248+
Canvas canvas = new Canvas(mIcon);
1249+
icon.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
1250+
icon.draw(canvas);
1251+
}
1252+
} else {
1253+
mIcon = Bitmap.createBitmap(1, 1, Bitmap.Config.RGB_565);
1254+
}
12461255
mBadgeAnimator.addListener(new Animator.AnimatorListener() {
12471256

12481257
@Override

0 commit comments

Comments
 (0)