mirror of
https://github.com/CherretGit/zaprett-app.git
synced 2026-03-22 00:28:15 +05:00
fix exclude repo and strategy test
This commit is contained in:
@@ -16,7 +16,6 @@ import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.navigationBarsPadding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material.icons.Icons
|
||||
|
||||
@@ -2,10 +2,12 @@ package com.cherret.zaprett.ui.viewmodel
|
||||
|
||||
import android.app.Application
|
||||
import com.cherret.zaprett.utils.RepoItemInfo
|
||||
import com.cherret.zaprett.utils.getAllExcludeLists
|
||||
import com.cherret.zaprett.utils.getAllLists
|
||||
import com.cherret.zaprett.utils.getHostList
|
||||
import com.cherret.zaprett.utils.getHostListMode
|
||||
|
||||
class HostRepoViewModel(application: Application): BaseRepoViewModel(application) {
|
||||
override fun getInstalledLists(): Array<String> = getAllLists()
|
||||
override fun getInstalledLists(): Array<String> = if (getHostListMode(sharedPreferences) == "whitelist") getAllLists() else getAllExcludeLists()
|
||||
override fun getRepoList(callback: (Result<List<RepoItemInfo>>) -> Unit) = getHostList(sharedPreferences, callback)
|
||||
}
|
||||
@@ -2,13 +2,15 @@ package com.cherret.zaprett.ui.viewmodel
|
||||
|
||||
import android.app.Application
|
||||
import com.cherret.zaprett.utils.RepoItemInfo
|
||||
import com.cherret.zaprett.utils.getAllExcludeIpsets
|
||||
import com.cherret.zaprett.utils.getAllIpsets
|
||||
import com.cherret.zaprett.utils.getAllLists
|
||||
import com.cherret.zaprett.utils.getHostList
|
||||
import com.cherret.zaprett.utils.getHostListMode
|
||||
import com.cherret.zaprett.utils.getIpsetList
|
||||
|
||||
class IpsetRepoViewModel(application: Application): BaseRepoViewModel(application) {
|
||||
override fun getInstalledLists(): Array<String> = getAllIpsets()
|
||||
override fun getInstalledLists(): Array<String> = if(getHostListMode(sharedPreferences) == "whitelist") getAllIpsets() else getAllExcludeIpsets()
|
||||
override fun getRepoList(callback: (Result<List<RepoItemInfo>>) -> Unit) =
|
||||
getIpsetList(sharedPreferences, callback)
|
||||
}
|
||||
@@ -122,7 +122,7 @@ class StrategySelectionViewModel(application: Application) : AndroidViewModel(ap
|
||||
}
|
||||
suspend fun performTest() {
|
||||
val targets = readActiveListsLines()
|
||||
var stopTest : Boolean = false;
|
||||
var stopTest = false
|
||||
for (index in strategyStates.indices) {
|
||||
val current = strategyStates[index]
|
||||
if (stopTest) break
|
||||
@@ -133,9 +133,11 @@ class StrategySelectionViewModel(application: Application) : AndroidViewModel(ap
|
||||
_errorFlow.value = error
|
||||
if (error.isNotEmpty()) stopTest = true
|
||||
} }
|
||||
startService { error ->
|
||||
_errorFlow.value = error
|
||||
if (error.isNotEmpty()) stopTest = true
|
||||
getStatus {
|
||||
if (!it) startService { error ->
|
||||
_errorFlow.value = error
|
||||
if (error.isNotEmpty()) stopTest = true
|
||||
}
|
||||
}
|
||||
try {
|
||||
val progress = countReachable(index, targets)
|
||||
|
||||
Reference in New Issue
Block a user