[Android] OpenSubtitles: fix some crash due to incorrect casting

Nicolas Pomepuy git at videolan.org
Thu Nov 21 13:19:11 UTC 2024


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Nov  5 09:30:58 2024 +0100| [4412753cb33ef23c4064e59c5413603d4a86cdd2] | committer: Duncan McNamara

OpenSubtitles: fix some crash due to incorrect casting

> https://code.videolan.org/videolan/vlc-android/commit/4412753cb33ef23c4064e59c5413603d4a86cdd2
---

 .../src/main/java/org/videolan/resources/opensubtitles/Models.kt      | 4 ++--
 .../vlc-android/src/org/videolan/vlc/gui/dialogs/SubtitleItem.kt      | 2 +-
 .../vlc-android/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 0448d9e184..7da7256794 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<RelatedLink?>?,
         @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 b2c2ecb666..c2465ca217 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 ef1bc6f127..ab3c5cd6d4 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<List<Data>> = 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,



More information about the Android mailing list