From 1b9561aa46da1ef9701d1c53b87400725fb1a6d1 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 2 Apr 2020 14:33:01 +0200 Subject: [PATCH] adding a placeholder in case no recordings are available --- .../voicerecorder/fragments/PlayerFragment.kt | 20 ++++++++++++++----- app/src/main/res/layout/fragment_player.xml | 13 ++++++++++++ app/src/main/res/values-sk/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 4 files changed, 30 insertions(+), 5 deletions(-) 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 6a3a470..ecfdadc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/fragments/PlayerFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/fragments/PlayerFragment.kt @@ -111,6 +111,12 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager private fun setupAdapter() { val recordings = getRecordings() + recordings_placeholder.beVisibleIf(recordings.isEmpty()) + if (recordings.isEmpty()) { + resetProgress(null) + player?.stop() + } + val adapter = getRecordingsAdapter() if (adapter == null) { RecordingsAdapter(context as SimpleActivity, recordings, this, recordings_list, recordings_fastscroller) { @@ -192,11 +198,7 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager recording.id.toLong() ) - updateCurrentProgress(0) - player_progressbar.progress = 0 - player_progressbar.max = recording.duration - player_title.text = recording.title - player_progress_max.text = recording.duration.getFormattedDuration() + resetProgress(recording) (recordings_list.adapter as RecordingsAdapter).updateCurrentRecording(recording.id) player!!.apply { @@ -244,6 +246,14 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager player_progress_current.text = seconds.getFormattedDuration() } + private fun resetProgress(recording: Recording?) { + updateCurrentProgress(0) + player_progressbar.progress = 0 + player_progressbar.max = recording?.duration ?: 0 + player_title.text = recording?.title ?: "" + player_progress_max.text = (recording?.duration ?: 0).getFormattedDuration() + } + private fun togglePlayPause() { if (getIsPlaying()) { pausePlayback() diff --git a/app/src/main/res/layout/fragment_player.xml b/app/src/main/res/layout/fragment_player.xml index b829d1a..806e84a 100644 --- a/app/src/main/res/layout/fragment_player.xml +++ b/app/src/main/res/layout/fragment_player.xml @@ -6,6 +6,19 @@ android:layout_width="match_parent" android:layout_height="match_parent"> + + Nahrávač zvuku Nahrávka bola uložená ako \n\"%s\" Nahráva sa + Nenašli sa žiadne nahrávky\nvytvorené touto aplikáciou Ste si istý, že chcete odstrániť %s? diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index dfbb5bb..0f0ed87 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -3,6 +3,7 @@ Voice Recorder Recording saved successfully as\n\"%s\" Recording + No recordings created by this app\nhave been found Are you sure you want to delete %s?