mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-02 18:31:40 +00:00
- Removed middle layer of abstraction for subsonic classes
- Used kotlin for classes
This commit is contained in:
parent
917c0839de
commit
ca15f51c85
168 changed files with 2026 additions and 6588 deletions
|
|
@ -2,62 +2,11 @@ package com.cappielloantonio.play.model
|
|||
|
||||
import android.os.Parcelable
|
||||
import androidx.annotation.Keep
|
||||
import com.cappielloantonio.play.subsonic.models.AlbumID3
|
||||
import com.cappielloantonio.play.subsonic.models.AlbumWithSongsID3
|
||||
import com.cappielloantonio.play.util.MappingUtil
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
import java.util.*
|
||||
|
||||
@Keep
|
||||
@Parcelize
|
||||
class Album(
|
||||
var id: String,
|
||||
val title: String,
|
||||
val year: Int? = 0,
|
||||
val artistId: String,
|
||||
val artistName: String,
|
||||
val primary: String,
|
||||
var starred: Boolean?,
|
||||
val songs: List<Media>?,
|
||||
val created: Date?
|
||||
) : Parcelable {
|
||||
|
||||
constructor(albumID3: AlbumID3) : this(
|
||||
albumID3.id,
|
||||
albumID3.name,
|
||||
albumID3.year ?: 0,
|
||||
albumID3.artistId,
|
||||
albumID3.artist,
|
||||
albumID3.coverArtId,
|
||||
albumID3.starred != null,
|
||||
null,
|
||||
albumID3.created
|
||||
)
|
||||
|
||||
constructor(albumWithSongsID3: AlbumWithSongsID3) : this(
|
||||
albumWithSongsID3.id,
|
||||
albumWithSongsID3.name,
|
||||
albumWithSongsID3.year ?: 0,
|
||||
albumWithSongsID3.artistId,
|
||||
albumWithSongsID3.artist,
|
||||
albumWithSongsID3.coverArtId,
|
||||
albumWithSongsID3.starred != null,
|
||||
MappingUtil.mapSong(albumWithSongsID3.songs),
|
||||
albumWithSongsID3.created
|
||||
)
|
||||
|
||||
constructor(download: Download) : this(
|
||||
download.albumId,
|
||||
download.albumName,
|
||||
0,
|
||||
download.artistId,
|
||||
download.artistName,
|
||||
download.primary,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
)
|
||||
|
||||
class Album : Parcelable {
|
||||
companion object {
|
||||
const val RECENTLY_PLAYED = "RECENTLY_PLAYED"
|
||||
const val MOST_PLAYED = "MOST_PLAYED"
|
||||
|
|
|
|||
|
|
@ -2,98 +2,11 @@ package com.cappielloantonio.play.model
|
|||
|
||||
import android.os.Parcelable
|
||||
import androidx.annotation.Keep
|
||||
import com.cappielloantonio.play.subsonic.models.ArtistID3
|
||||
import com.cappielloantonio.play.subsonic.models.ArtistInfo2
|
||||
import com.cappielloantonio.play.subsonic.models.ArtistWithAlbumsID3
|
||||
import com.cappielloantonio.play.subsonic.models.SimilarArtistID3
|
||||
import com.cappielloantonio.play.util.MappingUtil
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
|
||||
@Keep
|
||||
@Parcelize
|
||||
class Artist(
|
||||
val id: String?,
|
||||
val name: String?,
|
||||
val primary: String?,
|
||||
val albumCount: Int?,
|
||||
var starred: Boolean?,
|
||||
val bio: String?,
|
||||
val imageUrl: String?,
|
||||
val lastfm: String?,
|
||||
val albums: List<Album>?,
|
||||
val similarArtists: List<Artist>?,
|
||||
) : Parcelable {
|
||||
|
||||
constructor(artistID3: ArtistID3) : this(
|
||||
artistID3.id,
|
||||
artistID3.name,
|
||||
artistID3.coverArtId,
|
||||
artistID3.albumCount,
|
||||
artistID3.starred != null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
)
|
||||
|
||||
constructor(artistWithAlbumsID3: ArtistWithAlbumsID3) : this(
|
||||
artistWithAlbumsID3.id,
|
||||
artistWithAlbumsID3.name,
|
||||
artistWithAlbumsID3.coverArtId,
|
||||
artistWithAlbumsID3.albumCount,
|
||||
artistWithAlbumsID3.starred != null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
MappingUtil.mapAlbum(artistWithAlbumsID3.albums),
|
||||
null
|
||||
)
|
||||
|
||||
constructor(similarArtistID3: SimilarArtistID3) : this(
|
||||
similarArtistID3.id,
|
||||
similarArtistID3.name,
|
||||
similarArtistID3.coverArtId,
|
||||
similarArtistID3.albumCount,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
)
|
||||
|
||||
constructor(artistInfo2: ArtistInfo2) : this(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
artistInfo2.biography,
|
||||
artistInfo2.largeImageUrl,
|
||||
artistInfo2.lastFmUrl,
|
||||
null,
|
||||
MappingUtil.mapSimilarArtist(artistInfo2.similarArtists)
|
||||
)
|
||||
|
||||
constructor(id: String, name: String) : this(
|
||||
id,
|
||||
name,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
)
|
||||
|
||||
constructor(download: Download) : this(
|
||||
download.artistId,
|
||||
download.artistName
|
||||
)
|
||||
|
||||
class Artist : Parcelable {
|
||||
companion object {
|
||||
const val DOWNLOADED = "DOWNLOADED"
|
||||
const val STARRED = "STARRED"
|
||||
|
|
|
|||
|
|
@ -1,55 +1,19 @@
|
|||
package com.cappielloantonio.play.model
|
||||
|
||||
import android.os.Parcelable
|
||||
import androidx.annotation.Keep
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import com.cappielloantonio.play.subsonic.models.Child
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
|
||||
@Keep
|
||||
@Parcelize
|
||||
@Entity(tableName = "chronology")
|
||||
data class Chronology(
|
||||
@ColumnInfo(name = "id")
|
||||
val trackId: String,
|
||||
|
||||
@ColumnInfo(name = "title")
|
||||
val title: String,
|
||||
|
||||
@ColumnInfo(name = "albumId")
|
||||
val albumId: String,
|
||||
|
||||
@ColumnInfo(name = "albumName")
|
||||
val albumName: String,
|
||||
|
||||
@ColumnInfo(name = "artistId")
|
||||
val artistId: String,
|
||||
|
||||
@ColumnInfo(name = "artistName")
|
||||
val artistName: String,
|
||||
|
||||
@ColumnInfo(name = "cover_art_id")
|
||||
val coverArtId: String,
|
||||
|
||||
@ColumnInfo(name = "duration")
|
||||
val duration: Long,
|
||||
|
||||
@ColumnInfo(name = "container")
|
||||
val container: String,
|
||||
|
||||
@ColumnInfo(name = "bitrate")
|
||||
val bitrate: Int,
|
||||
|
||||
@ColumnInfo(name = "extension")
|
||||
val extension: String,
|
||||
|
||||
@ColumnInfo(name = "server")
|
||||
val server: String,
|
||||
) : Parcelable {
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
var uuid: Int = 0
|
||||
|
||||
class Chronology(@PrimaryKey override val id: String) : Child(id) {
|
||||
@ColumnInfo(name = "timestamp")
|
||||
var timestamp: Long = System.currentTimeMillis()
|
||||
|
||||
@ColumnInfo(name = "server")
|
||||
var server: String? = null
|
||||
}
|
||||
|
|
@ -1,89 +1,22 @@
|
|||
package com.cappielloantonio.play.model
|
||||
|
||||
import android.os.Parcelable
|
||||
import androidx.annotation.Keep
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import com.cappielloantonio.play.App
|
||||
import com.cappielloantonio.play.util.MusicUtil
|
||||
import com.cappielloantonio.play.util.PreferenceUtil
|
||||
import com.cappielloantonio.play.subsonic.models.Child
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
import java.util.*
|
||||
|
||||
@Keep
|
||||
@Parcelize
|
||||
@Entity(tableName = "download")
|
||||
class Download(
|
||||
@PrimaryKey @ColumnInfo(name = "id")
|
||||
var id: String,
|
||||
class Download(@PrimaryKey override val id: String) : Child(id) {
|
||||
@ColumnInfo(name = "media_id")
|
||||
var mediaID: String? = null
|
||||
|
||||
@ColumnInfo(name = "mediaId")
|
||||
val mediaID: String,
|
||||
@ColumnInfo
|
||||
var server: String? = null
|
||||
|
||||
@ColumnInfo(name = "title")
|
||||
val title: String,
|
||||
|
||||
@ColumnInfo(name = "albumId")
|
||||
val albumId: String,
|
||||
|
||||
@ColumnInfo(name = "albumName")
|
||||
val albumName: String,
|
||||
|
||||
@ColumnInfo(name = "artistId")
|
||||
val artistId: String,
|
||||
|
||||
@ColumnInfo(name = "artistName")
|
||||
val artistName: String,
|
||||
|
||||
@ColumnInfo(name = "trackNumber")
|
||||
val trackNumber: Int = 0,
|
||||
|
||||
@ColumnInfo(name = "primary")
|
||||
val primary: String,
|
||||
|
||||
@ColumnInfo(name = "duration")
|
||||
val duration: Long = 0,
|
||||
|
||||
@ColumnInfo(name = "server")
|
||||
val server: String,
|
||||
|
||||
@ColumnInfo(name = "playlistId")
|
||||
val playlistId: String? = null,
|
||||
|
||||
@ColumnInfo(name = "playlistName")
|
||||
val playlistName: String? = null,
|
||||
|
||||
@ColumnInfo(name = "container")
|
||||
val container: String,
|
||||
|
||||
@ColumnInfo(name = "bitrate")
|
||||
val bitrate: Int = 0,
|
||||
|
||||
@ColumnInfo(name = "extension")
|
||||
val extension: String,
|
||||
|
||||
@ColumnInfo(name = "type")
|
||||
val type: String,
|
||||
) : Parcelable {
|
||||
|
||||
constructor(media: Media, playlistId: String?, playlistName: String?) : this(
|
||||
UUID.randomUUID().toString(),
|
||||
media.id!!,
|
||||
media.title!!,
|
||||
media.albumId!!,
|
||||
media.albumName!!,
|
||||
media.artistId!!,
|
||||
MusicUtil.normalizedArtistName(media.artistName),
|
||||
media.trackNumber!!,
|
||||
media.coverArtId!!,
|
||||
media.duration!!,
|
||||
PreferenceUtil.getInstance(App.getInstance()).serverId,
|
||||
playlistId,
|
||||
playlistName,
|
||||
media.container!!,
|
||||
media.bitrate,
|
||||
media.extension!!,
|
||||
media.type!!
|
||||
)
|
||||
@ColumnInfo(name = "playlist_id")
|
||||
var playlistId: String? = null
|
||||
}
|
||||
|
|
@ -2,25 +2,11 @@ package com.cappielloantonio.play.model
|
|||
|
||||
import android.os.Parcelable
|
||||
import androidx.annotation.Keep
|
||||
import com.cappielloantonio.play.subsonic.models.Genre
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
|
||||
@Keep
|
||||
@Parcelize
|
||||
class Genre(
|
||||
val id: String,
|
||||
val name: String,
|
||||
val songCount: Int = 0,
|
||||
val albumCount: Int = 0
|
||||
) : Parcelable {
|
||||
|
||||
constructor(genre: Genre) : this(
|
||||
genre.genre,
|
||||
genre.genre,
|
||||
genre.songCount,
|
||||
genre.albumCount
|
||||
)
|
||||
|
||||
class Genre : Parcelable {
|
||||
companion object {
|
||||
const val ORDER_BY_NAME = "ORDER_BY_NAME"
|
||||
const val ORDER_BY_RANDOM = "ORDER_BY_RANDOM"
|
||||
|
|
|
|||
|
|
@ -2,192 +2,11 @@ package com.cappielloantonio.play.model
|
|||
|
||||
import android.os.Parcelable
|
||||
import androidx.annotation.Keep
|
||||
import com.cappielloantonio.play.subsonic.models.Child
|
||||
import com.cappielloantonio.play.subsonic.models.PodcastEpisode
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
|
||||
@Keep
|
||||
@Parcelize
|
||||
class Media(
|
||||
val id: String?,
|
||||
val title: String?,
|
||||
val channelId: String?,
|
||||
val streamId: String?,
|
||||
val albumId: String?,
|
||||
val albumName: String?,
|
||||
val artistId: String?,
|
||||
val artistName: String?,
|
||||
val coverArtId: String?,
|
||||
val trackNumber: Int?,
|
||||
val discNumber: Int?,
|
||||
val year: Int?,
|
||||
val duration: Long?,
|
||||
val description: String?,
|
||||
val status: String?,
|
||||
var starred: Boolean?,
|
||||
val path: String?,
|
||||
val size: Long?,
|
||||
val container: String?,
|
||||
val bitrate: Int,
|
||||
val extension: String?,
|
||||
val added: Long?,
|
||||
val type: String?,
|
||||
val playCount: Int?,
|
||||
val lastPlay: Long?,
|
||||
val rating: Int?,
|
||||
val publishDate: Long?
|
||||
) : Parcelable {
|
||||
|
||||
constructor(child: Child) : this(
|
||||
child.id,
|
||||
child.title,
|
||||
null,
|
||||
null,
|
||||
child.albumId,
|
||||
child.album,
|
||||
child.artistId,
|
||||
child.artist,
|
||||
child.coverArtId,
|
||||
child.track,
|
||||
child.discNumber,
|
||||
child.year,
|
||||
child.duration.toLong(),
|
||||
null,
|
||||
null,
|
||||
child.starred != null,
|
||||
child.path,
|
||||
child.size,
|
||||
child.contentType,
|
||||
child.bitRate,
|
||||
child.suffix,
|
||||
child.created.time,
|
||||
child.type,
|
||||
0,
|
||||
0,
|
||||
child.userRating,
|
||||
0
|
||||
)
|
||||
|
||||
constructor(podcastEpisode: PodcastEpisode) : this(
|
||||
podcastEpisode.id,
|
||||
podcastEpisode.title,
|
||||
podcastEpisode.channelId,
|
||||
podcastEpisode.streamId,
|
||||
null,
|
||||
podcastEpisode.album,
|
||||
null,
|
||||
podcastEpisode.artist,
|
||||
podcastEpisode.coverArtId,
|
||||
podcastEpisode.track,
|
||||
null,
|
||||
podcastEpisode.year,
|
||||
podcastEpisode.duration.toLong(),
|
||||
podcastEpisode.description,
|
||||
podcastEpisode.status,
|
||||
podcastEpisode.starred != null,
|
||||
null,
|
||||
null,
|
||||
podcastEpisode.contentType,
|
||||
podcastEpisode.bitRate,
|
||||
podcastEpisode.suffix,
|
||||
podcastEpisode.created.time,
|
||||
podcastEpisode.type,
|
||||
null,
|
||||
null,
|
||||
podcastEpisode.userRating,
|
||||
podcastEpisode.publishDate.time
|
||||
)
|
||||
|
||||
constructor(queue: Queue) : this(
|
||||
queue.id,
|
||||
queue.title,
|
||||
queue.channelId,
|
||||
queue.streamId,
|
||||
queue.albumId,
|
||||
queue.albumName,
|
||||
queue.artistId,
|
||||
queue.artistName,
|
||||
queue.coverArtId,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
queue.duration,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
queue.container,
|
||||
queue.bitrate,
|
||||
queue.extension,
|
||||
null,
|
||||
queue.type,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
queue.publishingDate
|
||||
)
|
||||
|
||||
constructor(download: Download) : this(
|
||||
download.mediaID,
|
||||
download.title,
|
||||
null,
|
||||
null,
|
||||
download.albumId,
|
||||
download.albumName,
|
||||
download.artistId,
|
||||
download.artistName,
|
||||
download.primary,
|
||||
download.trackNumber,
|
||||
null,
|
||||
null,
|
||||
download.duration,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
download.container,
|
||||
download.bitrate,
|
||||
download.extension,
|
||||
null,
|
||||
download.type,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
)
|
||||
|
||||
constructor(item: Chronology) : this(
|
||||
item.trackId,
|
||||
item.title,
|
||||
null,
|
||||
null,
|
||||
item.albumId,
|
||||
item.albumName,
|
||||
item.artistId,
|
||||
item.artistName,
|
||||
item.coverArtId,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
item.duration,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
item.container,
|
||||
item.bitrate,
|
||||
item.extension,
|
||||
null,
|
||||
MEDIA_TYPE_MUSIC,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
)
|
||||
|
||||
class Media : Parcelable {
|
||||
companion object {
|
||||
const val MEDIA_TYPE_MUSIC = "music"
|
||||
const val MEDIA_TYPE_PODCAST = "podcast"
|
||||
|
|
|
|||
|
|
@ -2,45 +2,11 @@ package com.cappielloantonio.play.model
|
|||
|
||||
import android.os.Parcelable
|
||||
import androidx.annotation.Keep
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.Ignore
|
||||
import androidx.room.PrimaryKey
|
||||
import com.cappielloantonio.play.subsonic.models.Playlist
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
|
||||
@Keep
|
||||
@Parcelize
|
||||
@Entity(tableName = "playlist")
|
||||
class Playlist(
|
||||
@PrimaryKey
|
||||
@ColumnInfo(name = "id")
|
||||
var id: String,
|
||||
|
||||
@ColumnInfo(name = "playlist_name")
|
||||
var name: String,
|
||||
|
||||
@ColumnInfo(name = "primary")
|
||||
var primary: String? = null,
|
||||
|
||||
@ColumnInfo(name = "song_count")
|
||||
var songCount: Int = 0,
|
||||
|
||||
@ColumnInfo(name = "playlist_duration")
|
||||
var duration: Long = 0,
|
||||
|
||||
@ColumnInfo(name = "server")
|
||||
var server: String? = null,
|
||||
) : Parcelable {
|
||||
|
||||
constructor(playlist: Playlist) : this(
|
||||
playlist.id,
|
||||
playlist.name,
|
||||
playlist.coverArtId,
|
||||
playlist.songCount,
|
||||
playlist.duration.toLong()
|
||||
)
|
||||
|
||||
class Playlist : Parcelable {
|
||||
companion object {
|
||||
const val ALL = "ALL"
|
||||
const val DOWNLOADED = "DOWNLOADED"
|
||||
|
|
|
|||
|
|
@ -1,34 +0,0 @@
|
|||
package com.cappielloantonio.play.model
|
||||
|
||||
import android.os.Parcelable
|
||||
import androidx.annotation.Keep
|
||||
import com.cappielloantonio.play.subsonic.models.PodcastChannel
|
||||
import com.cappielloantonio.play.util.MappingUtil
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
|
||||
@Keep
|
||||
@Parcelize
|
||||
class PodcastChannel(
|
||||
var id: String,
|
||||
var url: String,
|
||||
var title: String,
|
||||
var description: String,
|
||||
var coverArtId: String,
|
||||
var originalImageUrl: String,
|
||||
var status: String,
|
||||
var errorMessage: String,
|
||||
var episodes: List<Media>,
|
||||
) : Parcelable {
|
||||
|
||||
constructor(podcastChannel: PodcastChannel) : this(
|
||||
podcastChannel.id,
|
||||
podcastChannel.url,
|
||||
podcastChannel.title,
|
||||
podcastChannel.description,
|
||||
podcastChannel.coverArtId,
|
||||
podcastChannel.originalImageUrl,
|
||||
podcastChannel.status,
|
||||
podcastChannel.errorMessage,
|
||||
MappingUtil.mapPodcastEpisode(podcastChannel.episodes)
|
||||
)
|
||||
}
|
||||
|
|
@ -1,68 +1,26 @@
|
|||
package com.cappielloantonio.play.model
|
||||
|
||||
import android.os.Parcelable
|
||||
import androidx.annotation.Keep
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import com.cappielloantonio.play.subsonic.models.Child
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
|
||||
@Keep
|
||||
@Parcelize
|
||||
@Entity(tableName = "queue")
|
||||
data class Queue(
|
||||
@PrimaryKey
|
||||
class Queue(override val id: String) : Child(id) {
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
@ColumnInfo(name = "track_order")
|
||||
val trackOrder: Int,
|
||||
|
||||
@ColumnInfo(name = "id")
|
||||
val id: String?,
|
||||
|
||||
@ColumnInfo(name = "title")
|
||||
val title: String?,
|
||||
|
||||
@ColumnInfo(name = "albumId")
|
||||
val albumId: String?,
|
||||
|
||||
@ColumnInfo(name = "albumName")
|
||||
val albumName: String?,
|
||||
|
||||
@ColumnInfo(name = "artistId")
|
||||
val artistId: String?,
|
||||
|
||||
@ColumnInfo(name = "artistName")
|
||||
val artistName: String?,
|
||||
|
||||
@ColumnInfo(name = "cover_art_id")
|
||||
val coverArtId: String?,
|
||||
|
||||
@ColumnInfo(name = "duration")
|
||||
val duration: Long,
|
||||
var trackOrder: Int = 0
|
||||
|
||||
@ColumnInfo(name = "last_play", defaultValue = "0")
|
||||
val lastPlay: Long,
|
||||
var lastPlay: Long = 0
|
||||
|
||||
@ColumnInfo(name = "playing_changed", defaultValue = "0")
|
||||
val playingChanged: Long,
|
||||
var playingChanged: Long = 0
|
||||
|
||||
@ColumnInfo(name = "stream_id")
|
||||
val streamId: String?,
|
||||
|
||||
@ColumnInfo(name = "channel_id")
|
||||
val channelId: String?,
|
||||
|
||||
@ColumnInfo(name = "publishing_date", defaultValue = "0")
|
||||
val publishingDate: Long,
|
||||
|
||||
@ColumnInfo(name = "container")
|
||||
val container: String?,
|
||||
|
||||
@ColumnInfo(name = "bitrate")
|
||||
val bitrate: Int,
|
||||
|
||||
@ColumnInfo(name = "extension")
|
||||
val extension: String?,
|
||||
|
||||
@ColumnInfo(name = "media_type")
|
||||
val type: String?
|
||||
) : Parcelable
|
||||
var streamId: String? = null
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue