|
@@ -119,12 +119,31 @@ class ServerListViewModel(context: Context): ViewModel() {
|
|
|
}
|
|
|
|
|
|
if (sortedDistance.isNotEmpty()) {
|
|
|
- for (i in 0..2) {
|
|
|
- calculatePing(sortedDistance.get(i)) {
|
|
|
- sortedDistance.get(i).ping = it
|
|
|
+ var intRange: IntRange = 0..0
|
|
|
+ intRange = when (sortedDistance.size) {
|
|
|
+ 1 -> {
|
|
|
+ 0..0
|
|
|
}
|
|
|
- recommendedListGlobal.add(sortedDistance.get(i))
|
|
|
+
|
|
|
+ 2 -> {
|
|
|
+ 0..1
|
|
|
+ }
|
|
|
+
|
|
|
+ 3 -> {
|
|
|
+ 0..2
|
|
|
+ }
|
|
|
+ else -> {
|
|
|
+ 0..2
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (sortedDistance.isNotEmpty()) {
|
|
|
+ for (i in intRange) {
|
|
|
+ calculatePing(sortedDistance.get(i)) {
|
|
|
+ sortedDistance.get(i).ping = it
|
|
|
+ }
|
|
|
+ recommendedListGlobal.add(sortedDistance.get(i))
|
|
|
// Log.d("recommendedListGlobal", "SS:: server = ${sortedDistance.get(i).server_name} ${sortedDistance.get(i).ping}")
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|