Create a new list for sublist to fix stackoverflowerror.

This commit is contained in:
Onuray Sahin 2022-06-01 16:55:42 +03:00
parent 3cc1951587
commit 966b3ce54a
1 changed files with 3 additions and 1 deletions

View File

@ -156,7 +156,9 @@ class AudioWaveformView @JvmOverloads constructor(
val barHeight = max(fft.value / MAX_FFT * (height - verticalPadding * 2), barMinHeight) val barHeight = max(fft.value / MAX_FFT * (height - verticalPadding * 2), barMinHeight)
visibleBarHeights.add(FFT(barHeight, fft.color)) visibleBarHeights.add(FFT(barHeight, fft.color))
if (visibleBarHeights.size > maxVisibleBarCount) { if (visibleBarHeights.size > maxVisibleBarCount) {
visibleBarHeights = visibleBarHeights.subList(visibleBarHeights.size - maxVisibleBarCount, visibleBarHeights.size) visibleBarHeights = mutableListOf<FFT>().apply {
addAll(visibleBarHeights.subList(visibleBarHeights.size - maxVisibleBarCount, visibleBarHeights.size))
}
} }
} }
} }