[Android] Fix NPE when moviepedia date is null

Nicolas Pomepuy git at videolan.org
Mon Dec 9 10:32:58 CET 2019


vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Mon Dec  9 07:34:42 2019 +0100| [280fb243041083487d276df4060020d840f5d695] | committer: Geoffrey Métais

Fix NPE when moviepedia date is null

> https://code.videolan.org/videolan/vlc-android/commit/280fb243041083487d276df4060020d840f5d695
---

 vlc-android/src/org/videolan/vlc/database/models/MediaMetadata.kt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/database/models/MediaMetadata.kt b/vlc-android/src/org/videolan/vlc/database/models/MediaMetadata.kt
index f3fad0a6c..d19c488f4 100644
--- a/vlc-android/src/org/videolan/vlc/database/models/MediaMetadata.kt
+++ b/vlc-android/src/org/videolan/vlc/database/models/MediaMetadata.kt
@@ -128,7 +128,8 @@ fun MediaMetadataWithImages.tvshowSubtitle(): String {
 fun MediaMetadataWithImages.tvEpisodeSubtitle(): String {
     return when (metadata.type) {
         MediaMetadataType.TV_EPISODE -> "S${metadata.season.toString().padStart(2, '0')}E${metadata.episode.toString().padStart(2, '0')}"
-        else -> SimpleDateFormat("yyyy", Locale.getDefault()).format(metadata.releaseDate)
+        else -> metadata.releaseDate?.let { SimpleDateFormat("yyyy", Locale.getDefault()).format(metadata.releaseDate) }
+                ?: ""
     }
 }
 



More information about the Android mailing list