Test connection after updating subscription
This commit is contained in:
@@ -342,11 +342,13 @@ class MainActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedList
|
||||
}
|
||||
|
||||
R.id.ping_all -> {
|
||||
toast(R.string.connection_test_testing)
|
||||
mainViewModel.testAllTcping()
|
||||
true
|
||||
}
|
||||
|
||||
R.id.real_ping_all -> {
|
||||
toast(R.string.connection_test_testing)
|
||||
mainViewModel.testAllRealPing()
|
||||
true
|
||||
}
|
||||
@@ -604,8 +606,10 @@ class MainActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedList
|
||||
delay(500L)
|
||||
launch(Dispatchers.Main) {
|
||||
if (count > 0) {
|
||||
toast(R.string.toast_success)
|
||||
//toast(R.string.toast_success)
|
||||
toast(R.string.connection_test_testing)
|
||||
mainViewModel.reloadServerList()
|
||||
mainViewModel.testAllRealPing()
|
||||
} else {
|
||||
toast(R.string.toast_failure)
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import com.v2ray.ang.dto.V2rayConfig
|
||||
import com.v2ray.ang.extension.serializable
|
||||
import com.v2ray.ang.extension.toast
|
||||
import com.v2ray.ang.util.AngConfigManager
|
||||
import com.v2ray.ang.util.AngConfigManager.updateConfigViaSub
|
||||
import com.v2ray.ang.util.JsonUtil
|
||||
import com.v2ray.ang.util.MessageUtil
|
||||
import com.v2ray.ang.util.MmkvManager
|
||||
@@ -157,7 +156,7 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
||||
return AngConfigManager.updateConfigViaSubAll()
|
||||
} else {
|
||||
val subItem = MmkvManager.decodeSubscription(subscriptionId) ?: return 0
|
||||
return updateConfigViaSub(Pair(subscriptionId, subItem))
|
||||
return AngConfigManager.updateConfigViaSub(Pair(subscriptionId, subItem))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,10 +180,10 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
||||
tcpingTestScope.coroutineContext[Job]?.cancelChildren()
|
||||
SpeedtestUtil.closeAllTcpSockets()
|
||||
MmkvManager.clearAllTestDelayResults(serversCache.map { it.guid }.toList())
|
||||
updateListAction.value = -1 // update all
|
||||
//updateListAction.value = -1 // update all
|
||||
|
||||
getApplication<AngApplication>().toast(R.string.connection_test_testing)
|
||||
for (item in serversCache) {
|
||||
val serversCopy = serversCache.toList() // Create a copy of the list
|
||||
for (item in serversCopy) {
|
||||
item.profile.let { outbound ->
|
||||
val serverAddress = outbound.server
|
||||
val serverPort = outbound.serverPort
|
||||
@@ -207,8 +206,6 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
||||
updateListAction.value = -1 // update all
|
||||
|
||||
val serversCopy = serversCache.toList() // Create a copy of the list
|
||||
|
||||
getApplication<AngApplication>().toast(R.string.connection_test_testing)
|
||||
viewModelScope.launch(Dispatchers.Default) { // without Dispatchers.Default viewModelScope will launch in main thread
|
||||
for (item in serversCopy) {
|
||||
MessageUtil.sendMsg2TestService(getApplication(), AppConfig.MSG_MEASURE_CONFIG, item.guid)
|
||||
|
||||
Reference in New Issue
Block a user