make versions in DataTypes -> Episodes -> Episode nullable since it is in fact nullable
This commit is contained in:
parent
cf02bee7d4
commit
4bceacf75c
|
@ -34,7 +34,6 @@ import io.ktor.http.*
|
|||
import io.ktor.serialization.*
|
||||
import io.ktor.serialization.kotlinx.json.*
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.serialization.SerializationException
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
|
@ -149,7 +148,7 @@ object Crunchyroll {
|
|||
}
|
||||
|
||||
return@coroutineScope (Dispatchers.IO) {
|
||||
val response: T = client.request(url) {
|
||||
val response = client.request(url) {
|
||||
method = httpMethod
|
||||
header("Authorization", "${token.tokenType} ${token.accessToken}")
|
||||
params.forEach {
|
||||
|
@ -161,9 +160,9 @@ object Crunchyroll {
|
|||
setBody(bodyObject)
|
||||
contentType(ContentType.Application.Json)
|
||||
}
|
||||
}.body()
|
||||
}
|
||||
|
||||
response
|
||||
response.body<T>()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -389,7 +388,7 @@ object Crunchyroll {
|
|||
return try {
|
||||
requestGet(seriesEndpoint, parameters)
|
||||
} catch (ex: Exception) {
|
||||
Log.e(TAG, "Exception in series().", ex)
|
||||
Log.e(TAG, "Exception in series() for id $seriesId.", ex)
|
||||
NoneSeries
|
||||
}
|
||||
}
|
||||
|
@ -418,7 +417,7 @@ object Crunchyroll {
|
|||
Log.e(TAG, "JsonConvertException in upNextSeries() with seriesId=$seriesId", ex)
|
||||
NoneUpNextSeriesList
|
||||
} catch (ex: Exception) {
|
||||
Log.e(TAG, "Exception in upNextSeries().", ex)
|
||||
Log.e(TAG, "Exception in upNextSeries() for seriesId $seriesId.", ex)
|
||||
NoneUpNextSeriesList
|
||||
}
|
||||
}
|
||||
|
@ -439,7 +438,7 @@ object Crunchyroll {
|
|||
return try {
|
||||
requestGet(seasonsEndpoint, parameters)
|
||||
} catch (ex: Exception) {
|
||||
Log.e(TAG, "Exception in seasons().", ex)
|
||||
Log.e(TAG, "Exception in seasons() for seriesId $seriesId.", ex)
|
||||
NoneSeasons
|
||||
}
|
||||
}
|
||||
|
@ -460,7 +459,7 @@ object Crunchyroll {
|
|||
return try {
|
||||
requestGet(episodesEndpoint, parameters)
|
||||
} catch (ex: Exception) {
|
||||
Log.e(TAG, "Exception in episodes().", ex)
|
||||
Log.e(TAG, "Exception in episodes() for seasonId $seasonId.", ex)
|
||||
NoneEpisodes
|
||||
}
|
||||
}
|
||||
|
@ -480,7 +479,7 @@ object Crunchyroll {
|
|||
return try {
|
||||
requestGet(url, parameters)
|
||||
} catch (ex: Exception) {
|
||||
Log.e(TAG, "Exception in streams().", ex)
|
||||
Log.e(TAG, "Exception in streams() with url $url.", ex)
|
||||
NoneStreams
|
||||
}
|
||||
}
|
||||
|
@ -512,7 +511,7 @@ object Crunchyroll {
|
|||
(requestGet(watchlistSeriesEndpoint, parameters) as Collection2<IsWatchlistItem>)
|
||||
.total == 1
|
||||
} catch (ex: Exception) {
|
||||
Log.e(TAG, "Exception in isWatchlist() with seriesId = $seriesId", ex)
|
||||
Log.e(TAG, "Exception in isWatchlist() with seriesId $seriesId", ex)
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -536,7 +535,7 @@ object Crunchyroll {
|
|||
try {
|
||||
requestPost(watchlistPostEndpoint, parameters, json)
|
||||
} catch (ex: Exception) {
|
||||
Log.e(TAG, "Exception in postWatchlist() with seriesId = $seriesId", ex)
|
||||
Log.e(TAG, "Exception in postWatchlist() with seriesId $seriesId", ex)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -555,7 +554,7 @@ object Crunchyroll {
|
|||
try {
|
||||
requestDelete(watchlistDeleteEndpoint, parameters)
|
||||
} catch (ex: Exception) {
|
||||
Log.e(TAG, "Exception in deleteWatchlist() with seriesId = $seriesId", ex)
|
||||
Log.e(TAG, "Exception in deleteWatchlist() with seriesId $seriesId", ex)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -575,7 +574,6 @@ object Crunchyroll {
|
|||
"locale" to Preferences.preferredSubtitleLocale.toLanguageTag()
|
||||
)
|
||||
|
||||
|
||||
return try {
|
||||
requestGet(playheadsEndpoint, parameters)
|
||||
} catch (ex: Exception) {
|
||||
|
|
|
@ -302,7 +302,7 @@ data class Episode(
|
|||
@SerialName("is_dubbed") val isDubbed: Boolean,
|
||||
@SerialName("images") val images: Thumbnail,
|
||||
@SerialName("duration_ms") val durationMs: Int,
|
||||
@SerialName("versions") val versions: List<Version>,
|
||||
@SerialName("versions") val versions: List<Version>? = null,
|
||||
@SerialName("streams_link") val streamsLink: String,
|
||||
)
|
||||
|
||||
|
|
|
@ -157,9 +157,9 @@ class PlayerViewModel(application: Application) : AndroidViewModel(application)
|
|||
if (newAudioLocale != currentAudioLocale) {
|
||||
currentAudioLocale = newAudioLocale
|
||||
|
||||
currentVersion = currentEpisode.versions.firstOrNull {
|
||||
currentVersion = currentEpisode.versions?.firstOrNull {
|
||||
it.audioLocale == currentAudioLocale.toLanguageTag()
|
||||
} ?: currentEpisode.versions.first()
|
||||
} ?: currentEpisode.versions?.first() ?: NoneVersion
|
||||
|
||||
viewModelScope.launch {
|
||||
currentStreams = Crunchyroll.streamsFromMediaGUID(currentVersion.mediaGUID)
|
||||
|
@ -223,14 +223,18 @@ class PlayerViewModel(application: Application) : AndroidViewModel(application)
|
|||
joinAll(
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
currentVersion = if (Preferences.preferSubbed) {
|
||||
currentEpisode.versions.first { it.original }
|
||||
currentEpisode.versions?.first { it.original } ?: NoneVersion
|
||||
} else {
|
||||
currentEpisode.versions
|
||||
.firstOrNull { it.audioLocale == currentAudioLocale.toLanguageTag() }
|
||||
?: currentEpisode.versions.first()
|
||||
currentEpisode.versions?.firstOrNull { it.audioLocale == currentAudioLocale.toLanguageTag() }
|
||||
?: currentEpisode.versions?.first() ?: NoneVersion
|
||||
}
|
||||
|
||||
currentStreams = Crunchyroll.streamsFromMediaGUID(currentVersion.mediaGUID)
|
||||
// get the current streams object, if no version is set, use streamsLink
|
||||
currentStreams = if (currentVersion != NoneVersion) {
|
||||
Crunchyroll.streamsFromMediaGUID(currentVersion.mediaGUID)
|
||||
} else {
|
||||
Crunchyroll.streams(currentEpisode.streamsLink)
|
||||
}
|
||||
Log.d(classTag, currentVersion.toString())
|
||||
},
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
|
|
|
@ -64,7 +64,7 @@ class LanguageSettingsDialogFragment : DialogFragment() {
|
|||
|
||||
val currentAudioLocal = Locale.forLanguageTag(model.currentVersion.audioLocale)
|
||||
var selectedAudioView: TextView? = null
|
||||
model.currentEpisode.versions.forEach { version ->
|
||||
model.currentEpisode.versions?.forEach { version ->
|
||||
val locale = Locale.forLanguageTag(version.audioLocale)
|
||||
val audioView = addLanguage(binding.linearAudioLanguages, locale) { v ->
|
||||
selectedAudioLocale = locale
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:scrollbars="none">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -572,9 +573,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/info_about_desc"
|
||||
/>
|
||||
<!-- android:textColor="?textSecondary" -->
|
||||
android:text="@string/info_about_desc" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:scrollbars="none">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
Loading…
Reference in New Issue