From 13435429ae38ebce5b88c59a42a6cdf0cc3ea6a5 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 5 Nov 2020 19:39:18 +0100 Subject: [PATCH] stop the duration and visualizer during pause --- .../voicerecorder/fragments/RecorderFragment.kt | 8 ++++---- .../voicerecorder/services/RecorderService.kt | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/fragments/RecorderFragment.kt b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/fragments/RecorderFragment.kt index 2b64e2f..15d41f2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/fragments/RecorderFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/fragments/RecorderFragment.kt @@ -99,6 +99,7 @@ class RecorderFragment(context: Context, attributeSet: AttributeSet) : MyViewPag Intent(context, RecorderService::class.java).apply { context.startService(this) } + recorder_visualizer.recreate() } private fun stopRecording() { @@ -117,14 +118,13 @@ class RecorderFragment(context: Context, attributeSet: AttributeSet) : MyViewPag status = event.status toggle_recording_button.setImageDrawable(getToggleButtonIcon()) toggle_pause_button.beVisibleIf(status != RECORDING_STOPPED && isNougatPlus()) - if (status == RECORDING_RUNNING) { - recorder_visualizer.recreate() - } } @Subscribe(threadMode = ThreadMode.MAIN) fun gotAmplitudeEvent(event: Events.RecordingAmplitude) { val amplitude = event.amplitude - recorder_visualizer.update(amplitude) + if (status == RECORDING_RUNNING) { + recorder_visualizer.update(amplitude) + } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/services/RecorderService.kt b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/services/RecorderService.kt index a5882f2..19957c7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/services/RecorderService.kt +++ b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/services/RecorderService.kt @@ -202,8 +202,10 @@ class RecorderService : Service() { private fun getDurationUpdateTask() = object : TimerTask() { override fun run() { - duration++ - broadcastDuration() + if (status == RECORDING_RUNNING) { + duration++ + broadcastDuration() + } } }