Twelve: Add media type to media item models
Change-Id: I21cfe78568a993aa9c8e773fec9810fef5cebba1
diff --git a/app/src/main/java/org/lineageos/twelve/models/Album.kt b/app/src/main/java/org/lineageos/twelve/models/Album.kt
index 03545e6..de9673d 100644
--- a/app/src/main/java/org/lineageos/twelve/models/Album.kt
+++ b/app/src/main/java/org/lineageos/twelve/models/Album.kt
@@ -28,6 +28,8 @@
val year: Int?,
val thumbnail: Thumbnail?,
) : MediaItem<Album> {
+ override val mediaType = MediaType.ALBUM
+
override fun areContentsTheSame(other: Album) = compareValuesBy(
this, other,
Album::title,
diff --git a/app/src/main/java/org/lineageos/twelve/models/Artist.kt b/app/src/main/java/org/lineageos/twelve/models/Artist.kt
index d195887..9cb5216 100644
--- a/app/src/main/java/org/lineageos/twelve/models/Artist.kt
+++ b/app/src/main/java/org/lineageos/twelve/models/Artist.kt
@@ -22,6 +22,8 @@
val name: String,
val thumbnail: Thumbnail?,
) : MediaItem<Artist> {
+ override val mediaType = MediaType.ARTIST
+
override fun areContentsTheSame(other: Artist) = compareValuesBy(
this, other,
Artist::name,
diff --git a/app/src/main/java/org/lineageos/twelve/models/Audio.kt b/app/src/main/java/org/lineageos/twelve/models/Audio.kt
index f52f9c6..2ac679b 100644
--- a/app/src/main/java/org/lineageos/twelve/models/Audio.kt
+++ b/app/src/main/java/org/lineageos/twelve/models/Audio.kt
@@ -71,6 +71,8 @@
RECORDING(MediaMetadata.MEDIA_TYPE_MUSIC),
}
+ override val mediaType = MediaType.AUDIO
+
override fun areContentsTheSame(other: Audio) = compareValuesBy(
this, other,
Audio::mimeType,
diff --git a/app/src/main/java/org/lineageos/twelve/models/Genre.kt b/app/src/main/java/org/lineageos/twelve/models/Genre.kt
index e32ba8e..7549f04 100644
--- a/app/src/main/java/org/lineageos/twelve/models/Genre.kt
+++ b/app/src/main/java/org/lineageos/twelve/models/Genre.kt
@@ -20,6 +20,8 @@
override val uri: Uri,
val name: String?,
) : MediaItem<Genre> {
+ override val mediaType = MediaType.GENRE
+
override fun areContentsTheSame(other: Genre) = compareValuesBy(
other,
this,
diff --git a/app/src/main/java/org/lineageos/twelve/models/MediaItem.kt b/app/src/main/java/org/lineageos/twelve/models/MediaItem.kt
index 3fb0cf1..ea67b1a 100644
--- a/app/src/main/java/org/lineageos/twelve/models/MediaItem.kt
+++ b/app/src/main/java/org/lineageos/twelve/models/MediaItem.kt
@@ -12,6 +12,11 @@
*/
sealed interface MediaItem<T : MediaItem<T>> : UniqueItem<T> {
/**
+ * The media type.
+ */
+ val mediaType: MediaType
+
+ /**
* A [Uri] identifying this media item.
*/
val uri: Uri
diff --git a/app/src/main/java/org/lineageos/twelve/models/Playlist.kt b/app/src/main/java/org/lineageos/twelve/models/Playlist.kt
index 511118a..8357ea0 100644
--- a/app/src/main/java/org/lineageos/twelve/models/Playlist.kt
+++ b/app/src/main/java/org/lineageos/twelve/models/Playlist.kt
@@ -19,6 +19,8 @@
override val uri: Uri,
val name: String,
) : MediaItem<Playlist> {
+ override val mediaType = MediaType.PLAYLIST
+
override fun areContentsTheSame(other: Playlist) = compareValuesBy(
this,
other,