diff --git a/app/src/main/java/code/name/monkey/retromusic/Constants.kt b/app/src/main/java/code/name/monkey/retromusic/Constants.kt index 32e91aca..4e3a7a24 100644 --- a/app/src/main/java/code/name/monkey/retromusic/Constants.kt +++ b/app/src/main/java/code/name/monkey/retromusic/Constants.kt @@ -31,7 +31,7 @@ object Constants { const val APP_TWITTER_LINK = "https://twitter.com/retromusicapp" const val FAQ_LINK = "https://github.com/h4h13/RetroMusicPlayer/blob/master/FAQ.md" const val PINTEREST = "https://in.pinterest.com/retromusicapp/" - const val BASE_URL = "https://ws.audioscrobbler.com/2.0/" + const val AUDIO_SCROBBLER_URL = "https://ws.audioscrobbler.com/2.0/" const val IS_MUSIC = MediaStore.Audio.AudioColumns.IS_MUSIC + "=1" + " AND " + MediaStore.Audio.AudioColumns.TITLE + " != ''" @@ -70,8 +70,8 @@ const val NOW_PLAYING_SCREEN_ID = "now_playing_screen_id" const val CAROUSEL_EFFECT = "carousel_effect" const val COLORED_NOTIFICATION = "colored_notification" const val CLASSIC_NOTIFICATION = "classic_notification" -const val GAPLESS_PLAYBACK = "gapless_playback" -const val ALBUM_ART_ON_LOCKSCREEN = "album_art_on_lockscreen" +const val GAP_LESS_PLAYBACK = "gap_less_playback" +const val ALBUM_ART_ON_LOCK_SCREEN = "album_art_on_lock_screen" const val BLURRED_ALBUM_ART = "blurred_album_art" const val NEW_BLUR_AMOUNT = "new_blur_amount" const val TOGGLE_HEADSET = "toggle_headset" @@ -92,7 +92,6 @@ const val ALBUM_COVER_STYLE = "album_cover_style_id" const val ALBUM_COVER_TRANSFORM = "album_cover_transform" const val TAB_TEXT_MODE = "tab_text_mode" const val LANGUAGE_NAME = "language_name" -const val DIALOG_CORNER = "dialog_corner" const val SLEEP_TIMER_FINISH_SONG = "sleep_timer_finish_song" const val ALBUM_GRID_STYLE = "album_grid_style_home" const val ARTIST_GRID_STYLE = "artist_grid_style_home" diff --git a/app/src/main/java/code/name/monkey/retromusic/MainModule.kt b/app/src/main/java/code/name/monkey/retromusic/MainModule.kt index 40a296ba..aae0ed48 100644 --- a/app/src/main/java/code/name/monkey/retromusic/MainModule.kt +++ b/app/src/main/java/code/name/monkey/retromusic/MainModule.kt @@ -13,7 +13,6 @@ import code.name.monkey.retromusic.fragments.artists.ArtistDetailsViewModel import code.name.monkey.retromusic.fragments.genres.GenreDetailsViewModel import code.name.monkey.retromusic.fragments.playlists.PlaylistDetailsViewModel import code.name.monkey.retromusic.fragments.search.SearchViewModel -import code.name.monkey.retromusic.fragments.songs.SongsViewModel import code.name.monkey.retromusic.model.Genre import code.name.monkey.retromusic.network.networkModule import code.name.monkey.retromusic.repository.* @@ -152,10 +151,6 @@ private val viewModules = module { viewModel { SearchViewModel(get()) } - - viewModel { - SongsViewModel(get()) - } } val appModules = listOf(mainModule, dataModule, viewModules, networkModule, roomModule) \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/SearchAdapter.kt b/app/src/main/java/code/name/monkey/retromusic/adapter/SearchAdapter.kt index c372b45c..97e2ada1 100644 --- a/app/src/main/java/code/name/monkey/retromusic/adapter/SearchAdapter.kt +++ b/app/src/main/java/code/name/monkey/retromusic/adapter/SearchAdapter.kt @@ -60,7 +60,7 @@ class SearchAdapter( holder.title?.text = album.title holder.text?.text = album.artistName AlbumGlideRequest.Builder.from(Glide.with(activity), album.safeGetFirstSong()) - .checkIgnoreMediaStore(activity).build().into(holder.image) + .checkIgnoreMediaStore().build().into(holder.image) } ARTIST -> { val artist = dataSet.get(position) as Artist diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/album/AlbumAdapter.kt b/app/src/main/java/code/name/monkey/retromusic/adapter/album/AlbumAdapter.kt index 73c8b09e..8cb9f9d8 100644 --- a/app/src/main/java/code/name/monkey/retromusic/adapter/album/AlbumAdapter.kt +++ b/app/src/main/java/code/name/monkey/retromusic/adapter/album/AlbumAdapter.kt @@ -101,11 +101,10 @@ open class AlbumAdapter( } AlbumGlideRequest.Builder.from(Glide.with(activity), album.safeGetFirstSong()) - .checkIgnoreMediaStore(activity) + .checkIgnoreMediaStore() .generatePalette(activity) .build() .into(object : RetroMusicColoredTarget(holder.image!!) { - override fun onColorReady(colors: MediaNotificationProcessor) { setColors(colors, holder) } diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/album/HorizontalAlbumAdapter.kt b/app/src/main/java/code/name/monkey/retromusic/adapter/album/HorizontalAlbumAdapter.kt index 043f5ecd..8198a957 100644 --- a/app/src/main/java/code/name/monkey/retromusic/adapter/album/HorizontalAlbumAdapter.kt +++ b/app/src/main/java/code/name/monkey/retromusic/adapter/album/HorizontalAlbumAdapter.kt @@ -36,7 +36,7 @@ class HorizontalAlbumAdapter( override fun loadAlbumCover(album: Album, holder: ViewHolder) { if (holder.image == null) return AlbumGlideRequest.Builder.from(Glide.with(activity), album.safeGetFirstSong()) - .checkIgnoreMediaStore(activity) + .checkIgnoreMediaStore() .generatePalette(activity) .build() .into(object : RetroMusicColoredTarget(holder.image!!) { diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/AddToRetroPlaylist.kt b/app/src/main/java/code/name/monkey/retromusic/dialogs/AddToRetroPlaylist.kt index 52859a57..0e3debaf 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/AddToRetroPlaylist.kt +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/AddToRetroPlaylist.kt @@ -51,7 +51,8 @@ class AddToRetroPlaylist : BottomSheetDialogFragment() { return materialDialog(R.string.add_playlist_title) .setItems(playlistNames.toTypedArray()) { _, which -> if (which == 0) { - CreateRetroPlaylist.create(songs).show(requireActivity().supportFragmentManager, "Dialog") + CreateRetroPlaylist.create(songs) + .show(requireActivity().supportFragmentManager, "Dialog") } else { lifecycleScope.launch(Dispatchers.IO) { val songEntities = songs.toSongEntity(playlistEntities[which - 1]) diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/LibraryViewModel.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/LibraryViewModel.kt index 8a4c8cac..3392ccb8 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/LibraryViewModel.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/LibraryViewModel.kt @@ -12,9 +12,7 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.interfaces.MusicServiceEventListener import code.name.monkey.retromusic.model.* import code.name.monkey.retromusic.repository.RealRepository -import kotlinx.coroutines.Deferred import kotlinx.coroutines.Dispatchers.IO -import kotlinx.coroutines.async import kotlinx.coroutines.launch class LibraryViewModel( @@ -25,75 +23,95 @@ class LibraryViewModel( private val albums = MutableLiveData>() private val songs = MutableLiveData>() private val artists = MutableLiveData>() - private val playlists = MutableLiveData>() - private val roomPlaylists = MutableLiveData>() + private val playlists = MutableLiveData>() private val genres = MutableLiveData>() private val home = MutableLiveData>() val paletteColorLiveData: LiveData = paletteColor - val homeLiveData: LiveData> = home - val albumsLiveData: LiveData> = albums - val songsLiveData: LiveData> = songs - val artistsLiveData: LiveData> = artists - val playlisitsLiveData: LiveData> = playlists - val roomPlaylistsLiveData: LiveData> = roomPlaylists - val genresLiveData: LiveData> = genres - init { - viewModelScope.launch { - loadLibraryContent() + private fun loadLibraryContent() = viewModelScope.launch(IO) { + fetchSongs() + fetchAlbums() + fetchArtists() + fetchGenres() + fetchHomeSections() + fetchPlaylists() + } + + fun getSongs(): LiveData> { + fetchSongs() + return songs + } + + fun getAlbums(): LiveData> { + fetchAlbums() + return albums + } + + fun getArtists(): LiveData> { + fetchArtists() + return artists + } + + fun getPlaylists(): LiveData> { + fetchPlaylists() + return playlists + } + + fun getGenre(): LiveData> { + fetchGenres() + return genres + } + + fun getHome(): LiveData> { + fetchHomeSections() + return home + } + + private fun fetchSongs() { + viewModelScope.launch(IO) { + songs.postValue(repository.allSongs()) } } - private fun loadLibraryContent() = viewModelScope.launch { - home.value = loadHome.await() - songs.value = loadSongs.await() - albums.value = loadAlbums.await() - artists.value = loadArtists.await() - playlists.value = loadPlaylists.await() - roomPlaylists.value = loadPlaylistsWithSongs.await() - genres.value = loadGenres.await() + private fun fetchAlbums() { + viewModelScope.launch(IO) { + albums.postValue(repository.fetchAlbums()) + } } - private val loadHome: Deferred> - get() = viewModelScope.async { repository.homeSections() } - - private val loadSongs: Deferred> - get() = viewModelScope.async(IO) { repository.allSongs() } - - private val loadAlbums: Deferred> - get() = viewModelScope.async(IO) { - repository.allAlbums() + private fun fetchArtists() { + viewModelScope.launch(IO) { + artists.postValue(repository.fetchArtists()) } + } - private val loadArtists: Deferred> - get() = viewModelScope.async(IO) { - repository.albumArtists() + private fun fetchPlaylists() { + viewModelScope.launch(IO) { + playlists.postValue(repository.fetchPlaylistWithSongs()) } + } - private val loadPlaylists: Deferred> - get() = viewModelScope.async(IO) { - repository.allPlaylists() - } - private val loadPlaylistsWithSongs: Deferred> - get() = viewModelScope.async(IO) { - repository.playlistWithSongs() + private fun fetchGenres() { + viewModelScope.launch(IO) { + genres.postValue(repository.fetchGenres()) } + } - private val loadGenres: Deferred> - get() = viewModelScope.async(IO) { - repository.allGenres() + private fun fetchHomeSections() { + viewModelScope.launch(IO) { + home.postValue(repository.homeSections()) } - + } fun forceReload(reloadType: ReloadType) = viewModelScope.launch { when (reloadType) { - Songs -> songs.value = loadSongs.await() - Albums -> albums.value = loadAlbums.await() - Artists -> artists.value = loadArtists.await() - HomeSections -> home.value = loadHome.await() - Playlists -> roomPlaylists.value = loadPlaylistsWithSongs.await() - Genres -> genres.value = loadGenres.await() + Songs -> fetchSongs() + Albums -> fetchAlbums() + Artists -> fetchArtists() + HomeSections -> fetchHomeSections() + Playlists -> fetchPlaylists() + Genres -> fetchGenres() } } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/NowPlayingScreen.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/NowPlayingScreen.kt index dacaff2d..19e08522 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/NowPlayingScreen.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/NowPlayingScreen.kt @@ -24,7 +24,6 @@ enum class NowPlayingScreen constructor( Gradient(R.string.gradient, R.drawable.np_gradient, 17), Material(R.string.material, R.drawable.np_material, 11), Normal(R.string.normal, R.drawable.np_normal, 0), - //Peak(R.string.peak, R.drawable.np_peak, 14), Plain(R.string.plain, R.drawable.np_plain, 3), Simple(R.string.simple, R.drawable.np_simple, 8), diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumDetailsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumDetailsFragment.kt index bd9516fb..6919e2a4 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumDetailsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumDetailsFragment.kt @@ -79,7 +79,7 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det toolbar.title = null postponeEnterTransition() - detailsViewModel.getAlbum2().observe(viewLifecycleOwner, Observer { + detailsViewModel.getAlbum().observe(viewLifecycleOwner, Observer { startPostponedEnterTransition() showAlbum(it) }) @@ -149,12 +149,11 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det this.album = album albumTitle.text = album.title - val songText = - resources.getQuantityString( - R.plurals.albumSongs, - album.songCount, - album.songCount - ) + val songText = resources.getQuantityString( + R.plurals.albumSongs, + album.songCount, + album.songCount + ) songTitle.text = songText if (MusicUtil.getYearString(album.year) == "-") { @@ -171,7 +170,7 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det MusicUtil.getReadableDurationString(MusicUtil.getTotalDuration(album.songs)) ) } - loadAlbumCover() + loadAlbumCover(album) simpleSongAdapter.swapDataSet(album.songs) detailsViewModel.loadArtist(album.artistId) detailsViewModel.loadAlbumInfo(album) @@ -216,6 +215,7 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det private fun loadArtistImage(artist: Artist) { ArtistGlideRequest.Builder.from(Glide.with(requireContext()), artist) + .forceDownload(PreferenceUtil.isAllowedToDownloadMetadata()) .generatePalette(requireContext()) .build() .dontAnimate() @@ -226,14 +226,11 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det }) } - private fun loadAlbumCover() { + private fun loadAlbumCover(album: Album) { AlbumGlideRequest.Builder.from(Glide.with(requireContext()), album.safeGetFirstSong()) - .checkIgnoreMediaStore(requireContext()) - .ignoreMediaStore(PreferenceUtil.isIgnoreMediaStoreArtwork) + .checkIgnoreMediaStore() .generatePalette(requireContext()) .build() - .dontAnimate() - .dontTransform() .into(object : SingleColorTarget(image) { override fun onColorReady(color: Int) { setColors(color) @@ -287,7 +284,7 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det } R.id.action_add_to_playlist -> { lifecycleScope.launch(Dispatchers.IO) { - val playlists = get().roomPlaylists() + val playlists = get().fetchPlaylists() withContext(Dispatchers.Main) { AddToRetroPlaylist.create(playlists, songs) .show(childFragmentManager, "ADD_PLAYLIST") diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumsFragment.kt index be1da592..9f7b7ce0 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumsFragment.kt @@ -23,7 +23,7 @@ class AlbumsFragment : AbsRecyclerViewCustomGridSizeFragment { lifecycleScope.launch(Dispatchers.IO) { - val playlists = get().roomPlaylists() + val playlists = get().fetchPlaylists() withContext(Dispatchers.Main) { AddToRetroPlaylist.create(playlists, songs) .show(childFragmentManager, "ADD_PLAYLIST") diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/artists/ArtistsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/artists/ArtistsFragment.kt index f0889914..b39909d3 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/artists/ArtistsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/artists/ArtistsFragment.kt @@ -22,7 +22,7 @@ class ArtistsFragment : AbsRecyclerViewCustomGridSizeFragment { lifecycleScope.launch(IO) { - val playlists = get().roomPlaylists() + val playlists = get().fetchPlaylists() withContext(Main) { AddToRetroPlaylist.create(playlists, song) .show(childFragmentManager, "ADD_PLAYLIST") diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/genres/GenresFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/genres/GenresFragment.kt index 93af4203..568da54a 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/genres/GenresFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/genres/GenresFragment.kt @@ -26,7 +26,7 @@ class GenresFragment : AbsRecyclerViewFragment() { + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - libraryViewModel.songsLiveData.observe(viewLifecycleOwner, Observer { + libraryViewModel.getSongs().observe(viewLifecycleOwner, Observer { + println(Thread.currentThread().name) if (it.isNotEmpty()) adapter?.swapDataSet(it) else diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/songs/SongsViewModel.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/songs/SongsViewModel.kt deleted file mode 100644 index 3ec068fc..00000000 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/songs/SongsViewModel.kt +++ /dev/null @@ -1,31 +0,0 @@ -package code.name.monkey.retromusic.fragments.songs - -import androidx.lifecycle.LiveData -import androidx.lifecycle.MutableLiveData -import androidx.lifecycle.ViewModel -import androidx.lifecycle.viewModelScope -import code.name.monkey.retromusic.model.Song -import code.name.monkey.retromusic.repository.SongRepository -import kotlinx.coroutines.Dispatchers.IO -import kotlinx.coroutines.launch - -class SongsViewModel( - private val songRepository: SongRepository -) : ViewModel() { - init { - update() - } - - private val songsData = MutableLiveData>().apply { value = mutableListOf() } - - fun getSongList(): LiveData> { - return songsData - } - - fun update() { - viewModelScope.launch(IO) { - val songs = songRepository.songs() - songsData.postValue(songs) - } - } -} \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/glide/AlbumGlideRequest.java b/app/src/main/java/code/name/monkey/retromusic/glide/AlbumGlideRequest.java index fab61c61..82e65da2 100644 --- a/app/src/main/java/code/name/monkey/retromusic/glide/AlbumGlideRequest.java +++ b/app/src/main/java/code/name/monkey/retromusic/glide/AlbumGlideRequest.java @@ -69,7 +69,7 @@ public class AlbumGlideRequest { } @NonNull - public Builder checkIgnoreMediaStore(@NonNull Context context) { + public Builder checkIgnoreMediaStore() { return ignoreMediaStore(PreferenceUtil.INSTANCE.isIgnoreMediaStoreArtwork()); } diff --git a/app/src/main/java/code/name/monkey/retromusic/helper/menu/GenreMenuHelper.kt b/app/src/main/java/code/name/monkey/retromusic/helper/menu/GenreMenuHelper.kt index df43e38d..c5a6af03 100644 --- a/app/src/main/java/code/name/monkey/retromusic/helper/menu/GenreMenuHelper.kt +++ b/app/src/main/java/code/name/monkey/retromusic/helper/menu/GenreMenuHelper.kt @@ -45,7 +45,7 @@ object GenreMenuHelper : KoinComponent { } R.id.action_add_to_playlist -> { CoroutineScope(Dispatchers.IO).launch { - val playlists = get().roomPlaylists() + val playlists = get().fetchPlaylists() withContext(Dispatchers.Main) { AddToRetroPlaylist.create(playlists, getGenreSongs(genre)) .show(activity.supportFragmentManager, "ADD_PLAYLIST") diff --git a/app/src/main/java/code/name/monkey/retromusic/helper/menu/PlaylistMenuHelper.kt b/app/src/main/java/code/name/monkey/retromusic/helper/menu/PlaylistMenuHelper.kt index 535804fe..6dccf62f 100644 --- a/app/src/main/java/code/name/monkey/retromusic/helper/menu/PlaylistMenuHelper.kt +++ b/app/src/main/java/code/name/monkey/retromusic/helper/menu/PlaylistMenuHelper.kt @@ -58,7 +58,7 @@ object PlaylistMenuHelper : KoinComponent { } R.id.action_add_to_playlist -> { CoroutineScope(Dispatchers.IO).launch { - val playlists = get().roomPlaylists() + val playlists = get().fetchPlaylists() withContext(Dispatchers.Main) { AddToRetroPlaylist.create(playlists, playlistWithSongs.songs.toSongs()) .show(activity.supportFragmentManager, "ADD_PLAYLIST") diff --git a/app/src/main/java/code/name/monkey/retromusic/helper/menu/SongMenuHelper.kt b/app/src/main/java/code/name/monkey/retromusic/helper/menu/SongMenuHelper.kt index 115926de..58182efb 100644 --- a/app/src/main/java/code/name/monkey/retromusic/helper/menu/SongMenuHelper.kt +++ b/app/src/main/java/code/name/monkey/retromusic/helper/menu/SongMenuHelper.kt @@ -71,7 +71,7 @@ object SongMenuHelper : KoinComponent { } R.id.action_add_to_playlist -> { CoroutineScope(Dispatchers.IO).launch { - val playlists = get().roomPlaylists() + val playlists = get().fetchPlaylists() withContext(Dispatchers.Main) { AddToRetroPlaylist.create(playlists, song) .show(activity.supportFragmentManager, "ADD_PLAYLIST") diff --git a/app/src/main/java/code/name/monkey/retromusic/helper/menu/SongsMenuHelper.kt b/app/src/main/java/code/name/monkey/retromusic/helper/menu/SongsMenuHelper.kt index 058de45f..243d22fd 100644 --- a/app/src/main/java/code/name/monkey/retromusic/helper/menu/SongsMenuHelper.kt +++ b/app/src/main/java/code/name/monkey/retromusic/helper/menu/SongsMenuHelper.kt @@ -45,7 +45,7 @@ object SongsMenuHelper : KoinComponent { } R.id.action_add_to_playlist -> { CoroutineScope(Dispatchers.IO).launch { - val playlists = get().roomPlaylists() + val playlists = get().fetchPlaylists() withContext(Dispatchers.Main) { AddToRetroPlaylist.create(playlists, songs) .show(activity.supportFragmentManager, "ADD_PLAYLIST") diff --git a/app/src/main/java/code/name/monkey/retromusic/network/RetrofitClient.kt b/app/src/main/java/code/name/monkey/retromusic/network/RetrofitClient.kt index afaaeb67..affb3823 100644 --- a/app/src/main/java/code/name/monkey/retromusic/network/RetrofitClient.kt +++ b/app/src/main/java/code/name/monkey/retromusic/network/RetrofitClient.kt @@ -1,7 +1,7 @@ package code.name.monkey.retromusic.network import code.name.monkey.retromusic.App -import code.name.monkey.retromusic.Constants.BASE_URL +import code.name.monkey.retromusic.Constants.AUDIO_SCROBBLER_URL import com.google.gson.Gson import okhttp3.Cache import okhttp3.ConnectionPool @@ -37,7 +37,7 @@ fun provideLastFmService(retrofit: Retrofit): LastFMService = retrofit.create(LastFMService::class.java) fun providerRetrofit(okHttpClient: OkHttpClient.Builder): Retrofit = Retrofit.Builder() - .baseUrl(BASE_URL) + .baseUrl(AUDIO_SCROBBLER_URL) .callFactory(okHttpClient.build()) .addConverterFactory(GsonConverterFactory.create(Gson())) .build() diff --git a/app/src/main/java/code/name/monkey/retromusic/repository/Repository.kt b/app/src/main/java/code/name/monkey/retromusic/repository/Repository.kt index a3575a6e..a89223e8 100644 --- a/app/src/main/java/code/name/monkey/retromusic/repository/Repository.kt +++ b/app/src/main/java/code/name/monkey/retromusic/repository/Repository.kt @@ -37,14 +37,14 @@ interface Repository { fun genresFlow(): Flow>> fun historySong(): LiveData> fun favorites(): LiveData> - suspend fun allAlbums(): List + suspend fun fetchAlbums(): List suspend fun albumByIdAsync(albumId: Int): Album fun albumById(albumId: Int): Album suspend fun allSongs(): List - suspend fun allArtists(): List + suspend fun fetchArtists(): List suspend fun albumArtists(): List suspend fun allPlaylists(): List - suspend fun allGenres(): List + suspend fun fetchGenres(): List suspend fun search(query: String?): MutableList suspend fun getPlaylistSongs(playlist: Playlist): List suspend fun getGenre(genreId: Int): List @@ -66,12 +66,12 @@ interface Repository { suspend fun homeSections(): List suspend fun homeSectionsFlow(): Flow>> suspend fun playlist(playlistId: Int): Playlist - suspend fun playlistWithSongs(): List + suspend fun fetchPlaylistWithSongs(): List suspend fun playlistSongs(playlistWithSongs: PlaylistWithSongs): List suspend fun insertSongs(songs: List) suspend fun checkPlaylistExists(playlistName: String): List suspend fun createPlaylist(playlistEntity: PlaylistEntity): Long - suspend fun roomPlaylists(): List + suspend fun fetchPlaylists(): List suspend fun deleteRoomPlaylist(playlists: List) suspend fun renameRoomPlaylist(playlistId: Int, name: String) suspend fun deleteSongsInPlaylist(songs: List) @@ -107,11 +107,11 @@ class RealRepository( private val roomRepository: RoomRepository ) : Repository { - override suspend fun allAlbums(): List = albumRepository.albums() + override suspend fun fetchAlbums(): List = albumRepository.albums() override suspend fun albumByIdAsync(albumId: Int): Album = albumRepository.album(albumId) override fun albumById(albumId: Int): Album = albumRepository.album(albumId) - override suspend fun allArtists(): List = artistRepository.artists() + override suspend fun fetchArtists(): List = artistRepository.artists() override suspend fun albumArtists(): List = artistRepository.albumArtists() @@ -127,7 +127,7 @@ class RealRepository( override suspend fun allPlaylists(): List = playlistRepository.playlists() - override suspend fun allGenres(): List = genreRepository.genres() + override suspend fun fetchGenres(): List = genreRepository.genres() override suspend fun allSongs(): List = songRepository.songs() @@ -205,7 +205,7 @@ class RealRepository( override suspend fun playlist(playlistId: Int) = playlistRepository.playlist(playlistId) - override suspend fun playlistWithSongs(): List = + override suspend fun fetchPlaylistWithSongs(): List = roomRepository.playlistWithSongs() override suspend fun playlistSongs(playlistWithSongs: PlaylistWithSongs): List = @@ -222,7 +222,7 @@ class RealRepository( override suspend fun createPlaylist(playlistEntity: PlaylistEntity): Long = roomRepository.createPlaylist(playlistEntity) - override suspend fun roomPlaylists(): List = roomRepository.playlists() + override suspend fun fetchPlaylists(): List = roomRepository.playlists() override suspend fun deleteRoomPlaylist(playlists: List) = roomRepository.deletePlaylistEntities(playlists) diff --git a/app/src/main/java/code/name/monkey/retromusic/service/MusicService.java b/app/src/main/java/code/name/monkey/retromusic/service/MusicService.java index 64dfe785..eff55a60 100644 --- a/app/src/main/java/code/name/monkey/retromusic/service/MusicService.java +++ b/app/src/main/java/code/name/monkey/retromusic/service/MusicService.java @@ -84,11 +84,11 @@ import code.name.monkey.retromusic.util.MusicUtil; import code.name.monkey.retromusic.util.PreferenceUtil; import code.name.monkey.retromusic.util.RetroUtil; -import static code.name.monkey.retromusic.ConstantsKt.ALBUM_ART_ON_LOCKSCREEN; +import static code.name.monkey.retromusic.ConstantsKt.ALBUM_ART_ON_LOCK_SCREEN; import static code.name.monkey.retromusic.ConstantsKt.BLURRED_ALBUM_ART; import static code.name.monkey.retromusic.ConstantsKt.CLASSIC_NOTIFICATION; import static code.name.monkey.retromusic.ConstantsKt.COLORED_NOTIFICATION; -import static code.name.monkey.retromusic.ConstantsKt.GAPLESS_PLAYBACK; +import static code.name.monkey.retromusic.ConstantsKt.GAP_LESS_PLAYBACK; import static code.name.monkey.retromusic.ConstantsKt.TOGGLE_HEADSET; /** @@ -727,7 +727,7 @@ public class MusicService extends Service implements @Override public void onSharedPreferenceChanged(@NonNull SharedPreferences sharedPreferences, @NonNull String key) { switch (key) { - case GAPLESS_PLAYBACK: + case GAP_LESS_PLAYBACK: if (sharedPreferences.getBoolean(key, false)) { prepareNext(); } else { @@ -736,7 +736,7 @@ public class MusicService extends Service implements } } break; - case ALBUM_ART_ON_LOCKSCREEN: + case ALBUM_ART_ON_LOCK_SCREEN: case BLURRED_ALBUM_ART: updateMediaSessionMetaData(); break; diff --git a/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.kt b/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.kt index 5ee2ac60..9b4d427e 100644 --- a/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.kt +++ b/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.kt @@ -243,7 +243,7 @@ object PreferenceUtil { val isAlbumArtOnLockScreen get() = sharedPreferences.getBoolean( - ALBUM_ART_ON_LOCKSCREEN, false + ALBUM_ART_ON_LOCK_SCREEN, false ) val isAudioDucking @@ -292,7 +292,7 @@ object PreferenceUtil { val isGapLessPlayback get() = sharedPreferences.getBoolean( - GAPLESS_PLAYBACK, false + GAP_LESS_PLAYBACK, false ) val isAdaptiveColor @@ -471,7 +471,7 @@ object PreferenceUtil { var artistGridSizeLand get() = sharedPreferences.getInt( - ALBUM_GRID_SIZE_LAND, + ARTIST_GRID_SIZE_LAND, App.getContext().getIntRes(R.integer.default_grid_columns_land) ) set(value) = sharedPreferences.edit { diff --git a/app/src/main/res/layout/abs_playlists.xml b/app/src/main/res/layout/abs_playlists.xml index a0b8d1d2..73df4233 100644 --- a/app/src/main/res/layout/abs_playlists.xml +++ b/app/src/main/res/layout/abs_playlists.xml @@ -6,7 +6,6 @@ android:orientation="vertical" android:paddingBottom="12dp"> -