-
-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
music: build saf loader playlist boilerplate
- Loading branch information
1 parent
ba9ab5a
commit c4f4797
Showing
11 changed files
with
140 additions
and
399 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
app/src/main/java/org/oxycblt/auxio/music/stack/explore/playlists/StoredPlaylists.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.oxycblt.auxio.music.stack.explore.playlists | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.asFlow | ||
import kotlinx.coroutines.flow.emitAll | ||
import kotlinx.coroutines.flow.flow | ||
import kotlinx.coroutines.flow.map | ||
import org.oxycblt.auxio.music.stack.explore.PlaylistFile | ||
import org.oxycblt.auxio.music.stack.explore.SongPointer | ||
import javax.inject.Inject | ||
|
||
interface StoredPlaylists { | ||
fun read(): Flow<PlaylistFile> | ||
} | ||
|
||
class StoredPlaylistsImpl @Inject constructor( | ||
private val playlistDao: PlaylistDao | ||
) : StoredPlaylists { | ||
override fun read() = flow { | ||
emitAll(playlistDao.readRawPlaylists() | ||
.asFlow() | ||
.map { | ||
TODO() | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
app/src/main/java/org/oxycblt/auxio/music/stack/interpret/linker/PlaylistLinker.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.oxycblt.auxio.music.stack.interpret.linker | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.emptyFlow | ||
import org.oxycblt.auxio.music.stack.explore.PlaylistFile | ||
import org.oxycblt.auxio.music.stack.interpret.model.GenreImpl | ||
import org.oxycblt.auxio.music.stack.interpret.model.PlaylistImpl | ||
import org.oxycblt.auxio.music.stack.interpret.model.SongImpl | ||
import org.oxycblt.auxio.music.stack.interpret.prepare.PreSong | ||
|
||
|
||
class PlaylistLinker { | ||
fun register(playlists: Flow<PlaylistFile>, linkedSongs: Flow<AlbumLinker.LinkedSong>): Flow<LinkedPlaylist> = emptyFlow() | ||
fun resolve(): Collection<PlaylistImpl> = setOf() | ||
} |
51 changes: 51 additions & 0 deletions
51
app/src/main/java/org/oxycblt/auxio/music/stack/interpret/model/PlaylistImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (c) 2023 Auxio Project | ||
* PlaylistImpl.kt is part of Auxio. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package org.oxycblt.auxio.music.stack.interpret.model | ||
|
||
import org.oxycblt.auxio.image.extractor.ParentCover | ||
import org.oxycblt.auxio.music.Music | ||
import org.oxycblt.auxio.music.MusicType | ||
import org.oxycblt.auxio.music.Playlist | ||
import org.oxycblt.auxio.music.Song | ||
import org.oxycblt.auxio.music.info.Name | ||
import org.oxycblt.auxio.music.stack.explore.PlaylistFile | ||
import org.oxycblt.auxio.music.stack.explore.playlists.RawPlaylist | ||
import org.oxycblt.auxio.music.stack.interpret.linker.LinkedPlaylist | ||
|
||
class PlaylistImpl(linkedPlaylist: LinkedPlaylist) : Playlist { | ||
private val prePlaylist = linkedPlaylist.prePlaylist | ||
override val uid = prePlaylist.handle.uid | ||
override val name: Name.Known = prePlaylist.name | ||
override val songs = linkedPlaylist.songs.resolve(this) | ||
override val durationMs = songs.sumOf { it.durationMs } | ||
override val cover = songs.takeIf { it.isNotEmpty() }?.let { ParentCover.from(it.first(), it) } | ||
private var hashCode = uid.hashCode() | ||
|
||
init { | ||
hashCode = 31 * hashCode + prePlaylist.hashCode() | ||
hashCode = 31 * hashCode + songs.hashCode() | ||
} | ||
|
||
override fun equals(other: Any?) = | ||
other is PlaylistImpl && prePlaylist == other.prePlaylist && songs == other.songs | ||
|
||
override fun hashCode() = hashCode | ||
|
||
override fun toString() = "Playlist(uid=$uid, name=$name)" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 0 additions & 103 deletions
103
app/src/main/java/org/oxycblt/auxio/music/user/PlaylistImpl.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.