Skip to content

Commit

Permalink
Twelve: Add media type to media item models
Browse files Browse the repository at this point in the history
Change-Id: I21cfe78568a993aa9c8e773fec9810fef5cebba1
  • Loading branch information
SebaUbuntu committed Nov 7, 2024
1 parent 973cc41 commit 6cc5557
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/src/main/java/org/lineageos/twelve/models/Album.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ data class Album(
val year: Int?,
val thumbnail: Thumbnail?,
) : MediaItem<Album> {
override val mediaType = MediaType.ALBUM

override fun areContentsTheSame(other: Album) = compareValuesBy(
this, other,
Album::title,
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/org/lineageos/twelve/models/Artist.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ data class Artist(
val name: String,
val thumbnail: Thumbnail?,
) : MediaItem<Artist> {
override val mediaType = MediaType.ARTIST

override fun areContentsTheSame(other: Artist) = compareValuesBy(
this, other,
Artist::name,
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/org/lineageos/twelve/models/Audio.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ data class Audio(
RECORDING(MediaMetadata.MEDIA_TYPE_MUSIC),
}

override val mediaType = MediaType.AUDIO

override fun areContentsTheSame(other: Audio) = compareValuesBy(
this, other,
Audio::mimeType,
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/org/lineageos/twelve/models/Genre.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ data class Genre(
override val uri: Uri,
val name: String?,
) : MediaItem<Genre> {
override val mediaType = MediaType.GENRE

override fun areContentsTheSame(other: Genre) = compareValuesBy(
other,
this,
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/org/lineageos/twelve/models/MediaItem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import android.net.Uri
* A media item.
*/
sealed interface MediaItem<T : MediaItem<T>> : UniqueItem<T> {
/**
* The media type.
*/
val mediaType: MediaType

/**
* A [Uri] identifying this media item.
*/
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/org/lineageos/twelve/models/Playlist.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ data class Playlist(
override val uri: Uri,
val name: String,
) : MediaItem<Playlist> {
override val mediaType = MediaType.PLAYLIST

override fun areContentsTheSame(other: Playlist) = compareValuesBy(
this,
other,
Expand Down

0 comments on commit 6cc5557

Please sign in to comment.