fix(android): drawPath CRASH_java.lang.NullPointerException

This commit is contained in:
maxli
2023-03-16 17:30:30 +08:00
committed by zoomchan-cxj
parent df4d7ea648
commit 76210a49a2
@@ -423,7 +423,7 @@ public class BackgroundDrawable extends BaseDrawable
{
// updateStyle border with radius path
updatePath();
assert mPathForBorderRadius != null;
// draw bg color
boolean useGradientPaint = initGradientPaint();
if (useGradientPaint) {
@@ -801,19 +801,15 @@ public class BackgroundDrawable extends BaseDrawable
private void updatePath()
{
if (!mNeedUpdateBorderPath)
{
return;
}
mNeedUpdateBorderPath = false;
if (mPathForBorderRadius == null)
{
if (mPathForBorderRadius == null) {
mPathForBorderRadius = new Path();
mTempRectForBorderRadius = new RectF();
}
if (!mNeedUpdateBorderPath) {
return;
}
mNeedUpdateBorderPath = false;
mPathForBorderRadius.reset();
mTempRectForBorderRadius.set(mRect);
float fullBorderWidth = mBorderWidthArray == null ? 0 : mBorderWidthArray[0];
if (fullBorderWidth > 1)