Skip to content

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

Description

@tudou152

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);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions