0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-18 01:05:10 +00:00

fix VancedDownloader lang npe

This commit is contained in:
HaliksaR 2020-11-15 06:28:11 +07:00
parent 31162db145
commit b7ba61b5e2

View file

@ -36,7 +36,7 @@ object VancedDownloader {
private var installUrl: String? = null private var installUrl: String? = null
private var variant: String? = null private var variant: String? = null
private var theme: String? = null private var theme: String? = null
private var lang: MutableList<String>? = null private var lang = mutableListOf<String>()
private lateinit var themePath: String private lateinit var themePath: String
@ -56,7 +56,9 @@ object VancedDownloader {
downloadPath = context.getExternalFilesDir("vanced/$variant")?.path downloadPath = context.getExternalFilesDir("vanced/$variant")?.path
File(downloadPath.toString()).deleteRecursively() File(downloadPath.toString()).deleteRecursively()
installUrl = defPrefs.getInstallUrl() installUrl = defPrefs.getInstallUrl()
lang = prefs.getString("lang", getDefaultVancedLanguages())?.split(", ")?.toMutableList() prefs.getString("lang", getDefaultVancedLanguages())?.let {
lang = it.split(", ").toMutableList()
}
theme = prefs.getString("theme", "dark") theme = prefs.getString("theme", "dark")
vancedVersion = defPrefs.getString("vanced_version", "latest")?.getLatestAppVersion(vancedVersions.get()?.value ?: listOf("")) vancedVersion = defPrefs.getString("vanced_version", "latest")?.getLatestAppVersion(vancedVersions.get()?.value ?: listOf(""))
themePath = "$installUrl/apks/v$vancedVersion/$variant/Theme" themePath = "$installUrl/apks/v$vancedVersion/$variant/Theme"
@ -112,7 +114,7 @@ object VancedDownloader {
"lang" -> { "lang" -> {
count++ count++
succesfulLangCount++ succesfulLangCount++
if (count < lang?.size!!) if (count < lang.size)
downloadSplits(context, "lang") downloadSplits(context, "lang")
else else
startVancedInstall(context) startVancedInstall(context)
@ -132,9 +134,9 @@ object VancedDownloader {
if (type == "lang") { if (type == "lang") {
count++ count++
when { when {
count < lang?.size!! -> downloadSplits(context, "lang") count < lang.size -> downloadSplits(context, "lang")
succesfulLangCount == 0 -> { succesfulLangCount == 0 -> {
lang?.add("en") lang.add("en")
downloadSplits(context, "lang") downloadSplits(context, "lang")
} }
else -> startVancedInstall(context) else -> startVancedInstall(context)