Browse Source

working on ping ms...

Khubaib 1 năm trước cách đây
mục cha
commit
4628d814a6

+ 6 - 1
app/src/main/java/com/vpn/fastestvpnservice/customItems/CountryItem.kt

@@ -79,7 +79,12 @@ import java.util.logging.Handler
 var serverInfoObj: MutableState<Server> = mutableStateOf(Server())
 
 @Composable
-fun CountryItem(server: Server, category: String, countryTotalServers: Int, navHostController: NavHostController) {
+fun CountryItem(
+    server: Server,
+    category: String,
+    countryTotalServers: Int,
+    navHostController: NavHostController
+) {
     Log.d("test_countrySize", "CountryItem Called ${server.server_name} ${server.totalServers}")
     Box(
         modifier = Modifier

+ 1 - 1
app/src/main/java/com/vpn/fastestvpnservice/screens/ServerListScreen.kt

@@ -682,7 +682,7 @@ fun ColumnScope.ShowAllLocationsList(
                                         Log.d("test_ping_stream", "SLS : ${country.server_name} ${it}")
                                         pingResult = it
                                     })
-                                    ServerItem(server = country, navHostController, pingResult)
+                                    ServerItem(server = country, navHostController, country.ping)
 
 //                                        Log.d("test_fav_server_logic", "${country.server_name} ${it}")
                                 })

+ 11 - 7
app/src/main/java/com/vpn/fastestvpnservice/viewmodels/ServerListViewModel.kt

@@ -333,6 +333,10 @@ class ServerListViewModel(context: Context): ViewModel() {
 //                    distinctBy.get(index).totalServers = entry.value.sumBy { it.totalServers }
                     distinctBy.get(index).totalServers = 1
 
+                    calculatePing(value) {
+                        distinctBy.get(index).ping = it
+                    }
+
 //                    distinctBy.get(index).countryServers = entry.value
                 }
             }
@@ -346,13 +350,13 @@ class ServerListViewModel(context: Context): ViewModel() {
             }
         }
 
-        filterList.forEach {server ->
-            calculatePing(server) {
-                server.ping = it
-            }
-            Log.d("test_ping_stream", "${server.ping}")
-
-        }
+//        filterList.forEach {server ->
+//            calculatePing(server) {
+//                server.ping = it
+//            }
+//            Log.d("test_ping_stream", "${server.ping}")
+//
+//        }
         return (filterList)
     }