Skip to content

Commit

Permalink
To idiomatic Kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
strangesource committed Nov 15, 2024
1 parent c6d09fa commit 6c0fe0b
Showing 1 changed file with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ fun ReadableMap.toStyleConfig(): StyleConfig = StyleConfig().apply {
}

/**
* Converts any JS string into an `AdSourceType` enum value.
* Converts any JS string into an `ForceReuseVideoCodecReason` enum value.
*/
private fun String.forceReuseVideoCodecReason(): ForceReuseVideoCodecReason? = when (this) {
private fun String.toForceReuseVideoCodecReason(): ForceReuseVideoCodecReason? = when (this) {
"ColorInfoMismatch" -> ForceReuseVideoCodecReason.ColorInfoMismatch
"MaxInputSizeExceeded" -> ForceReuseVideoCodecReason.MaxInputSizeExceeded
"MaxResolutionExceeded" -> ForceReuseVideoCodecReason.MaxResolutionExceeded
Expand Down Expand Up @@ -201,14 +201,10 @@ fun ReadableMap.toTweaksConfig(): TweaksConfig = TweaksConfig().apply {
withBoolean("useFiletypeExtractorFallbackForHls") { useFiletypeExtractorFallbackForHls = it }
withBoolean("preferSoftwareDecodingForAds") { preferSoftwareDecodingForAds = it }
withStringArray("forceReuseVideoCodecReasons") {
val mutableSet = mutableSetOf<ForceReuseVideoCodecReason>()
for (item in it) {
val reason = item?.forceReuseVideoCodecReason()
if (reason != null) {
mutableSet.add(reason)
}
}
forceReuseVideoCodecReasons = mutableSet
forceReuseVideoCodecReasons = it
.filterNotNull()
.mapNotNull(String::toForceReuseVideoCodecReason)
.toSet()
}
}

Expand Down

0 comments on commit 6c0fe0b

Please sign in to comment.