2020-07-20 19:05:48 +00:00
|
|
|
package code.name.monkey.retromusic
|
|
|
|
|
2020-08-19 18:43:06 +00:00
|
|
|
import code.name.monkey.retromusic.db.PlaylistDatabase
|
2020-08-20 06:49:08 +00:00
|
|
|
import code.name.monkey.retromusic.db.RealRoomPlaylistRepository
|
|
|
|
import code.name.monkey.retromusic.db.RoomPlaylistRepository
|
2020-08-13 17:08:37 +00:00
|
|
|
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
2020-08-11 18:29:44 +00:00
|
|
|
import code.name.monkey.retromusic.fragments.albums.AlbumDetailsViewModel
|
|
|
|
import code.name.monkey.retromusic.fragments.artists.ArtistDetailsViewModel
|
|
|
|
import code.name.monkey.retromusic.fragments.genres.GenreDetailsViewModel
|
|
|
|
import code.name.monkey.retromusic.fragments.playlists.PlaylistDetailsViewModel
|
2020-08-11 18:58:14 +00:00
|
|
|
import code.name.monkey.retromusic.fragments.search.SearchViewModel
|
2020-07-20 19:05:48 +00:00
|
|
|
import code.name.monkey.retromusic.model.Genre
|
|
|
|
import code.name.monkey.retromusic.model.Playlist
|
2020-07-25 20:22:37 +00:00
|
|
|
import code.name.monkey.retromusic.network.networkModule
|
2020-08-13 17:08:37 +00:00
|
|
|
import code.name.monkey.retromusic.repository.*
|
|
|
|
import org.koin.android.ext.koin.androidContext
|
2020-07-25 20:22:37 +00:00
|
|
|
import org.koin.androidx.viewmodel.dsl.viewModel
|
|
|
|
import org.koin.dsl.bind
|
2020-07-20 19:05:48 +00:00
|
|
|
import org.koin.dsl.module
|
|
|
|
|
2020-08-20 06:49:08 +00:00
|
|
|
private val mainModule = module {
|
|
|
|
single {
|
|
|
|
androidContext().contentResolver
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2020-07-25 20:22:37 +00:00
|
|
|
private val dataModule = module {
|
|
|
|
single {
|
2020-08-20 06:49:08 +00:00
|
|
|
RealRepository(get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get())
|
2020-07-25 20:22:37 +00:00
|
|
|
} bind Repository::class
|
2020-08-13 17:08:37 +00:00
|
|
|
|
|
|
|
single {
|
|
|
|
RealSongRepository(get())
|
|
|
|
} bind SongRepository::class
|
|
|
|
|
|
|
|
single {
|
|
|
|
RealGenreRepository(get(), get())
|
|
|
|
} bind GenreRepository::class
|
|
|
|
|
|
|
|
single {
|
|
|
|
RealAlbumRepository(get())
|
|
|
|
} bind AlbumRepository::class
|
|
|
|
|
|
|
|
single {
|
|
|
|
RealArtistRepository(get(), get())
|
|
|
|
} bind ArtistRepository::class
|
|
|
|
|
|
|
|
single {
|
|
|
|
RealPlaylistRepository(get())
|
|
|
|
} bind PlaylistRepository::class
|
|
|
|
|
|
|
|
single {
|
|
|
|
RealTopPlayedRepository(get(), get(), get(), get())
|
|
|
|
} bind TopPlayedRepository::class
|
|
|
|
|
|
|
|
single {
|
|
|
|
RealLastAddedRepository(
|
|
|
|
get(),
|
|
|
|
get(),
|
|
|
|
get()
|
|
|
|
)
|
|
|
|
} bind LastAddedRepository::class
|
|
|
|
|
|
|
|
single {
|
|
|
|
RealSearchRepository(
|
|
|
|
get(),
|
|
|
|
get(),
|
|
|
|
get(),
|
|
|
|
get(),
|
|
|
|
get()
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
single {
|
2020-08-20 06:49:08 +00:00
|
|
|
PlaylistDatabase.getDatabase(get()).playlistDao()
|
2020-08-13 17:08:37 +00:00
|
|
|
}
|
2020-08-19 18:43:06 +00:00
|
|
|
|
|
|
|
single {
|
2020-08-20 06:49:08 +00:00
|
|
|
RealRoomPlaylistRepository(get())
|
|
|
|
} bind RoomPlaylistRepository::class
|
2020-07-25 20:22:37 +00:00
|
|
|
}
|
2020-07-20 19:05:48 +00:00
|
|
|
|
2020-07-25 20:22:37 +00:00
|
|
|
private val viewModules = module {
|
2020-07-20 19:05:48 +00:00
|
|
|
|
|
|
|
viewModel {
|
|
|
|
LibraryViewModel(get())
|
|
|
|
}
|
|
|
|
|
|
|
|
viewModel { (albumId: Int) ->
|
2020-08-11 18:29:44 +00:00
|
|
|
AlbumDetailsViewModel(
|
|
|
|
get(),
|
|
|
|
albumId
|
|
|
|
)
|
2020-07-20 19:05:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
viewModel { (artistId: Int) ->
|
2020-08-11 18:29:44 +00:00
|
|
|
ArtistDetailsViewModel(
|
|
|
|
get(),
|
|
|
|
artistId
|
|
|
|
)
|
2020-07-20 19:05:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
viewModel { (playlist: Playlist) ->
|
2020-08-11 18:29:44 +00:00
|
|
|
PlaylistDetailsViewModel(
|
|
|
|
get(),
|
|
|
|
playlist
|
|
|
|
)
|
2020-07-20 19:05:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
viewModel { (genre: Genre) ->
|
2020-08-11 18:29:44 +00:00
|
|
|
GenreDetailsViewModel(
|
|
|
|
get(),
|
|
|
|
genre
|
|
|
|
)
|
2020-07-20 19:05:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
viewModel {
|
|
|
|
SearchViewModel(get())
|
|
|
|
}
|
2020-07-25 20:22:37 +00:00
|
|
|
}
|
|
|
|
|
2020-08-20 06:49:08 +00:00
|
|
|
val appModules = listOf(mainModule, dataModule, viewModules, networkModule)
|