From 55679185cece1e611c14176f4d4cb9af44b6f60c Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 2 Apr 2020 17:51:09 +0200 Subject: [PATCH] properly fetch the recordings on older devices --- .../voicerecorder/fragments/PlayerFragment.kt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 e5355ec..92ee5b9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/fragments/PlayerFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/fragments/PlayerFragment.kt @@ -27,6 +27,7 @@ import kotlinx.android.synthetic.main.fragment_player.view.* import org.greenrobot.eventbus.EventBus import org.greenrobot.eventbus.Subscribe import org.greenrobot.eventbus.ThreadMode +import java.io.File import java.util.* import kotlin.collections.ArrayList @@ -204,6 +205,20 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager private fun getLegacyRecordings(): ArrayList { val recordings = ArrayList() + val files = File(context.config.saveRecordingsFolder).listFiles() ?: return recordings + + files.filter { it.isAudioFast() }.forEach { + val id = it.hashCode() + val title = it.name + val path = it.absolutePath + val timestamp = (it.lastModified() / 1000).toInt() + val duration = it.absolutePath.getFileDurationSeconds() ?: 0 + val size = it.length().toInt() + val recording = Recording(id, title, path, timestamp, duration, size) + recordings.add(recording) + } + + recordings.sortByDescending { it.timestamp } return recordings }