From 4412753cb33ef23c4064e59c5413603d4a86cdd2 Mon Sep 17 00:00:00 2001 From: Nicolas Pomepuy Date: Tue, 5 Nov 2024 09:30:58 +0100 Subject: [PATCH] OpenSubtitles: fix some crash due to incorrect casting --- .../main/java/org/videolan/resources/opensubtitles/Models.kt | 4 ++-- .../src/org/videolan/vlc/gui/dialogs/SubtitleItem.kt | 2 +- .../src/org/videolan/vlc/viewmodels/SubtitlesModel.kt | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/application/resources/src/main/java/org/videolan/resources/opensubtitles/Models.kt b/application/resources/src/main/java/org/videolan/resources/opensubtitles/Models.kt index 0448d9e18..7da725679 100644 --- a/application/resources/src/main/java/org/videolan/resources/opensubtitles/Models.kt +++ b/application/resources/src/main/java/org/videolan/resources/opensubtitles/Models.kt @@ -63,7 +63,7 @@ data class Attributes( @field:Json(name = "new_download_count") val newDownloadCount: Int?, @field:Json(name = "ratings") - val ratings: Int = 0, + val ratings: Float = 0F, @field:Json(name = "related_links") val relatedLinks: List?, @field:Json(name = "release") @@ -93,7 +93,7 @@ data class FeatureDetails( @field:Json(name = "imdb_id") val imdbId: Int?, @field:Json(name = "movie_name") - val movieName: String?, + val movieName: String, @field:Json(name = "parent_feature_id") val parentFeatureId: Int?, @field:Json(name = "parent_imdb_id") diff --git a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/SubtitleItem.kt b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/SubtitleItem.kt index b2c2ecb66..c2465ca21 100644 --- a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/SubtitleItem.kt +++ b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/SubtitleItem.kt @@ -12,7 +12,7 @@ data class SubtitleItem( val state: State, var zipDownloadLink: String, val hearingImpaired: Boolean, - val rating: Int, + val rating: Float, val downloadNumber: Long, var fileName: String = "" ) { diff --git a/application/vlc-android/src/org/videolan/vlc/viewmodels/SubtitlesModel.kt b/application/vlc-android/src/org/videolan/vlc/viewmodels/SubtitlesModel.kt index ef1bc6f12..ab3c5cd6d 100644 --- a/application/vlc-android/src/org/videolan/vlc/viewmodels/SubtitlesModel.kt +++ b/application/vlc-android/src/org/videolan/vlc/viewmodels/SubtitlesModel.kt @@ -98,7 +98,7 @@ class SubtitlesModel(private val context: Context, private val mediaUri: Uri, pr private val apiResultLiveData: MutableLiveData> = MutableLiveData() private val downloadedLiveData = ExternalSubRepository.getInstance(context).getDownloadedSubtitles(mediaUri).map { list -> - list.map { SubtitleItem(it.idSubtitle, -1, mediaUri, it.subLanguageID, it.movieReleaseName, State.Downloaded, "", it.hearingImpaired, 0, 0) } + list.map { SubtitleItem(it.idSubtitle, -1, mediaUri, it.subLanguageID, it.movieReleaseName, State.Downloaded, "", it.hearingImpaired, 0F, 0) } } private val downloadingLiveData = ExternalSubRepository.getInstance(context).downloadingSubtitles @@ -164,7 +164,7 @@ class SubtitlesModel(private val context: Context, private val mediaUri: Uri, pr openSubtitle.attributes.files.first().fileId, mediaUri, openSubtitle.attributes.language, - openSubtitle.attributes.featureDetails.title, + openSubtitle.attributes.featureDetails.movieName, state, "", openSubtitle.attributes.hearingImpaired,