some crash fixes
This commit is contained in:
parent
8f026e9a3b
commit
34980c2605
|
@ -37,7 +37,8 @@
|
|||
<activity
|
||||
android:name=".ui.MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/DarkTheme.Blue"/>
|
||||
android:theme="@style/DarkTheme.Blue"
|
||||
android:exported="true"/>
|
||||
|
||||
<meta-data
|
||||
android:name="preloaded_fonts"
|
||||
|
|
|
@ -37,25 +37,10 @@ class VancedLanguageSelectionFragment : Fragment() {
|
|||
@ExperimentalStdlibApi
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val langcor = CoroutineScope(Dispatchers.IO).async {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
langs = getArrayFromJson("${PreferenceManager.getDefaultSharedPreferences(requireActivity()).getString("install_url", baseUrl)}/vanced.json", "langs")
|
||||
}
|
||||
CoroutineScope(Dispatchers.Main).launch {
|
||||
langcor.await()
|
||||
if (!langs.contains("null")) {
|
||||
langs.forEach { lang ->
|
||||
val loc = Locale(lang)
|
||||
val box: MaterialCheckBox = MaterialCheckBox(requireActivity()).apply {
|
||||
tag = lang
|
||||
text = loc.getDisplayLanguage(loc).capitalize(Locale.ROOT)
|
||||
textSize = 18F
|
||||
typeface = ResourcesCompat.getFont(requireActivity(), R.font.exo_bold)
|
||||
}
|
||||
view.findViewById<LinearLayout>(R.id.lang_button_ll)
|
||||
.addView(box, MATCH_PARENT, WRAP_CONTENT)
|
||||
}
|
||||
}
|
||||
}
|
||||
loadBoxes(view.findViewById(R.id.lang_button_ll))
|
||||
view.findViewById<MaterialButton>(R.id.vanced_install_finish).setOnClickListener {
|
||||
val chosenLangs = mutableListOf("en")
|
||||
if (!langs.contains("null"))
|
||||
|
@ -75,4 +60,25 @@ class VancedLanguageSelectionFragment : Fragment() {
|
|||
}
|
||||
}
|
||||
|
||||
@ExperimentalStdlibApi
|
||||
private fun loadBoxes(ll: LinearLayout) {
|
||||
CoroutineScope(Dispatchers.Main).launch {
|
||||
if (this@VancedLanguageSelectionFragment::langs.isInitialized) {
|
||||
if (!langs.contains("null")) {
|
||||
langs.forEach { lang ->
|
||||
val loc = Locale(lang)
|
||||
val box: MaterialCheckBox = MaterialCheckBox(requireActivity()).apply {
|
||||
tag = lang
|
||||
text = loc.getDisplayLanguage(loc).capitalize(Locale.ROOT)
|
||||
textSize = 18F
|
||||
typeface = ResourcesCompat.getFont(requireActivity(), R.font.exo_bold)
|
||||
}
|
||||
ll.addView(box, MATCH_PARENT, WRAP_CONTENT)
|
||||
}
|
||||
}
|
||||
} else
|
||||
loadBoxes(ll)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue