Code fixes

This commit is contained in:
Hemanth S 2020-10-04 14:43:42 +05:30
parent c23c56649e
commit f02888113e
4 changed files with 10 additions and 14 deletions

View file

@ -60,7 +60,7 @@ open class SongAdapter(
} }
override fun getItemId(position: Int): Long { override fun getItemId(position: Int): Long {
return dataSet[position].id.toLong() return dataSet[position].id
} }
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {

View file

@ -14,14 +14,10 @@ class PlaylistDetailsViewModel(
private var playlist: PlaylistWithSongs private var playlist: PlaylistWithSongs
) : ViewModel(), IMusicServiceEventListener { ) : ViewModel(), IMusicServiceEventListener {
private val _playListSongs = MutableLiveData<List<Song>>() private val playListSongs = MutableLiveData<List<Song>>()
private val _playlist = MutableLiveData<PlaylistWithSongs>().apply {
postValue(playlist)
}
fun getPlaylist(): LiveData<PlaylistWithSongs> = _playlist fun getSongs(): LiveData<List<SongEntity>> =
realRepository.playlistSongs(playlist.playlistEntity.playListId)
fun getSongs(): LiveData<List<SongEntity>> = realRepository.playlistSongs(playlist.playlistEntity)
override fun onMediaStoreChanged() { override fun onMediaStoreChanged() {

View file

@ -42,7 +42,7 @@ interface Repository {
fun favorites(): LiveData<List<SongEntity>> fun favorites(): LiveData<List<SongEntity>>
fun observableHistorySongs(): LiveData<List<Song>> fun observableHistorySongs(): LiveData<List<Song>>
fun albumById(albumId: Long): Album fun albumById(albumId: Long): Album
fun playlistSongs(playlistEntity: PlaylistEntity): LiveData<List<SongEntity>> fun playlistSongs(playListId: Long): LiveData<List<SongEntity>>
suspend fun fetchAlbums(): List<Album> suspend fun fetchAlbums(): List<Album>
suspend fun albumByIdAsync(albumId: Long): Album suspend fun albumByIdAsync(albumId: Long): Album
suspend fun allSongs(): List<Song> suspend fun allSongs(): List<Song>
@ -252,8 +252,8 @@ class RealRepository(
it.toSong() it.toSong()
} }
override fun playlistSongs(playlistEntity: PlaylistEntity): LiveData<List<SongEntity>> = override fun playlistSongs(playListId: Long): LiveData<List<SongEntity>> =
roomRepository.getSongs(playlistEntity) roomRepository.getSongs(playListId)
override suspend fun insertSongs(songs: List<SongEntity>) = override suspend fun insertSongs(songs: List<SongEntity>) =
roomRepository.insertSongs(songs) roomRepository.insertSongs(songs)

View file

@ -11,7 +11,7 @@ interface RoomRepository {
fun favoritePlaylistLiveData(favorite: String): LiveData<List<SongEntity>> fun favoritePlaylistLiveData(favorite: String): LiveData<List<SongEntity>>
fun insertBlacklistPath(blackListStoreEntity: BlackListStoreEntity) fun insertBlacklistPath(blackListStoreEntity: BlackListStoreEntity)
fun observableHistorySongs(): LiveData<List<HistoryEntity>> fun observableHistorySongs(): LiveData<List<HistoryEntity>>
fun getSongs(playlistEntity: PlaylistEntity): LiveData<List<SongEntity>> fun getSongs(playListId: Long): LiveData<List<SongEntity>>
suspend fun createPlaylist(playlistEntity: PlaylistEntity): Long suspend fun createPlaylist(playlistEntity: PlaylistEntity): Long
suspend fun checkPlaylistExists(playlistName: String): List<PlaylistEntity> suspend fun checkPlaylistExists(playlistName: String): List<PlaylistEntity>
suspend fun playlists(): List<PlaylistEntity> suspend fun playlists(): List<PlaylistEntity>
@ -70,8 +70,8 @@ class RealRoomRepository(
} }
override fun getSongs(playlistEntity: PlaylistEntity): LiveData<List<SongEntity>> = override fun getSongs(playListId: Long): LiveData<List<SongEntity>> =
playlistDao.songsFromPlaylist(playlistEntity.playListId) playlistDao.songsFromPlaylist(playListId)
override suspend fun deletePlaylistEntities(playlistEntities: List<PlaylistEntity>) = override suspend fun deletePlaylistEntities(playlistEntities: List<PlaylistEntity>) =
playlistDao.deletePlaylists(playlistEntities) playlistDao.deletePlaylists(playlistEntities)