split the recordings fetching between Q and legacy mode

This commit is contained in:
tibbi 2020-04-02 16:08:50 +02:00
parent 0c768d5cb8
commit 41e7cfe71b
1 changed files with 15 additions and 1 deletions

View File

@ -14,6 +14,7 @@ import android.provider.MediaStore
import android.util.AttributeSet
import android.widget.SeekBar
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.isQPlus
import com.simplemobiletools.voicerecorder.R
import com.simplemobiletools.voicerecorder.activities.SimpleActivity
import com.simplemobiletools.voicerecorder.adapters.RecordingsAdapter
@ -143,8 +144,16 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
}
}
@SuppressLint("InlinedApi")
private fun getRecordings(): ArrayList<Recording> {
return if (isQPlus()) {
getMediaStoreRecordings()
} else {
getLegacyRecordings()
}
}
@SuppressLint("InlinedApi")
private fun getMediaStoreRecordings(): ArrayList<Recording> {
val recordings = ArrayList<Recording>()
val uri = MediaStore.Audio.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY)
@ -193,6 +202,11 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
return recordings
}
private fun getLegacyRecordings(): ArrayList<Recording> {
val recordings = ArrayList<Recording>()
return recordings
}
private fun getDurationFromUri(id: Long): Long {
val retriever = MediaMetadataRetriever()
retriever.setDataSource(context, getAudioFileContentUri(id))