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

View file

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