Migrate database (2)

This commit is contained in:
vfsfitvnm
2022-06-29 15:03:20 +02:00
parent a7bdda074b
commit 6f5bc02216
13 changed files with 545 additions and 145 deletions

View File

@@ -20,7 +20,7 @@ import it.vfsfitvnm.vimusic.*
import it.vfsfitvnm.vimusic.R
import it.vfsfitvnm.vimusic.models.Playlist
import it.vfsfitvnm.vimusic.models.SongInPlaylist
import it.vfsfitvnm.vimusic.models.SongWithInfo
import it.vfsfitvnm.vimusic.models.DetailedSong
import it.vfsfitvnm.vimusic.ui.components.LocalMenuState
import it.vfsfitvnm.vimusic.ui.screens.rememberArtistRoute
import it.vfsfitvnm.vimusic.ui.screens.rememberCreatePlaylistRoute
@@ -32,7 +32,7 @@ import kotlinx.coroutines.Dispatchers
@ExperimentalAnimationApi
@Composable
fun InFavoritesMediaItemMenu(
song: SongWithInfo,
song: DetailedSong,
modifier: Modifier = Modifier,
onDismiss: (() -> Unit)? = null
) {
@@ -51,7 +51,7 @@ fun InFavoritesMediaItemMenu(
@ExperimentalAnimationApi
@Composable
fun InHistoryMediaItemMenu(
song: SongWithInfo,
song: DetailedSong,
modifier: Modifier = Modifier,
onDismiss: (() -> Unit)? = null
) {
@@ -94,7 +94,7 @@ fun InHistoryMediaItemMenu(
fun InPlaylistMediaItemMenu(
playlistId: Long,
positionInPlaylist: Int,
song: SongWithInfo,
song: DetailedSong,
modifier: Modifier = Modifier,
onDismiss: (() -> Unit)? = null
) {

View File

@@ -28,7 +28,7 @@ import it.vfsfitvnm.route.RouteHandler
import it.vfsfitvnm.vimusic.Database
import it.vfsfitvnm.vimusic.LocalPlayerServiceBinder
import it.vfsfitvnm.vimusic.R
import it.vfsfitvnm.vimusic.models.SongWithInfo
import it.vfsfitvnm.vimusic.models.DetailedSong
import it.vfsfitvnm.vimusic.ui.components.OutcomeItem
import it.vfsfitvnm.vimusic.ui.components.TopAppBar
import it.vfsfitvnm.vimusic.ui.components.themed.InHistoryMediaItemMenu
@@ -40,6 +40,7 @@ import it.vfsfitvnm.vimusic.utils.*
import it.vfsfitvnm.youtubemusic.Outcome
import it.vfsfitvnm.youtubemusic.YouTube
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.withContext
@@ -96,8 +97,9 @@ fun ArtistScreen(
}
val songs by remember(browseId) {
Database.artistSongs(browseId)
}.collectAsState(initial = emptyList(), context = Dispatchers.IO)
flowOf(emptyList<DetailedSong>())
// Database.artistSongs(browseId)
}.collectAsState(initial = emptyList<DetailedSong>(), context = Dispatchers.IO)
LazyColumn(
state = lazyListState,
@@ -218,7 +220,7 @@ fun ArtistScreen(
modifier = Modifier
.clickable(enabled = songs.isNotEmpty()) {
binder?.stopRadio()
binder?.player?.forcePlayFromBeginning(songs.shuffled().map(SongWithInfo::asMediaItem))
binder?.player?.forcePlayFromBeginning(songs.shuffled().map(DetailedSong::asMediaItem))
}
.padding(horizontal = 8.dp, vertical = 8.dp)
.size(20.dp)
@@ -236,7 +238,7 @@ fun ArtistScreen(
thumbnailSize = songThumbnailSizePx,
onClick = {
binder?.stopRadio()
binder?.player?.forcePlayAtIndex(songs.map(SongWithInfo::asMediaItem), index)
binder?.player?.forcePlayAtIndex(songs.map(DetailedSong::asMediaItem), index)
},
menuContent = {
InHistoryMediaItemMenu(song = song)

View File

@@ -37,7 +37,7 @@ import it.vfsfitvnm.vimusic.enums.SongCollection
import it.vfsfitvnm.vimusic.enums.ThumbnailRoundness
import it.vfsfitvnm.vimusic.models.Playlist
import it.vfsfitvnm.vimusic.models.SearchQuery
import it.vfsfitvnm.vimusic.models.SongWithInfo
import it.vfsfitvnm.vimusic.models.DetailedSong
import it.vfsfitvnm.vimusic.query
import it.vfsfitvnm.vimusic.ui.components.TopAppBar
import it.vfsfitvnm.vimusic.ui.components.themed.InFavoritesMediaItemMenu
@@ -358,7 +358,7 @@ fun HomeScreen() {
modifier = Modifier
.clickable(enabled = songCollection.isNotEmpty()) {
binder?.stopRadio()
binder?.player?.forcePlayFromBeginning(songCollection.shuffled().map(SongWithInfo::asMediaItem))
binder?.player?.forcePlayFromBeginning(songCollection.shuffled().map(DetailedSong::asMediaItem))
}
.padding(horizontal = 8.dp, vertical = 8.dp)
.size(20.dp)
@@ -378,7 +378,7 @@ fun HomeScreen() {
thumbnailSize = thumbnailSize,
onClick = {
binder?.stopRadio()
binder?.player?.forcePlayAtIndex(songCollection.map(SongWithInfo::asMediaItem), index)
binder?.player?.forcePlayAtIndex(songCollection.map(DetailedSong::asMediaItem), index)
},
menuContent = {
when (preferences.homePageSongCollection) {

View File

@@ -28,7 +28,7 @@ import it.vfsfitvnm.vimusic.*
import it.vfsfitvnm.vimusic.R
import it.vfsfitvnm.vimusic.models.PlaylistWithSongs
import it.vfsfitvnm.vimusic.models.SongInPlaylist
import it.vfsfitvnm.vimusic.models.SongWithInfo
import it.vfsfitvnm.vimusic.models.DetailedSong
import it.vfsfitvnm.vimusic.ui.components.LocalMenuState
import it.vfsfitvnm.vimusic.ui.components.TopAppBar
import it.vfsfitvnm.vimusic.ui.components.themed.*
@@ -160,7 +160,7 @@ fun LocalPlaylistScreen(
enabled = playlistWithSongs.songs.isNotEmpty(),
onClick = {
menuState.hide()
binder?.player?.enqueue(playlistWithSongs.songs.map(SongWithInfo::asMediaItem))
binder?.player?.enqueue(playlistWithSongs.songs.map(DetailedSong::asMediaItem))
}
)
@@ -225,7 +225,7 @@ fun LocalPlaylistScreen(
modifier = Modifier
.clickable {
binder?.stopRadio()
binder?.player?.forcePlayFromBeginning(playlistWithSongs.songs.map(SongWithInfo::asMediaItem).shuffled())
binder?.player?.forcePlayFromBeginning(playlistWithSongs.songs.map(DetailedSong::asMediaItem).shuffled())
}
.shadow(elevation = 2.dp, shape = CircleShape)
.background(
@@ -243,7 +243,7 @@ fun LocalPlaylistScreen(
modifier = Modifier
.clickable {
binder?.stopRadio()
binder?.player?.forcePlayFromBeginning(playlistWithSongs.songs.map(SongWithInfo::asMediaItem))
binder?.player?.forcePlayFromBeginning(playlistWithSongs.songs.map(DetailedSong::asMediaItem))
}
.shadow(elevation = 2.dp, shape = CircleShape)
.background(
@@ -267,7 +267,7 @@ fun LocalPlaylistScreen(
thumbnailSize = thumbnailSize,
onClick = {
binder?.stopRadio()
binder?.player?.forcePlayAtIndex(playlistWithSongs.songs.map(SongWithInfo::asMediaItem), index)
binder?.player?.forcePlayAtIndex(playlistWithSongs.songs.map(DetailedSong::asMediaItem), index)
},
menuContent = {
InPlaylistMediaItemMenu(

View File

@@ -26,7 +26,7 @@ import coil.compose.AsyncImage
import coil.request.ImageRequest
import it.vfsfitvnm.vimusic.R
import it.vfsfitvnm.vimusic.enums.ThumbnailRoundness
import it.vfsfitvnm.vimusic.models.SongWithInfo
import it.vfsfitvnm.vimusic.models.DetailedSong
import it.vfsfitvnm.vimusic.ui.components.LocalMenuState
import it.vfsfitvnm.vimusic.ui.styling.LocalColorPalette
import it.vfsfitvnm.vimusic.ui.styling.LocalTypography
@@ -67,7 +67,7 @@ fun SongItem(
@Composable
@NonRestartableComposable
fun SongItem(
song: SongWithInfo,
song: DetailedSong,
thumbnailSize: Int,
onClick: () -> Unit,
menuContent: @Composable () -> Unit,
@@ -78,7 +78,7 @@ fun SongItem(
SongItem(
thumbnailModel = song.song.thumbnailUrl?.thumbnail(thumbnailSize),
title = song.song.title,
authors = song.authors?.joinToString("") { it.text } ?: "",
authors = song.song.artistsText ?: "",
durationText = song.song.durationText,
menuContent = menuContent,
onClick = onClick,