Update subscriptions based on grouping
https://github.com/2dust/v2rayNG/issues/3445
This commit is contained in:
@@ -589,7 +589,7 @@ class MainActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedList
|
|||||||
binding.pbWaiting.show()
|
binding.pbWaiting.show()
|
||||||
|
|
||||||
lifecycleScope.launch(Dispatchers.IO) {
|
lifecycleScope.launch(Dispatchers.IO) {
|
||||||
val count = AngConfigManager.updateConfigViaSubAll()
|
val count = mainViewModel.updateConfigViaSubAll()
|
||||||
delay(500L)
|
delay(500L)
|
||||||
launch(Dispatchers.Main) {
|
launch(Dispatchers.Main) {
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
|
|||||||
@@ -535,7 +535,7 @@ object AngConfigManager {
|
|||||||
return count
|
return count
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateConfigViaSub(it: Pair<String, SubscriptionItem>): Int {
|
fun updateConfigViaSub(it: Pair<String, SubscriptionItem>): Int {
|
||||||
try {
|
try {
|
||||||
if (TextUtils.isEmpty(it.first)
|
if (TextUtils.isEmpty(it.first)
|
||||||
|| TextUtils.isEmpty(it.second.remarks)
|
|| TextUtils.isEmpty(it.second.remarks)
|
||||||
|
|||||||
@@ -20,12 +20,15 @@ import com.v2ray.ang.dto.EConfigType
|
|||||||
import com.v2ray.ang.dto.ProfileItem
|
import com.v2ray.ang.dto.ProfileItem
|
||||||
import com.v2ray.ang.dto.ServerConfig
|
import com.v2ray.ang.dto.ServerConfig
|
||||||
import com.v2ray.ang.dto.ServersCache
|
import com.v2ray.ang.dto.ServersCache
|
||||||
|
import com.v2ray.ang.dto.SubscriptionItem
|
||||||
import com.v2ray.ang.dto.V2rayConfig
|
import com.v2ray.ang.dto.V2rayConfig
|
||||||
import com.v2ray.ang.extension.toast
|
import com.v2ray.ang.extension.toast
|
||||||
import com.v2ray.ang.util.AngConfigManager
|
import com.v2ray.ang.util.AngConfigManager
|
||||||
|
import com.v2ray.ang.util.AngConfigManager.updateConfigViaSub
|
||||||
import com.v2ray.ang.util.MessageUtil
|
import com.v2ray.ang.util.MessageUtil
|
||||||
import com.v2ray.ang.util.MmkvManager
|
import com.v2ray.ang.util.MmkvManager
|
||||||
import com.v2ray.ang.util.MmkvManager.KEY_ANG_CONFIGS
|
import com.v2ray.ang.util.MmkvManager.KEY_ANG_CONFIGS
|
||||||
|
import com.v2ray.ang.util.MmkvManager.subStorage
|
||||||
import com.v2ray.ang.util.SpeedtestUtil
|
import com.v2ray.ang.util.SpeedtestUtil
|
||||||
import com.v2ray.ang.util.Utils
|
import com.v2ray.ang.util.Utils
|
||||||
import com.v2ray.ang.util.V2rayConfigUtil
|
import com.v2ray.ang.util.V2rayConfigUtil
|
||||||
@@ -152,6 +155,18 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun updateConfigViaSubAll(): Int {
|
||||||
|
if (subscriptionId.isNullOrEmpty()) {
|
||||||
|
return AngConfigManager.updateConfigViaSubAll()
|
||||||
|
} else {
|
||||||
|
val json = subStorage?.decodeString(subscriptionId)
|
||||||
|
if (!json.isNullOrBlank()) {
|
||||||
|
return updateConfigViaSub(Pair(subscriptionId, Gson().fromJson(json, SubscriptionItem::class.java)))
|
||||||
|
} else {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun exportAllServer(): Int {
|
fun exportAllServer(): Int {
|
||||||
val serverListCopy =
|
val serverListCopy =
|
||||||
|
|||||||
Reference in New Issue
Block a user