Twelve: Relax models non-null requirements
Change-Id: I9d5fd3e3b9456dff898f022fac3af467a51847e5
diff --git a/app/src/main/java/org/lineageos/twelve/datasources/LocalDataSource.kt b/app/src/main/java/org/lineageos/twelve/datasources/LocalDataSource.kt
index 77bd72d..a5c45bd 100644
--- a/app/src/main/java/org/lineageos/twelve/datasources/LocalDataSource.kt
+++ b/app/src/main/java/org/lineageos/twelve/datasources/LocalDataSource.kt
@@ -166,7 +166,7 @@
track,
genreUri,
genre,
- year,
+ year.takeIf { it != 0 },
)
}
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 94f315a..655b7cc 100644
--- a/app/src/main/java/org/lineageos/twelve/models/Audio.kt
+++ b/app/src/main/java/org/lineageos/twelve/models/Audio.kt
@@ -23,6 +23,7 @@
* @param albumTitle The title of the album of the audio
* @param albumTrack The track number of the audio in the album
* @param genreUri The URI of the genre of the audio
+ * @param genreName The name of the genre of the audio
* @param year The year of release of the audio
*/
data class Audio(
@@ -36,9 +37,9 @@
val albumUri: Uri,
val albumTitle: String,
val albumTrack: Int,
- val genreUri: Uri,
- val genre: String?,
- val year: Int,
+ val genreUri: Uri?,
+ val genreName: String?,
+ val year: Int?,
) : MediaItem<Audio> {
enum class Type(
val media3MediaType: @MediaMetadata.MediaType Int,
@@ -76,7 +77,7 @@
Audio::albumTitle,
Audio::albumTrack,
Audio::genreUri,
- Audio::genre,
+ Audio::genreName,
Audio::year,
) == 0
@@ -88,7 +89,7 @@
mediaType = type.media3MediaType,
album = albumTitle,
artist = artistName,
- genre = genre,
+ genre = genreName,
sourceUri = uri,
mimeType = mimeType,
)