adding a placeholder in case no recordings are available
This commit is contained in:
parent
f2f2283525
commit
1b9561aa46
|
@ -111,6 +111,12 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
|
||||||
|
|
||||||
private fun setupAdapter() {
|
private fun setupAdapter() {
|
||||||
val recordings = getRecordings()
|
val recordings = getRecordings()
|
||||||
|
recordings_placeholder.beVisibleIf(recordings.isEmpty())
|
||||||
|
if (recordings.isEmpty()) {
|
||||||
|
resetProgress(null)
|
||||||
|
player?.stop()
|
||||||
|
}
|
||||||
|
|
||||||
val adapter = getRecordingsAdapter()
|
val adapter = getRecordingsAdapter()
|
||||||
if (adapter == null) {
|
if (adapter == null) {
|
||||||
RecordingsAdapter(context as SimpleActivity, recordings, this, recordings_list, recordings_fastscroller) {
|
RecordingsAdapter(context as SimpleActivity, recordings, this, recordings_list, recordings_fastscroller) {
|
||||||
|
@ -192,11 +198,7 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
|
||||||
recording.id.toLong()
|
recording.id.toLong()
|
||||||
)
|
)
|
||||||
|
|
||||||
updateCurrentProgress(0)
|
resetProgress(recording)
|
||||||
player_progressbar.progress = 0
|
|
||||||
player_progressbar.max = recording.duration
|
|
||||||
player_title.text = recording.title
|
|
||||||
player_progress_max.text = recording.duration.getFormattedDuration()
|
|
||||||
(recordings_list.adapter as RecordingsAdapter).updateCurrentRecording(recording.id)
|
(recordings_list.adapter as RecordingsAdapter).updateCurrentRecording(recording.id)
|
||||||
|
|
||||||
player!!.apply {
|
player!!.apply {
|
||||||
|
@ -244,6 +246,14 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
|
||||||
player_progress_current.text = seconds.getFormattedDuration()
|
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() {
|
private fun togglePlayPause() {
|
||||||
if (getIsPlaying()) {
|
if (getIsPlaying()) {
|
||||||
pausePlayback()
|
pausePlayback()
|
||||||
|
|
|
@ -6,6 +6,19 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyTextView
|
||||||
|
android:id="@+id/recordings_placeholder"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginTop="@dimen/activity_margin"
|
||||||
|
android:gravity="center"
|
||||||
|
android:padding="@dimen/activity_margin"
|
||||||
|
android:lineSpacingExtra="@dimen/medium_margin"
|
||||||
|
android:text="@string/no_recordings_found"
|
||||||
|
android:textSize="@dimen/bigger_text_size"
|
||||||
|
android:visibility="visible"/>
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
android:id="@+id/recordings_list"
|
android:id="@+id/recordings_list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
<string name="app_launcher_name">Nahrávač zvuku</string>
|
<string name="app_launcher_name">Nahrávač zvuku</string>
|
||||||
<string name="recording_saved_successfully">Nahrávka bola uložená ako \n\"%s\"</string>
|
<string name="recording_saved_successfully">Nahrávka bola uložená ako \n\"%s\"</string>
|
||||||
<string name="recording">Nahráva sa</string>
|
<string name="recording">Nahráva sa</string>
|
||||||
|
<string name="no_recordings_found">Nenašli sa žiadne nahrávky\nvytvorené touto aplikáciou</string>
|
||||||
|
|
||||||
<!-- Confirmation dialog -->
|
<!-- Confirmation dialog -->
|
||||||
<string name="delete_recordings_confirmation">Ste si istý, že chcete odstrániť %s?</string> <!-- Are you sure you want to delete 5 recordings? -->
|
<string name="delete_recordings_confirmation">Ste si istý, že chcete odstrániť %s?</string> <!-- Are you sure you want to delete 5 recordings? -->
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
<string name="app_launcher_name">Voice Recorder</string>
|
<string name="app_launcher_name">Voice Recorder</string>
|
||||||
<string name="recording_saved_successfully">Recording saved successfully as\n\"%s\"</string>
|
<string name="recording_saved_successfully">Recording saved successfully as\n\"%s\"</string>
|
||||||
<string name="recording">Recording</string>
|
<string name="recording">Recording</string>
|
||||||
|
<string name="no_recordings_found">No recordings created by this app\nhave been found</string>
|
||||||
|
|
||||||
<!-- Confirmation dialog -->
|
<!-- Confirmation dialog -->
|
||||||
<string name="delete_recordings_confirmation">Are you sure you want to delete %s?</string> <!-- Are you sure you want to delete 5 recordings? -->
|
<string name="delete_recordings_confirmation">Are you sure you want to delete %s?</string> <!-- Are you sure you want to delete 5 recordings? -->
|
||||||
|
|
Loading…
Reference in New Issue