fix exclude repo and strategy test

This commit is contained in:
CherretGit
2025-12-25 22:58:45 +07:00
parent b92e2d94da
commit 1e9f043112
4 changed files with 12 additions and 7 deletions

View File

@@ -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

View File

@@ -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)
}

View File

@@ -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)
}

View File

@@ -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)