From 8c58532e62c2c3459a689f57cfaa6a859c4ebcb5 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 20 May 2020 22:56:50 +0200 Subject: [PATCH] catch and show errors thrown at playing a recording --- app/build.gradle | 2 +- .../voicerecorder/fragments/PlayerFragment.kt | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index e20a261..5c3179d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -57,7 +57,7 @@ android { } dependencies { - implementation 'com.simplemobiletools:commons:5.27.6' + implementation 'com.simplemobiletools:commons:5.28.14' implementation 'org.greenrobot:eventbus:3.2.0' implementation 'com.github.Armen101:AudioRecordView:1.0.2' } diff --git a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/fragments/PlayerFragment.kt b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/fragments/PlayerFragment.kt index d6c00a4..d0d869b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/fragments/PlayerFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/fragments/PlayerFragment.kt @@ -42,7 +42,7 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager override fun onResume() { setupColors() - if (!prevSavePath.isEmpty() && context!!.config.saveRecordingsFolder != prevSavePath) { + if (prevSavePath.isNotEmpty() && context!!.config.saveRecordingsFolder != prevSavePath) { setupAdapter() } else { getRecordingsAdapter()?.updateTextColor(context.config.textColor) @@ -269,10 +269,14 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager player!!.apply { reset() - if (isQPlus()) { - setDataSource(context, getAudioFileContentUri(recording.id.toLong())) - } else { - setDataSource(recording.path) + try { + if (isQPlus()) { + setDataSource(context, getAudioFileContentUri(recording.id.toLong())) + } else { + setDataSource(recording.path) + } + } catch (e: Exception) { + context?.showErrorToast(e) } prepareAsync()