Code review fix.
This commit is contained in:
parent
807e89521f
commit
0b9db0ee6b
|
@ -151,14 +151,14 @@ class AudioWaveformView @JvmOverloads constructor(
|
||||||
|
|
||||||
private fun handleNewFftList(fftList: List<FFT>) {
|
private fun handleNewFftList(fftList: List<FFT>) {
|
||||||
val maxVisibleBarCount = getMaxVisibleBarCount()
|
val maxVisibleBarCount = getMaxVisibleBarCount()
|
||||||
|
|
||||||
fftList.forEach { fft ->
|
fftList.forEach { fft ->
|
||||||
rawFftList.add(fft)
|
rawFftList.add(fft)
|
||||||
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 = mutableListOf<FFT>().apply {
|
visibleBarHeights = visibleBarHeights.takeLast(maxVisibleBarCount).toMutableList()
|
||||||
addAll(visibleBarHeights.subList(visibleBarHeights.size - maxVisibleBarCount, visibleBarHeights.size))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue