|
@@ -3,12 +3,9 @@ package com.vpn.fastestvpnservice.viewmodels
|
|
|
import android.content.Context
|
|
|
import android.os.Looper
|
|
|
import android.util.Log
|
|
|
-import androidx.compose.runtime.MutableState
|
|
|
-import androidx.compose.runtime.mutableStateOf
|
|
|
import androidx.lifecycle.LiveData
|
|
|
import androidx.lifecycle.MutableLiveData
|
|
|
import androidx.lifecycle.ViewModel
|
|
|
-import androidx.lifecycle.ViewModelProvider
|
|
|
import com.google.gson.Gson
|
|
|
import com.google.gson.reflect.TypeToken
|
|
|
import com.stealthcopter.networktools.Ping
|
|
@@ -18,7 +15,6 @@ import com.vpn.fastestvpnservice.beans.Server
|
|
|
import com.vpn.fastestvpnservice.beans.ServerData
|
|
|
import com.vpn.fastestvpnservice.beans.ServerResponse
|
|
|
import com.vpn.fastestvpnservice.helpers.BasePreferenceHelper
|
|
|
-import com.vpn.fastestvpnservice.helpers.UIHelper
|
|
|
import com.vpn.fastestvpnservice.retrofit.RetrofitNetworkHandling
|
|
|
import com.vpn.fastestvpnservice.retrofit.WebServiceFactory
|
|
|
import com.vpn.fastestvpnservice.screens.isAlphabetList
|
|
@@ -40,7 +36,7 @@ class ServerListViewModel(context: Context): ViewModel() {
|
|
|
var _mutableLiveDataPagerIndex = MutableLiveData<Int>(0)
|
|
|
var liveDataPagerIndex: LiveData<Int> = _mutableLiveDataPagerIndex
|
|
|
|
|
|
- var _mutableLiveDataGetFavList = MutableLiveData<ArrayList<Server>>(getFavList())
|
|
|
+ var _mutableLiveDataGetFavList = MutableLiveData<ArrayList<Server>>(getFavList(isAlphabetList.value))
|
|
|
var liveDataGetFavList: LiveData<ArrayList<Server>> = _mutableLiveDataGetFavList
|
|
|
|
|
|
var _mutableLiveDataGetServers = MutableLiveData<ArrayList<Server>>()
|
|
@@ -506,19 +502,12 @@ class ServerListViewModel(context: Context): ViewModel() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- tempList.forEachIndexed { index, server ->
|
|
|
- calculatePing(server) {
|
|
|
- server.ping = it
|
|
|
+ if (isAlphabetList.value) {
|
|
|
+ tempList.sortBy {
|
|
|
+ it.server_name
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// if (isAlphabetList.value) {
|
|
|
-// tempList.sortBy {
|
|
|
-// it.server_name
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
- Log.d("test_server favList", "size of favlist = ${tempList.size}")
|
|
|
return tempList
|
|
|
}
|
|
|
|