mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 16:00:31 +05:30
Use array extensions.
This commit is contained in:
parent
030cc80c71
commit
e68677ab6d
@ -73,7 +73,7 @@ class PlayerSettings : BasePreferenceFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setupSubtitlePref(preference: ListPreference) {
|
private fun setupSubtitlePref(preference: ListPreference) {
|
||||||
val locales = LocaleHelper.getAvailableLocales().sortedBy { it.name }
|
val locales = LocaleHelper.getAvailableLocales()
|
||||||
val localeNames = locales.map { it.name }
|
val localeNames = locales.map { it.name }
|
||||||
.toMutableList()
|
.toMutableList()
|
||||||
localeNames.add(0, requireContext().getString(R.string.none))
|
localeNames.add(0, requireContext().getString(R.string.none))
|
||||||
|
@ -67,37 +67,16 @@ object LocaleHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getAvailableCountries(): List<Country> {
|
fun getAvailableCountries(): List<Country> {
|
||||||
val isoCountries = Locale.getISOCountries()
|
return Locale.getISOCountries()
|
||||||
val countries = mutableListOf<Country>()
|
.map { Country(Locale("", it).displayCountry, it) }
|
||||||
isoCountries.forEach { countryCode ->
|
.sortedBy { it.name }
|
||||||
val locale = Locale("", countryCode)
|
|
||||||
val countryName = locale.displayCountry
|
|
||||||
countries.add(
|
|
||||||
Country(
|
|
||||||
countryName,
|
|
||||||
countryCode
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
countries.sortBy { it.name }
|
|
||||||
return countries
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getAvailableLocales(): List<Country> {
|
fun getAvailableLocales(): List<Country> {
|
||||||
val availableLocales: Array<Locale> = Locale.getAvailableLocales()
|
return Locale.getAvailableLocales()
|
||||||
val locales = mutableListOf<Country>()
|
.distinctBy { it.language }
|
||||||
|
.map { Country(it.displayLanguage, it.language) }
|
||||||
availableLocales.forEach { locale ->
|
.sortedBy { it.name }
|
||||||
if (locales.filter { it.code == locale.language }.isEmpty()) {
|
|
||||||
locales.add(
|
|
||||||
Country(
|
|
||||||
locale.displayLanguage,
|
|
||||||
locale.language
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return locales
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getTrendingRegion(context: Context): String {
|
fun getTrendingRegion(context: Context): String {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user