Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

偶尔会出现的闪退请款,是什么原因...求大神看看!! #24

Open
tudou152 opened this issue Sep 19, 2017 · 2 comments
Open

Comments

@tudou152
Copy link

Process: com.lixiangdong.weatherforecast, PID: 15881
java.lang.NullPointerException: Attempt to read from field 'float android.graphics.PointF.y' on a null object reference
at tech.linjiang.suitlines.SuitLines.drawLines(SuitLines.java:660)
at tech.linjiang.suitlines.SuitLines.onDraw(SuitLines.java:437)
at android.view.View.draw(View.java:17077)
at tech.linjiang.suitlines.SuitLines.draw(SuitLines.java:391)
at

private void drawLines(Canvas canvas, int startIndex, int endIndex) {
for (int i = 0; i < paths.size(); i++) {
paths.get(i).reset();
}
for (int i = startIndex; i <= endIndex; i++) {
for (int j = 0; j < datas.size(); j++) {
Unit current = datas.get(j).get(i);
float curY = linesArea.bottom - (linesArea.bottom - current.getXY().y) * current.getPercent(); // 报错包的是这一行代码中的 current.getXY().y
if (i == startIndex) {
paths.get(j).moveTo(current.getXY().x, curY);
continue;
}
if (lineType == SEGMENT) {
paths.get(j).lineTo(current.getXY().x, curY);
} else if (lineType == CURVE) {
// 到这里肯定不是起始点,所以可以减1
Unit previous = datas.get(j).get(i - 1);
// 两个锚点的坐标x为中点的x,y分别是两个连接点的y
paths.get(j).cubicTo((previous.getXY().x + current.getXY().x) / 2,
linesArea.bottom - (linesArea.bottom - previous.getXY().y) * previous.getPercent(),
(previous.getXY().x + current.getXY().x) / 2, curY,
current.getXY().x, curY);
}
if (!needCoverLine && isLineFill() && i == endIndex) {
paths.get(j).lineTo(current.getXY().x, linesArea.bottom);
paths.get(j).lineTo(datas.get(j).get(startIndex).getXY().x, linesArea.bottom);
paths.get(j).close();
}
}
}
drawExsitDirectly(canvas);
}

@SailFlorve
Copy link

我也是 这种情况,同样的错误,出现在连续大量绘图的时候。读了下源码也没搞清楚...

@whataa
Copy link
Owner

whataa commented Feb 28, 2018

重载onMeasure,并尝试把 onSizeChanged 里的 代码 放到里面去,删除 onSizeChanged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants