2017-09-02 19:40:32 +02:00
|
|
|
// Converts Album entity from [org.moire.ultrasonic.api.subsonic.SubsonicAPIClient]
|
|
|
|
// to app domain entities.
|
|
|
|
@file:JvmName("APIAlbumConverter")
|
|
|
|
package org.moire.ultrasonic.data
|
|
|
|
|
|
|
|
import org.moire.ultrasonic.api.subsonic.models.Album
|
|
|
|
import org.moire.ultrasonic.domain.MusicDirectory
|
|
|
|
|
|
|
|
fun Album.toDomainEntity(): MusicDirectory.Entry = MusicDirectory.Entry().apply {
|
2017-12-16 20:10:25 +01:00
|
|
|
id = this@toDomainEntity.id
|
2017-09-02 19:40:32 +02:00
|
|
|
setIsDirectory(true)
|
|
|
|
title = this@toDomainEntity.name
|
|
|
|
coverArt = this@toDomainEntity.coverArt
|
|
|
|
artist = this@toDomainEntity.artist
|
2017-12-16 20:10:25 +01:00
|
|
|
artistId = this@toDomainEntity.artistId
|
2017-09-02 19:40:32 +02:00
|
|
|
songCount = this@toDomainEntity.songCount.toLong()
|
|
|
|
duration = this@toDomainEntity.duration
|
|
|
|
created = this@toDomainEntity.created?.time
|
|
|
|
year = this@toDomainEntity.year
|
|
|
|
genre = this@toDomainEntity.genre
|
|
|
|
}
|
|
|
|
|
|
|
|
fun Album.toMusicDirectoryDomainEntity(): MusicDirectory = MusicDirectory().apply {
|
|
|
|
addAll(this@toMusicDirectoryDomainEntity.songList.map { it.toDomainEntity() })
|
|
|
|
}
|
2017-09-16 20:02:44 +02:00
|
|
|
|
|
|
|
fun List<Album>.toDomainEntityList(): List<MusicDirectory.Entry> = this.map { it.toDomainEntity() }
|