dont create bitmap with 0 height/width during early render.

when specify background color in react-native even parent view height/width could become zero
https://github.com/react-native-community/react-native-svg/issues/823
This commit is contained in:
Nizam Moidu
2018-10-24 22:34:36 +04:00
parent e2e415c467
commit c0bfe22e0d
@@ -88,7 +88,8 @@ public class SvgView extends ReactViewGroup implements ReactCompoundView, ReactC
if (mBitmap == null) {
mBitmap = drawOutput();
}
canvas.drawBitmap(mBitmap, 0, 0, null);
if (mBitmap != null)
canvas.drawBitmap(mBitmap, 0, 0, null);
}
@Override
@@ -214,6 +215,9 @@ public class SvgView extends ReactViewGroup implements ReactCompoundView, ReactC
height = (float) PropHelper.fromRelative(mbbHeight, parentHeight, 0, mScale, 12);
setMeasuredDimension((int)Math.ceil(width), (int)Math.ceil(height));
}
if (width == 0 || height == 0) {
return null;
}
Bitmap bitmap = Bitmap.createBitmap(
(int) width,
(int) height,