Code refactor and Genre category added to home
This commit is contained in:
parent
d4ab36fd69
commit
c23e959356
21 changed files with 149 additions and 58 deletions
|
@ -1,11 +0,0 @@
|
|||
package code.name.monkey.retromusic.providers
|
||||
|
||||
import org.eclipse.egit.github.core.Repository
|
||||
import org.koin.dsl.bind
|
||||
import org.koin.dsl.module
|
||||
|
||||
val provideModules = module {
|
||||
single {
|
||||
RepositoryImpl(get(), get())
|
||||
} bind Repository::class
|
||||
}
|
|
@ -32,19 +32,19 @@ class RepositoryImpl(
|
|||
|
||||
override suspend fun allAlbums(): List<Album> = AlbumLoader.getAllAlbums(context)
|
||||
|
||||
override suspend fun albumById(albumId: Int): Album = AlbumLoader.getAlbum(context, albumId)
|
||||
|
||||
override suspend fun allArtists(): List<Artist> = ArtistLoader.getAllArtists(context)
|
||||
|
||||
override suspend fun artistById(artistId: Int): Artist =
|
||||
ArtistLoader.getArtist(context, artistId)
|
||||
|
||||
override suspend fun allPlaylists(): List<Playlist> = PlaylistLoader.getAllPlaylists(context)
|
||||
|
||||
override suspend fun allGenres(): List<Genre> = GenreLoader.getAllGenres(context)
|
||||
|
||||
override suspend fun allSongs(): List<Song> = SongLoader.getAllSongs(context)
|
||||
|
||||
override suspend fun albumById(albumId: Int): Album = AlbumLoader.getAlbum(context, albumId)
|
||||
|
||||
override suspend fun artistById(artistId: Int): Artist =
|
||||
ArtistLoader.getArtist(context, artistId)
|
||||
|
||||
override suspend fun suggestions(): Home? {
|
||||
val songs = NotRecentlyPlayedPlaylist(context).getSongs(context).shuffled().apply {
|
||||
if (size > 9) subList(0, 9)
|
||||
|
@ -59,6 +59,23 @@ class RepositoryImpl(
|
|||
return null
|
||||
}
|
||||
|
||||
override suspend fun homeGenres(): Home? {
|
||||
val genres =
|
||||
GenreLoader.getAllGenres(context)
|
||||
.shuffled()
|
||||
.take(10)
|
||||
.filter { it.name.length > 4 }
|
||||
|
||||
if (genres.isNotEmpty()) {
|
||||
return Home(
|
||||
genres,
|
||||
HomeAdapter.GENRES,
|
||||
R.drawable.ic_guitar
|
||||
)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override suspend fun search(query: String?): MutableList<Any> =
|
||||
SearchLoader.searchAll(context, query)
|
||||
|
||||
|
|
|
@ -58,4 +58,6 @@ interface Repository {
|
|||
suspend fun favoritePlaylist(): Home?
|
||||
|
||||
suspend fun suggestions(): Home?
|
||||
|
||||
suspend fun homeGenres(): Home?
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue