|
@@ -713,6 +713,7 @@ class ServerListViewModel(context: Context): ViewModel() {
|
|
|
fun getFavList(toReturn: Boolean = false): ArrayList<Server> {
|
|
|
val tempList = ArrayList<Server>()
|
|
|
val getServersIdList = preferencesHelper.getServersId()
|
|
|
+ val serverList = ArrayList<Server>()
|
|
|
|
|
|
// preferencesHelper.getServerData().let {
|
|
|
// it.forEach {
|
|
@@ -724,14 +725,24 @@ class ServerListViewModel(context: Context): ViewModel() {
|
|
|
|
|
|
preferencesHelper.getServerData().let {
|
|
|
it.forEach {
|
|
|
- tempList.addAll(it.servers?.filter { server ->
|
|
|
- getServersIdList?.any { id ->
|
|
|
- server.id == id
|
|
|
- } == true
|
|
|
- }!!)
|
|
|
+ it.servers?.let { it1 -> serverList.addAll(it1) }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// val serverProtocol = serverList.filter {
|
|
|
+// it.protocol.equals(preferencesHelper.getProtocol().title, ignoreCase = true)
|
|
|
+// }
|
|
|
+
|
|
|
+ Log.d("test_fav_lang", "SLVM -> serverList = ${serverList.size}")
|
|
|
+// Log.d("test_fav_lang", "SLVM -> serverProtocol = ${serverProtocol.size}")
|
|
|
+// Log.d("test_fav_lang", "SLVM -> distinctBy = ${distinctBy.size}")
|
|
|
+
|
|
|
+ tempList.addAll(serverList.filter { server ->
|
|
|
+ getServersIdList?.any { id ->
|
|
|
+ server.id == id
|
|
|
+ } == true
|
|
|
+ })
|
|
|
+
|
|
|
if (isAlphabetList.value) {
|
|
|
tempList.sortBy {
|
|
|
it.server_name
|
|
@@ -740,21 +751,16 @@ class ServerListViewModel(context: Context): ViewModel() {
|
|
|
|
|
|
tempList.forEachIndexed { index, server ->
|
|
|
server.isFavourited = true
|
|
|
- Log.d("test_fav_lang", "SLVM -> ${server.server_name} ${server.id}")
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- tempList.forEachIndexed { index, server ->
|
|
|
calculatePing(server) {
|
|
|
server.ping = it
|
|
|
}
|
|
|
}
|
|
|
-//
|
|
|
-// if (toReturn) {
|
|
|
-// _mutableLiveDataGetFavList.value = tempList
|
|
|
-// }
|
|
|
|
|
|
- return tempList
|
|
|
+ val distinctBy: List<Server> = tempList.distinctBy {
|
|
|
+ it.id
|
|
|
+ }
|
|
|
+
|
|
|
+ return distinctBy as ArrayList
|
|
|
}
|
|
|
|
|
|
fun getServerData(): ArrayList<ServerData> {
|