Skip to content

Commit e75c712

Browse files
author
Dennis Mantz
committed
Fix crash when hiding drawer in landscape with enabled peaks
1 parent befbe17 commit e75c712

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

app/src/main/java/com/mantz_it/rfanalyzer/ui/AnalyzerSurface.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,10 @@ class AnalyzerSurface(context: Context,
530530
frameRateTimestamp = startTimestamp
531531
}
532532

533+
// Local current state (better performance, and safer because width/height could change at any time)
534+
val width = width
535+
val fftHeight = fftHeight
536+
533537
if(timeAverageSamples == null || timeAverageSamples!!.size != width)
534538
timeAverageSamples = FloatArray(width)
535539
if(fftPeakHold.value && (peaksYCoordinates == null || peaksYCoordinates!!.size != width))
@@ -574,7 +578,9 @@ class AnalyzerSurface(context: Context,
574578
waterfallBufferDirtyMap,
575579
frequency,
576580
sampleRate,
577-
readIndex
581+
readIndex,
582+
width,
583+
fftHeight
578584
)
579585
}
580586
} finally {
@@ -598,12 +604,12 @@ class AnalyzerSurface(context: Context,
598604
frequency: Long, // center frequency of the fft samples
599605
sampleRate: Long, // sample rate of the fft samples
600606
currentRowIdx: Int, // Index of the most recent row in waterfallBuffer
607+
width: Int,
608+
fftHeight: Int
601609
) {
602610
val startTimestamp = System.currentTimeMillis()
603611

604612
// performance optimization:
605-
val width = width
606-
val fftHeight = fftHeight
607613
val timeAverageSamples = timeAverageSamples!!
608614
val waterfallColorMapArray = waterfallColorMapArray
609615
val colorMapSize = waterfallColorMapArray.size

0 commit comments

Comments
 (0)