Code review fix.

This commit is contained in:
Onuray Sahin 2022-06-06 12:19:09 +03:00
parent 807e89521f
commit 0b9db0ee6b
1 changed files with 3 additions and 3 deletions

View File

@ -151,14 +151,14 @@ class AudioWaveformView @JvmOverloads constructor(
private fun handleNewFftList(fftList: List<FFT>) {
val maxVisibleBarCount = getMaxVisibleBarCount()
fftList.forEach { fft ->
rawFftList.add(fft)
val barHeight = max(fft.value / MAX_FFT * (height - verticalPadding * 2), barMinHeight)
visibleBarHeights.add(FFT(barHeight, fft.color))
if (visibleBarHeights.size > maxVisibleBarCount) {
visibleBarHeights = mutableListOf<FFT>().apply {
addAll(visibleBarHeights.subList(visibleBarHeights.size - maxVisibleBarCount, visibleBarHeights.size))
}
visibleBarHeights = visibleBarHeights.takeLast(maxVisibleBarCount).toMutableList()
}
}
}