Some Kotlin cleanup
This commit is contained in:
parent
7aac687b46
commit
e856bcbbfe
|
@ -121,7 +121,7 @@ object VancedDownloader {
|
|||
"lang" -> {
|
||||
count++
|
||||
succesfulLangCount++
|
||||
if (count < lang?.count()!!)
|
||||
if (count < lang?.size!!)
|
||||
downloadSplits(context, "lang")
|
||||
else
|
||||
startVancedInstall(context)
|
||||
|
@ -133,7 +133,7 @@ object VancedDownloader {
|
|||
if (type == "lang") {
|
||||
count++
|
||||
when {
|
||||
count < lang?.count()!! -> downloadSplits(context, "lang")
|
||||
count < lang?.size!! -> downloadSplits(context, "lang")
|
||||
succesfulLangCount == 0 -> {
|
||||
lang?.add("en")
|
||||
downloadSplits(context, "lang")
|
||||
|
|
|
@ -3,8 +3,4 @@ package com.vanced.manager.ui.viewmodels
|
|||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.lifecycle.ViewModel
|
||||
|
||||
class SettingsViewModel(activity: FragmentActivity) : ViewModel() {
|
||||
|
||||
|
||||
|
||||
}
|
||||
class SettingsViewModel(activity: FragmentActivity) : ViewModel()
|
|
@ -9,7 +9,7 @@ import com.github.kittinunf.fuel.httpGet
|
|||
|
||||
object JsonHelper {
|
||||
|
||||
var dataMap: HashMap<String, JsonObject> = HashMap()
|
||||
private var dataMap: HashMap<String, JsonObject> = HashMap()
|
||||
|
||||
suspend fun getJson(url: String): JsonObject? {
|
||||
return try {
|
||||
|
|
|
@ -254,11 +254,8 @@ object PackageHelper {
|
|||
val apkFilesPath = context.getExternalFilesDir("vanced/root")?.path
|
||||
val fileInfoList = apkFilesPath?.let { it1 -> getFileInfoList(it1) }
|
||||
if (fileInfoList != null) {
|
||||
var modApk: FileInfo? = null
|
||||
for (file in fileInfoList) {
|
||||
if (file.name == "dark.apk" || file.name == "black.apk") {
|
||||
modApk = file
|
||||
}
|
||||
val modApk: FileInfo? = fileInfoList.lastOrNull {
|
||||
it.name == "dark.apk" || it.name == "black.apk"
|
||||
}
|
||||
if (modApk != null) {
|
||||
if (overwriteBase(modApk, fileInfoList, vancedVersionCode!!, context)) {
|
||||
|
@ -315,7 +312,7 @@ object PackageHelper {
|
|||
val installResult = Shell.su("pm install-commit $sessionId").exec()
|
||||
if (installResult.isSuccess) {
|
||||
return true
|
||||
} else
|
||||
}
|
||||
sendFailure(installResult.out, context)
|
||||
|
||||
return false
|
||||
|
@ -333,8 +330,9 @@ object PackageHelper {
|
|||
|
||||
if (parentFile.exists() && parentFile.canRead()) {
|
||||
val listFiles = parentFile.listFiles() ?: return ArrayList()
|
||||
for (file in listFiles)
|
||||
result.add(FileInfo(file.name, file.length(), file))
|
||||
listFiles.mapTo(result) {
|
||||
FileInfo(it.name, it.length(), it)
|
||||
}
|
||||
return result
|
||||
}
|
||||
val longLines = Shell.su("ls -l $splitApkPath").exec().out
|
||||
|
@ -425,10 +423,8 @@ object PackageHelper {
|
|||
}
|
||||
return true
|
||||
}
|
||||
else {
|
||||
return fixNoInstall(baseApkFiles, context)
|
||||
}
|
||||
}
|
||||
return fixNoInstall(baseApkFiles, context)
|
||||
}
|
||||
|
||||
|
@ -508,11 +504,9 @@ object PackageHelper {
|
|||
return false
|
||||
}
|
||||
}
|
||||
else {
|
||||
sendFailure(listOf("IFile_Missing").toMutableList(), context)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Throws(IOException::class)
|
||||
|
@ -534,14 +528,12 @@ object PackageHelper {
|
|||
if(execRes.isSuccess) {
|
||||
val result = execRes.out
|
||||
var version = 0
|
||||
for(line in result) {
|
||||
val versionCode = line.substringAfter("=")
|
||||
val versionCodeFiltered = versionCode.substringBefore(" ")
|
||||
if(version < Integer.valueOf(versionCodeFiltered))
|
||||
{
|
||||
version = Integer.valueOf(versionCodeFiltered)
|
||||
}
|
||||
}
|
||||
result
|
||||
.asSequence()
|
||||
.map { it.substringAfter("=") }
|
||||
.map { it.substringBefore(" ") }
|
||||
.filter { version < Integer.valueOf(it) }
|
||||
.forEach { version = Integer.valueOf(it) }
|
||||
return version
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue