SuitLines icon indicating copy to clipboard operation
SuitLines copied to clipboard

为什么直接设置4条线就会报空指针~

Open alless1 opened this issue 7 years ago • 1 comments

Caused by: java.lang.NullPointerException: Attempt to read from field 'float android.graphics.RectF.left' on a null object reference at tech.linjiang.suitlines.SuitLines.buildPaintColor(SuitLines.java:814) at tech.linjiang.suitlines.SuitLines.access$1000(SuitLines.java:61) at tech.linjiang.suitlines.SuitLines$LineBuilder.build(SuitLines.java:1375) at tech.linjiang.suitlines.simple.DemoChartActivity.init(DemoChartActivity.java:139) at tech.linjiang.suitlines.simple.DemoChartActivity.onCreate(DemoChartActivity.java:32)

alless1 avatar Jun 06 '17 07:06 alless1

这是作者的一个bug,在他源码SuitLines类种 /** * * @param color 不能为null * @return */ private LinearGradient buildPaintColor(int[] color) { int[] bakColor = color; if (color != null && color.length < 2) { bakColor = new int[2]; bakColor[0] = color[0]; bakColor[1] = color[0]; } if(linesArea==null){ //添加该判断 calcAreas(); } return new LinearGradient(linesArea.left, linesArea.top, linesArea.left, linesArea.bottom, bakColor, null, Shader.TileMode.CLAMP); } 即可

bilifo avatar May 27 '19 08:05 bilifo