add preferred content language selection

followup to 0b5a8e69fb
This commit is contained in:
2022-03-04 20:29:37 +01:00
parent a51001ec2e
commit e8bf63a666
5 changed files with 101 additions and 18 deletions

View File

@ -3,8 +3,8 @@ package org.mosad.teapod.util
import android.widget.TextView
import org.mosad.teapod.parser.crunchyroll.Collection
import org.mosad.teapod.parser.crunchyroll.ContinueWatchingItem
import org.mosad.teapod.parser.crunchyroll.ContinueWatchingList
import org.mosad.teapod.parser.crunchyroll.Item
import java.util.*
fun TextView.setDrawableTop(drawable: Int) {
this.setCompoundDrawablesWithIntrinsicBounds(0, drawable, 0, 0)
@ -27,3 +27,13 @@ fun Collection<ContinueWatchingItem>.toItemMediaList(): List<ItemMedia> {
ItemMedia(it.panel.episodeMetadata.seriesId, it.panel.title, it.panel.images.thumbnail[0][0].source)
}
}
fun Locale.toDisplayString(fallback: String): String {
return if (this.displayLanguage.isNotEmpty() && this.displayCountry.isNotEmpty()) {
"${this.displayLanguage} (${this.displayCountry})"
} else if (this.displayCountry.isNotEmpty()) {
this.displayLanguage
} else {
fallback
}
}