music: add playlist creation stub
Add a stub for creating a new playlist. UX details are not worked out yet, so the functionality is still extremely bare.
This commit is contained in:
parent
a5176d6209
commit
cb69400905
2 changed files with 20 additions and 3 deletions
|
|
@ -33,6 +33,7 @@ import org.oxycblt.auxio.music.device.DeviceLibrary
|
||||||
import org.oxycblt.auxio.music.device.RawSong
|
import org.oxycblt.auxio.music.device.RawSong
|
||||||
import org.oxycblt.auxio.music.fs.MediaStoreExtractor
|
import org.oxycblt.auxio.music.fs.MediaStoreExtractor
|
||||||
import org.oxycblt.auxio.music.metadata.TagExtractor
|
import org.oxycblt.auxio.music.metadata.TagExtractor
|
||||||
|
import org.oxycblt.auxio.music.user.MutableUserLibrary
|
||||||
import org.oxycblt.auxio.music.user.UserLibrary
|
import org.oxycblt.auxio.music.user.UserLibrary
|
||||||
import org.oxycblt.auxio.util.logD
|
import org.oxycblt.auxio.util.logD
|
||||||
import org.oxycblt.auxio.util.logE
|
import org.oxycblt.auxio.util.logE
|
||||||
|
|
@ -110,6 +111,14 @@ interface MusicRepository {
|
||||||
*/
|
*/
|
||||||
fun find(uid: Music.UID): Music?
|
fun find(uid: Music.UID): Music?
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new [Playlist] of the given [Song]s.
|
||||||
|
*
|
||||||
|
* @param name The name of the new [Playlist]
|
||||||
|
* @param songs The songs to populate the new [Playlist] with.
|
||||||
|
*/
|
||||||
|
fun createPlaylist(name: String, songs: List<Song>)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request that a music loading operation is started by the current [IndexingWorker]. Does
|
* Request that a music loading operation is started by the current [IndexingWorker]. Does
|
||||||
* nothing if one is not available.
|
* nothing if one is not available.
|
||||||
|
|
@ -183,7 +192,7 @@ constructor(
|
||||||
private var indexingWorker: MusicRepository.IndexingWorker? = null
|
private var indexingWorker: MusicRepository.IndexingWorker? = null
|
||||||
|
|
||||||
override var deviceLibrary: DeviceLibrary? = null
|
override var deviceLibrary: DeviceLibrary? = null
|
||||||
override var userLibrary: UserLibrary? = null
|
override var userLibrary: MutableUserLibrary? = null
|
||||||
private var previousCompletedState: IndexingState.Completed? = null
|
private var previousCompletedState: IndexingState.Completed? = null
|
||||||
private var currentIndexingState: IndexingState? = null
|
private var currentIndexingState: IndexingState? = null
|
||||||
override val indexingState: IndexingState?
|
override val indexingState: IndexingState?
|
||||||
|
|
@ -237,6 +246,14 @@ constructor(
|
||||||
(deviceLibrary?.run { findSong(uid) ?: findAlbum(uid) ?: findArtist(uid) ?: findGenre(uid) }
|
(deviceLibrary?.run { findSong(uid) ?: findAlbum(uid) ?: findArtist(uid) ?: findGenre(uid) }
|
||||||
?: userLibrary?.findPlaylist(uid))
|
?: userLibrary?.findPlaylist(uid))
|
||||||
|
|
||||||
|
override fun createPlaylist(name: String, songs: List<Song>) {
|
||||||
|
userLibrary?.createPlaylist(name, songs)
|
||||||
|
for (listener in updateListeners) {
|
||||||
|
listener.onMusicChanges(
|
||||||
|
MusicRepository.Changes(deviceLibrary = false, userLibrary = true))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun requestIndex(withCache: Boolean) {
|
override fun requestIndex(withCache: Boolean) {
|
||||||
indexingWorker?.requestIndex(withCache)
|
indexingWorker?.requestIndex(withCache)
|
||||||
}
|
}
|
||||||
|
|
@ -374,7 +391,7 @@ constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
private fun emitData(deviceLibrary: DeviceLibrary, userLibrary: UserLibrary) {
|
private fun emitData(deviceLibrary: DeviceLibrary, userLibrary: MutableUserLibrary) {
|
||||||
val deviceLibraryChanged = this.deviceLibrary != deviceLibrary
|
val deviceLibraryChanged = this.deviceLibrary != deviceLibrary
|
||||||
val userLibraryChanged = this.userLibrary != userLibrary
|
val userLibraryChanged = this.userLibrary != userLibrary
|
||||||
if (!deviceLibraryChanged && !userLibraryChanged) return
|
if (!deviceLibraryChanged && !userLibraryChanged) return
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ class MusicViewModel @Inject constructor(private val musicRepository: MusicRepos
|
||||||
* @param name The name of the new playlist. If null, the user will be prompted for a name.
|
* @param name The name of the new playlist. If null, the user will be prompted for a name.
|
||||||
*/
|
*/
|
||||||
fun createPlaylist(name: String? = null) {
|
fun createPlaylist(name: String? = null) {
|
||||||
// TODO: Implement
|
musicRepository.createPlaylist(name ?: "New playlist", listOf())
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue