Skip to content

Commit 4214c28

Browse files
committed
fix an issue where switching charts back and forth can crash the app
1 parent e0e299f commit 4214c28

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/main/java/de/dennisguse/opentracks/chart/ChartView.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,10 +683,18 @@ private record TitleDimensions(
683683
*/
684684
private void drawSeriesTitles(Canvas canvas) {
685685
Iterator<TitlePosition> tpI = titleDimensions.titlePositions.iterator();
686+
686687
for (ChartValueSeries chartValueSeries : seriesList) {
687688
if (chartValueSeries.isEnabled() && chartValueSeries.hasData() || allowIfEmpty(chartValueSeries)) {
688689
String title = getContext().getString(chartValueSeries.getTitleId(unitSystem));
689690
Paint paint = chartValueSeries.getTitlePaint();
691+
692+
// It is possible for the titlePositions to become empty temporarily, while switching between
693+
// chart screens quickly.
694+
if (!tpI.hasNext()) {
695+
return;
696+
}
697+
690698
TitlePosition tp = tpI.next();
691699
int y = topBorder - spacer - (titleDimensions.lineCount - tp.line) * (titleDimensions.lineHeight + spacer);
692700
canvas.drawText(title, tp.xPos + getScrollX(), y, paint);

0 commit comments

Comments
 (0)