Code refactor
This commit is contained in:
parent
3fd8481522
commit
c3ddb066b7
10 changed files with 88 additions and 58 deletions
|
@ -13,13 +13,13 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Daksh P. Jain",
|
"name": "Daksh P. Jain",
|
||||||
"summary": "Telegram group maintainer",
|
"summary": "Support Representative & Moderator",
|
||||||
"link": "https://daksh.eu.org",
|
"link": "https://daksh.eu.org",
|
||||||
"profile_image": "https://i.imgur.com/fnYpg65.jpg"
|
"profile_image": "https://i.imgur.com/fnYpg65.jpg"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Milind Goel",
|
"name": "Milind Goel",
|
||||||
"summary": "Github & Telegram maintainer",
|
"summary": "Support Representative & Moderator",
|
||||||
"link": "https://t.me/MilindGoel15",
|
"link": "https://t.me/MilindGoel15",
|
||||||
"profile_image": "https://i.imgur.com/Bz4De21_d.jpg"
|
"profile_image": "https://i.imgur.com/Bz4De21_d.jpg"
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.FragmentManager
|
import androidx.fragment.app.FragmentManager
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.dialogs.LyricsDialog
|
|
||||||
import code.name.monkey.retromusic.fragments.AlbumCoverStyle
|
import code.name.monkey.retromusic.fragments.AlbumCoverStyle
|
||||||
import code.name.monkey.retromusic.fragments.NowPlayingScreen.*
|
import code.name.monkey.retromusic.fragments.NowPlayingScreen.*
|
||||||
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
|
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
|
||||||
|
@ -91,7 +90,7 @@ class AlbumCoverPagerAdapter(
|
||||||
val view = inflater.inflate(getLayoutWithPlayerTheme(), container, false)
|
val view = inflater.inflate(getLayoutWithPlayerTheme(), container, false)
|
||||||
albumCover = view.findViewById(R.id.player_image)
|
albumCover = view.findViewById(R.id.player_image)
|
||||||
albumCover.setOnClickListener {
|
albumCover.setOnClickListener {
|
||||||
LyricsDialog().show(childFragmentManager, "LyricsDialog")
|
//LyricsDialog().show(childFragmentManager, "LyricsDialog")
|
||||||
showLyricsDialog()
|
showLyricsDialog()
|
||||||
}
|
}
|
||||||
return view
|
return view
|
||||||
|
|
|
@ -3,8 +3,11 @@ package code.name.monkey.retromusic.fragments
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
|
import androidx.navigation.fragment.FragmentNavigatorExtras
|
||||||
|
import androidx.navigation.fragment.findNavController
|
||||||
import androidx.navigation.fragment.navArgs
|
import androidx.navigation.fragment.navArgs
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
@ -179,10 +182,20 @@ class DetailListFragment : AbsMainActivityFragment(R.layout.fragment_playlist_de
|
||||||
|
|
||||||
|
|
||||||
override fun onArtist(artistId: Long, imageView: ImageView) {
|
override fun onArtist(artistId: Long, imageView: ImageView) {
|
||||||
|
findNavController().navigate(
|
||||||
|
R.id.artistDetailsFragment,
|
||||||
|
bundleOf(EXTRA_ARTIST_ID to artistId),
|
||||||
|
null,
|
||||||
|
FragmentNavigatorExtras(imageView to getString(R.string.transition_artist_image))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAlbumClick(albumId: Long, view: View) {
|
override fun onAlbumClick(albumId: Long, view: View) {
|
||||||
|
findNavController().navigate(
|
||||||
|
R.id.albumDetailsFragment,
|
||||||
|
bundleOf(EXTRA_ALBUM_ID to albumId),
|
||||||
|
null,
|
||||||
|
FragmentNavigatorExtras(view to getString(R.string.transition_album_art))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -75,7 +75,6 @@ class LibraryViewModel(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getHome(): LiveData<List<Home>> {
|
fun getHome(): LiveData<List<Home>> {
|
||||||
fetchHomeSections()
|
|
||||||
return home
|
return home
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import androidx.core.text.HtmlCompat
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.navigation.findNavController
|
import androidx.navigation.findNavController
|
||||||
|
import androidx.navigation.fragment.FragmentNavigatorExtras
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
import androidx.navigation.fragment.navArgs
|
import androidx.navigation.fragment.navArgs
|
||||||
import androidx.recyclerview.widget.DefaultItemAnimator
|
import androidx.recyclerview.widget.DefaultItemAnimator
|
||||||
|
@ -267,7 +268,9 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
|
||||||
override fun onAlbumClick(albumId: Long, view: View) {
|
override fun onAlbumClick(albumId: Long, view: View) {
|
||||||
findNavController().navigate(
|
findNavController().navigate(
|
||||||
R.id.albumDetailsFragment,
|
R.id.albumDetailsFragment,
|
||||||
bundleOf(EXTRA_ALBUM_ID to albumId)
|
bundleOf(EXTRA_ALBUM_ID to albumId),
|
||||||
|
null,
|
||||||
|
FragmentNavigatorExtras(view to getString(R.string.transition_album_art))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ import androidx.navigation.fragment.navArgs
|
||||||
import androidx.recyclerview.widget.DefaultItemAnimator
|
import androidx.recyclerview.widget.DefaultItemAnimator
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import code.name.monkey.appthemehelper.ThemeStore
|
|
||||||
import code.name.monkey.retromusic.EXTRA_ALBUM_ID
|
import code.name.monkey.retromusic.EXTRA_ALBUM_ID
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.adapter.album.HorizontalAlbumAdapter
|
import code.name.monkey.retromusic.adapter.album.HorizontalAlbumAdapter
|
||||||
|
@ -38,7 +37,6 @@ import code.name.monkey.retromusic.network.model.LastFmArtist
|
||||||
import code.name.monkey.retromusic.repository.RealRepository
|
import code.name.monkey.retromusic.repository.RealRepository
|
||||||
import code.name.monkey.retromusic.util.CustomArtistImageUtil
|
import code.name.monkey.retromusic.util.CustomArtistImageUtil
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
import code.name.monkey.retromusic.util.RetroUtil
|
import code.name.monkey.retromusic.util.RetroUtil
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import kotlinx.android.synthetic.main.fragment_artist_content.*
|
import kotlinx.android.synthetic.main.fragment_artist_content.*
|
||||||
|
@ -199,10 +197,8 @@ class ArtistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_artist_d
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setColors(color: Int) {
|
private fun setColors(color: Int) {
|
||||||
val finalColor = if (PreferenceUtil.isAdaptiveColor) color
|
shuffleAction.applyColor(color)
|
||||||
else ThemeStore.accentColor(requireContext())
|
playAction.applyOutlineColor(color)
|
||||||
shuffleAction.applyColor(finalColor)
|
|
||||||
playAction.applyOutlineColor(finalColor)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,12 +14,16 @@ import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.appcompat.widget.Toolbar
|
import androidx.appcompat.widget.Toolbar
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
import androidx.core.view.ViewCompat
|
import androidx.core.view.ViewCompat
|
||||||
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.RetroBottomSheetBehavior
|
import code.name.monkey.retromusic.RetroBottomSheetBehavior
|
||||||
import code.name.monkey.retromusic.adapter.song.PlayingQueueAdapter
|
import code.name.monkey.retromusic.adapter.song.PlayingQueueAdapter
|
||||||
|
import code.name.monkey.retromusic.db.PlaylistEntity
|
||||||
|
import code.name.monkey.retromusic.db.SongEntity
|
||||||
|
import code.name.monkey.retromusic.db.toSongEntity
|
||||||
import code.name.monkey.retromusic.extensions.hide
|
import code.name.monkey.retromusic.extensions.hide
|
||||||
import code.name.monkey.retromusic.extensions.ripAlpha
|
import code.name.monkey.retromusic.extensions.ripAlpha
|
||||||
import code.name.monkey.retromusic.extensions.show
|
import code.name.monkey.retromusic.extensions.show
|
||||||
|
@ -45,6 +49,9 @@ import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils
|
||||||
import kotlinx.android.synthetic.main.fragment_gradient_controls.*
|
import kotlinx.android.synthetic.main.fragment_gradient_controls.*
|
||||||
import kotlinx.android.synthetic.main.fragment_gradient_player.*
|
import kotlinx.android.synthetic.main.fragment_gradient_player.*
|
||||||
import kotlinx.android.synthetic.main.status_bar.*
|
import kotlinx.android.synthetic.main.status_bar.*
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
|
|
||||||
class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_player),
|
class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_player),
|
||||||
MusicProgressViewUpdateHelper.Callback,
|
MusicProgressViewUpdateHelper.Callback,
|
||||||
|
@ -216,7 +223,7 @@ class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_play
|
||||||
override fun toggleFavorite(song: Song) {
|
override fun toggleFavorite(song: Song) {
|
||||||
super.toggleFavorite(song)
|
super.toggleFavorite(song)
|
||||||
if (song.id == MusicPlayerRemote.currentSong.id) {
|
if (song.id == MusicPlayerRemote.currentSong.id) {
|
||||||
updateIsFavorite()
|
updateIsFavoriteIcon()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,6 +231,23 @@ class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_play
|
||||||
toggleFavorite(MusicPlayerRemote.currentSong)
|
toggleFavorite(MusicPlayerRemote.currentSong)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun updateIsFavoriteIcon() {
|
||||||
|
lifecycleScope.launch(Dispatchers.IO) {
|
||||||
|
val playlist: PlaylistEntity? = libraryViewModel.favoritePlaylist()
|
||||||
|
if (playlist != null) {
|
||||||
|
val song: SongEntity =
|
||||||
|
MusicPlayerRemote.currentSong.toSongEntity(playlist.playListId)
|
||||||
|
val isFavorite: Boolean = libraryViewModel.isFavoriteSong(song).isNotEmpty()
|
||||||
|
withContext(Dispatchers.Main) {
|
||||||
|
val icon =
|
||||||
|
if (isFavorite) R.drawable.ic_favorite
|
||||||
|
else R.drawable.ic_favorite_border
|
||||||
|
songFavourite.setImageResource(icon)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun hideVolumeIfAvailable() {
|
private fun hideVolumeIfAvailable() {
|
||||||
if (PreferenceUtil.isVolumeVisibilityMode) {
|
if (PreferenceUtil.isVolumeVisibilityMode) {
|
||||||
childFragmentManager.beginTransaction()
|
childFragmentManager.beginTransaction()
|
||||||
|
@ -241,6 +265,7 @@ class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_play
|
||||||
updatePlayPauseDrawableState()
|
updatePlayPauseDrawableState()
|
||||||
updatePlayPauseDrawableState()
|
updatePlayPauseDrawableState()
|
||||||
updateQueue()
|
updateQueue()
|
||||||
|
updateIsFavoriteIcon()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPlayStateChanged() {
|
override fun onPlayStateChanged() {
|
||||||
|
@ -259,6 +284,7 @@ class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_play
|
||||||
super.onPlayingMetaChanged()
|
super.onPlayingMetaChanged()
|
||||||
updateSong()
|
updateSong()
|
||||||
updateQueuePosition()
|
updateQueuePosition()
|
||||||
|
updateIsFavoriteIcon()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onQueueChanged() {
|
override fun onQueueChanged() {
|
||||||
|
@ -457,15 +483,11 @@ class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_play
|
||||||
|
|
||||||
override fun onUpdateProgressViews(progress: Int, total: Int) {
|
override fun onUpdateProgressViews(progress: Int, total: Int) {
|
||||||
progressSlider.max = total
|
progressSlider.max = total
|
||||||
|
|
||||||
val animator = ObjectAnimator.ofInt(progressSlider, "progress", progress)
|
val animator = ObjectAnimator.ofInt(progressSlider, "progress", progress)
|
||||||
animator.duration = AbsPlayerControlsFragment.SLIDER_ANIMATION_TIME
|
animator.duration = AbsPlayerControlsFragment.SLIDER_ANIMATION_TIME
|
||||||
animator.interpolator = LinearInterpolator()
|
animator.interpolator = LinearInterpolator()
|
||||||
animator.start()
|
animator.start()
|
||||||
|
|
||||||
songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong())
|
songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong())
|
||||||
songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong())
|
songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -39,7 +39,16 @@ class RealArtistRepository(
|
||||||
PreferenceUtil.artistAlbumSortOrder + ", " +
|
PreferenceUtil.artistAlbumSortOrder + ", " +
|
||||||
PreferenceUtil.artistSongSortOrder
|
PreferenceUtil.artistSongSortOrder
|
||||||
}
|
}
|
||||||
|
override fun artist(artistId: Long): Artist {
|
||||||
|
val songs = songRepository.songs(
|
||||||
|
songRepository.makeSongCursor(
|
||||||
|
AudioColumns.ARTIST_ID + "=?",
|
||||||
|
arrayOf(artistId.toString()),
|
||||||
|
getSongLoaderSortOrder()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return Artist(artistId, albumRepository.splitIntoAlbums(songs))
|
||||||
|
}
|
||||||
override fun artists(): List<Artist> {
|
override fun artists(): List<Artist> {
|
||||||
val songs = songRepository.songs(
|
val songs = songRepository.songs(
|
||||||
songRepository.makeSongCursor(
|
songRepository.makeSongCursor(
|
||||||
|
@ -50,17 +59,6 @@ class RealArtistRepository(
|
||||||
return splitIntoArtists(albumRepository.splitIntoAlbums(songs))
|
return splitIntoArtists(albumRepository.splitIntoAlbums(songs))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun artists(query: String): List<Artist> {
|
|
||||||
val songs = songRepository.songs(
|
|
||||||
songRepository.makeSongCursor(
|
|
||||||
AudioColumns.ARTIST + " LIKE ?",
|
|
||||||
arrayOf("%$query%"),
|
|
||||||
getSongLoaderSortOrder()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
return splitIntoArtists(albumRepository.splitIntoAlbums(songs))
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun albumArtists(): List<Artist> {
|
override fun albumArtists(): List<Artist> {
|
||||||
val songs = songRepository.songs(
|
val songs = songRepository.songs(
|
||||||
songRepository.makeSongCursor(
|
songRepository.makeSongCursor(
|
||||||
|
@ -72,6 +70,18 @@ class RealArtistRepository(
|
||||||
return splitIntoAlbumArtists(albumRepository.splitIntoAlbums(songs))
|
return splitIntoAlbumArtists(albumRepository.splitIntoAlbums(songs))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun artists(query: String): List<Artist> {
|
||||||
|
val songs = songRepository.songs(
|
||||||
|
songRepository.makeSongCursor(
|
||||||
|
AudioColumns.ARTIST + " LIKE ?",
|
||||||
|
arrayOf("%$query%"),
|
||||||
|
getSongLoaderSortOrder()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return splitIntoArtists(albumRepository.splitIntoAlbums(songs))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun splitIntoAlbumArtists(albums: List<Album>): List<Artist> {
|
private fun splitIntoAlbumArtists(albums: List<Album>): List<Artist> {
|
||||||
return albums.groupBy { it.albumArtist }
|
return albums.groupBy { it.albumArtist }
|
||||||
.map {
|
.map {
|
||||||
|
@ -84,20 +94,10 @@ class RealArtistRepository(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun artist(artistId: Long): Artist {
|
|
||||||
val songs = songRepository.songs(
|
|
||||||
songRepository.makeSongCursor(
|
|
||||||
AudioColumns.ARTIST_ID + "=?",
|
|
||||||
arrayOf(artistId.toString()),
|
|
||||||
getSongLoaderSortOrder()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
return Artist(artistId, albumRepository.splitIntoAlbums(songs))
|
|
||||||
}
|
|
||||||
|
|
||||||
fun splitIntoArtists(albums: List<Album>): List<Artist> {
|
fun splitIntoArtists(albums: List<Album>): List<Artist> {
|
||||||
return albums.groupBy { it.artistId }
|
return albums.groupBy { it.artistId }
|
||||||
.map { Artist(it.key, it.value) }
|
.map { Artist(it.key, it.value) }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,9 @@ import android.content.ContentResolver
|
||||||
import android.database.Cursor
|
import android.database.Cursor
|
||||||
import android.provider.BaseColumns
|
import android.provider.BaseColumns
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
import android.provider.MediaStore.Audio.*
|
import android.provider.MediaStore.Audio.AudioColumns
|
||||||
import android.provider.MediaStore.Audio.Playlists.*
|
import android.provider.MediaStore.Audio.Playlists.*
|
||||||
|
import android.provider.MediaStore.Audio.PlaylistsColumns
|
||||||
import code.name.monkey.retromusic.Constants
|
import code.name.monkey.retromusic.Constants
|
||||||
import code.name.monkey.retromusic.extensions.getInt
|
import code.name.monkey.retromusic.extensions.getInt
|
||||||
import code.name.monkey.retromusic.extensions.getLong
|
import code.name.monkey.retromusic.extensions.getLong
|
||||||
|
@ -150,7 +151,7 @@ class RealPlaylistRepository(
|
||||||
val artistId = cursor.getLong(AudioColumns.ARTIST_ID)
|
val artistId = cursor.getLong(AudioColumns.ARTIST_ID)
|
||||||
val artistName = cursor.getString(AudioColumns.ARTIST)
|
val artistName = cursor.getString(AudioColumns.ARTIST)
|
||||||
val idInPlaylist = cursor.getLong(Members._ID)
|
val idInPlaylist = cursor.getLong(Members._ID)
|
||||||
val composer = cursor.getString(AudioColumns.COMPOSER)
|
val composer = cursor.getStringOrNull(AudioColumns.COMPOSER)
|
||||||
val albumArtist = cursor.getStringOrNull("album_artist")
|
val albumArtist = cursor.getStringOrNull("album_artist")
|
||||||
return PlaylistSong(
|
return PlaylistSong(
|
||||||
id,
|
id,
|
||||||
|
@ -166,7 +167,7 @@ class RealPlaylistRepository(
|
||||||
artistName,
|
artistName,
|
||||||
playlistId,
|
playlistId,
|
||||||
idInPlaylist,
|
idInPlaylist,
|
||||||
composer,
|
composer ?: "",
|
||||||
albumArtist
|
albumArtist
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,8 @@ package code.name.monkey.retromusic.repository
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.database.Cursor
|
import android.database.Cursor
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
import android.provider.MediaStore.Audio
|
import android.provider.MediaStore.Audio.AudioColumns
|
||||||
import android.provider.MediaStore.Audio.*
|
import android.provider.MediaStore.Audio.Media
|
||||||
import code.name.monkey.retromusic.Constants.IS_MUSIC
|
import code.name.monkey.retromusic.Constants.IS_MUSIC
|
||||||
import code.name.monkey.retromusic.Constants.baseProjection
|
import code.name.monkey.retromusic.Constants.baseProjection
|
||||||
import code.name.monkey.retromusic.extensions.getInt
|
import code.name.monkey.retromusic.extensions.getInt
|
||||||
|
@ -148,17 +148,14 @@ class RealSongRepository(private val context: Context) : SongRepository {
|
||||||
}
|
}
|
||||||
selectionFinal =
|
selectionFinal =
|
||||||
selectionFinal + " AND " + Media.DURATION + ">= " + (PreferenceUtil.filterLength * 1000)
|
selectionFinal + " AND " + Media.DURATION + ">= " + (PreferenceUtil.filterLength * 1000)
|
||||||
try {
|
|
||||||
return context.contentResolver.query(
|
return context.contentResolver.query(
|
||||||
Media.EXTERNAL_CONTENT_URI,
|
Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY),
|
||||||
baseProjection,
|
baseProjection,
|
||||||
selectionFinal,
|
selectionFinal,
|
||||||
selectionValuesFinal,
|
selectionValuesFinal,
|
||||||
sortOrder
|
sortOrder
|
||||||
)
|
)
|
||||||
} catch (e: SecurityException) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun generateBlacklistSelection(
|
private fun generateBlacklistSelection(
|
||||||
|
|
Loading…
Reference in a new issue