Show audio files from MediaStore.Files table

This commit is contained in:
Naveen 2023-07-04 19:36:16 +05:30
parent f6cd3ed7ad
commit 35ae6dd946
No known key found for this signature in database
GPG key ID: 0E155DAD31671DA3

View file

@ -13,13 +13,10 @@ import com.simplemobiletools.musicplayer.activities.SimpleActivity
import com.simplemobiletools.musicplayer.activities.TracksActivity
import com.simplemobiletools.musicplayer.adapters.FoldersAdapter
import com.simplemobiletools.musicplayer.dialogs.ChangeSortingDialog
import com.simplemobiletools.musicplayer.extensions.albumsDAO
import com.simplemobiletools.musicplayer.extensions.artistDAO
import com.simplemobiletools.musicplayer.extensions.config
import com.simplemobiletools.musicplayer.extensions.tracksDAO
import com.simplemobiletools.musicplayer.helpers.FOLDER
import com.simplemobiletools.musicplayer.helpers.TAB_FOLDERS
import com.simplemobiletools.musicplayer.models.Album
import com.simplemobiletools.musicplayer.models.Folder
import com.simplemobiletools.musicplayer.models.Track
import kotlinx.android.synthetic.main.fragment_folders.view.*
@ -29,17 +26,7 @@ class FoldersFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
override fun setupFragment(activity: BaseSimpleActivity) {
ensureBackgroundThread {
val albums = ArrayList<Album>()
val artists = context.artistDAO.getAll()
artists.forEach { artist ->
albums.addAll(context.albumsDAO.getArtistAlbums(artist.id))
}
var tracks = ArrayList<Track>()
albums.forEach { album ->
tracks.addAll(context.tracksDAO.getTracksFromAlbum(album.id))
}
var tracks = context.tracksDAO.getAll()
tracks = tracks.distinctBy { "${it.path}/${it.mediaStoreId}" }.toMutableList() as ArrayList<Track>
Track.sorting = context.config.trackSorting