Merge branch 'room-playlist' of https://github.com/h4h13/RetroMusicPlayer into room-playlist

This commit is contained in:
Hemanth S 2020-09-05 19:33:16 +05:30
commit c050ce3fbd
2 changed files with 8 additions and 15 deletions

View file

@ -2,6 +2,7 @@ package code.name.monkey.retromusic.fragments.base
import android.content.ContentUris import android.content.ContentUris
import android.content.Intent import android.content.Intent
import android.graphics.drawable.Drawable
import android.media.MediaMetadataRetriever import android.media.MediaMetadataRetriever
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
@ -21,6 +22,7 @@ import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.activities.tageditor.AbsTagEditorActivity import code.name.monkey.retromusic.activities.tageditor.AbsTagEditorActivity
import code.name.monkey.retromusic.activities.tageditor.SongTagEditorActivity import code.name.monkey.retromusic.activities.tageditor.SongTagEditorActivity
import code.name.monkey.retromusic.db.PlaylistEntity import code.name.monkey.retromusic.db.PlaylistEntity
import code.name.monkey.retromusic.db.SongEntity
import code.name.monkey.retromusic.dialogs.* import code.name.monkey.retromusic.dialogs.*
import code.name.monkey.retromusic.extensions.hide import code.name.monkey.retromusic.extensions.hide
import code.name.monkey.retromusic.extensions.whichFragment import code.name.monkey.retromusic.extensions.whichFragment
@ -201,12 +203,14 @@ abstract class AbsPlayerFragment(@LayoutRes layout: Int) : AbsMainActivityFragme
lifecycleScope.launch(IO) { lifecycleScope.launch(IO) {
val playlist: PlaylistEntity? = libraryViewModel.favoritePlaylist() val playlist: PlaylistEntity? = libraryViewModel.favoritePlaylist()
if (playlist != null) { if (playlist != null) {
val song = MusicPlayerRemote.currentSong.toSongEntity(playlist.playListId) val song: SongEntity =
val isFavorite = libraryViewModel.isFavoriteSong(song).isNotEmpty() MusicPlayerRemote.currentSong.toSongEntity(playlist.playListId)
val isFavorite: Boolean = libraryViewModel.isFavoriteSong(song).isNotEmpty()
withContext(Main) { withContext(Main) {
val icon = val icon =
if (isFavorite) R.drawable.ic_favorite else R.drawable.ic_favorite_border if (isFavorite) R.drawable.ic_favorite else R.drawable.ic_favorite_border
val drawable = val drawable: Drawable? =
RetroUtil.getTintedVectorDrawable( RetroUtil.getTintedVectorDrawable(
requireContext(), requireContext(),
icon, icon,

View file

@ -5,10 +5,6 @@
android:id="@+id/retro_graph" android:id="@+id/retro_graph"
app:startDestination="@id/libraryFragment"> app:startDestination="@id/libraryFragment">
<include app:graph="@navigation/settings_graph" />
<include app:graph="@navigation/library_graph" />
<fragment <fragment
android:id="@+id/genreDetailsFragment" android:id="@+id/genreDetailsFragment"
android:name="code.name.monkey.retromusic.fragments.genres.GenreDetailsFragment" android:name="code.name.monkey.retromusic.fragments.genres.GenreDetailsFragment"
@ -53,14 +49,7 @@
android:id="@+id/libraryFragment" android:id="@+id/libraryFragment"
android:name="code.name.monkey.retromusic.fragments.library.LibraryFragment" android:name="code.name.monkey.retromusic.fragments.library.LibraryFragment"
android:label="" android:label=""
tools:layout="@layout/fragment_library"> tools:layout="@layout/fragment_library" />
<action
android:id="@+id/action_main_to_library"
app:destination="@id/library_graph" />
<action
android:id="@+id/action_main_to_settings"
app:destination="@id/settings_graph" />
</fragment>
<fragment <fragment
android:id="@+id/detailListFragment" android:id="@+id/detailListFragment"