|
@@ -25,6 +25,7 @@ import com.vpn.fastestvpnservice.screens.countriesListGlobal
|
|
|
import com.vpn.fastestvpnservice.screens.isAlphabetList
|
|
|
import com.vpn.fastestvpnservice.screens.recommendedListGlobal
|
|
|
import com.vpn.fastestvpnservice.screens.serverListViewModelSplash
|
|
|
+import com.vpn.fastestvpnservice.screens.serversGroupListGlobal
|
|
|
import com.vpn.fastestvpnservice.screens.serversListGlobal
|
|
|
import com.vpn.fastestvpnservice.screens.smartLocationListGlobal
|
|
|
import retrofit2.Call
|
|
@@ -37,8 +38,8 @@ class ServerListViewModel(context: Context): ViewModel() {
|
|
|
val mutableLiveDataFavourite = MutableLiveData<List<Server>>()
|
|
|
val mutableLiveDataFavUnFav = MutableLiveData<ServerResponse?>()
|
|
|
|
|
|
- var mutableLiveDataGroupServers = MutableLiveData<ArrayList<Server>>()
|
|
|
- var liveDataGroupServers: LiveData<ArrayList<Server>> = mutableLiveDataGroupServers
|
|
|
+ var mutableLiveDataGroupServers = MutableLiveData<ArrayList<ServerDataGlobal>>()
|
|
|
+ var liveDataGroupServers: LiveData<ArrayList<ServerDataGlobal>> = mutableLiveDataGroupServers
|
|
|
|
|
|
var _mutableLiveDataTest = MutableLiveData<Int>(0)
|
|
|
var liveDataTest: LiveData<Int> = _mutableLiveDataTest
|
|
@@ -141,11 +142,11 @@ class ServerListViewModel(context: Context): ViewModel() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- smartLocationList.forEach {
|
|
|
-// preferencesHelper.setSmartServerObject(it)
|
|
|
- preferencesHelper.setRecommendedServerObject(it)
|
|
|
- Log.d("smartLocationList", "SS:: server = ${it.server_name}")
|
|
|
- }
|
|
|
+// smartLocationList.forEach {
|
|
|
+//// preferencesHelper.setSmartServerObject(it)
|
|
|
+// preferencesHelper.setRecommendedServerObject(it)
|
|
|
+// Log.d("smartLocationList", "SS:: server = ${it.server_name}")
|
|
|
+// }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -165,6 +166,12 @@ class ServerListViewModel(context: Context): ViewModel() {
|
|
|
it, isAlphabetList.value
|
|
|
)
|
|
|
serversListGlobal.add(index, ServerDataGlobal(serverData.name, servers))
|
|
|
+
|
|
|
+ servers.forEachIndexed { index, server ->
|
|
|
+ Log.d("test_filterList", "${server.server_name} ${server.country}")
|
|
|
+ getServerGroupList(server, it, index)
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
} else {
|
|
|
data[index].servers?.let {
|
|
@@ -220,10 +227,9 @@ class ServerListViewModel(context: Context): ViewModel() {
|
|
|
distinctBy.get(index).totalServers = entry.value.sumBy { it.totalServers }
|
|
|
// distinctBy.get(index).totalServers = 1
|
|
|
|
|
|
-
|
|
|
var total_enables = entry.value.sumBy { it.enable }
|
|
|
|
|
|
- println("--testing "+entry.value.size +" : "+total_enables+" : "+value.country)
|
|
|
+ println("__testing"+entry.value.size +" : "+total_enables+" : "+value.country)
|
|
|
|
|
|
entry.value.forEachIndexed { indexs, server ->
|
|
|
Log.d("test_country_servers",server.country + " " + server.server_name.toString())
|
|
@@ -615,7 +621,7 @@ class ServerListViewModel(context: Context): ViewModel() {
|
|
|
}
|
|
|
|
|
|
fun getServerGroupList(
|
|
|
- server: Server, serverList: ArrayList<Server>
|
|
|
+ server: Server, serverList: ArrayList<Server>, index: Int
|
|
|
): ArrayList<Server> {
|
|
|
|
|
|
val tempList = ArrayList<Server>()
|
|
@@ -631,20 +637,18 @@ class ServerListViewModel(context: Context): ViewModel() {
|
|
|
it.server_name
|
|
|
}
|
|
|
|
|
|
-// tempList.forEachIndexed { index, servers ->
|
|
|
-// Log.d("tempList_servers", "${servers.server_name} , ${servers.country}")
|
|
|
-// }
|
|
|
-
|
|
|
val tempList2 = ArrayList<Server>()
|
|
|
- tempList.forEachIndexed { index, server1 ->
|
|
|
+
|
|
|
+ tempList.forEachIndexed { index1, server1 ->
|
|
|
calculatePing(server1){
|
|
|
- Log.d("serverInfo_ping", "serverInfo $it")
|
|
|
+ Log.d("serverInfo_ping", "In: ${server1.server_name} $it")
|
|
|
server1.ping = it
|
|
|
}
|
|
|
tempList2.add(server1)
|
|
|
}
|
|
|
|
|
|
- mutableLiveDataGroupServers.value = tempList2
|
|
|
+ serversGroupListGlobal.add(index, ServerDataGlobal(server.country, tempList2))
|
|
|
+ mutableLiveDataGroupServers.value = serversGroupListGlobal
|
|
|
|
|
|
return tempList2
|
|
|
}
|