mirror of
https://github.com/yggdrasil-network/crispa-android.git
synced 2025-01-22 16:06:30 +00:00
2. fix adding Peers when json url unavailable
This commit is contained in:
parent
2e25e2e08c
commit
0201705c45
@ -28,6 +28,7 @@ import kotlinx.coroutines.GlobalScope
|
|||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
|
import java.io.FileNotFoundException
|
||||||
import java.lang.reflect.Type
|
import java.lang.reflect.Type
|
||||||
import java.net.InetAddress
|
import java.net.InetAddress
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
@ -77,6 +78,7 @@ class PeerListActivity : AppCompatActivity() {
|
|||||||
var ping = ping(pi.address, pi.port)
|
var ping = ping(pi.address, pi.port)
|
||||||
pi.ping = ping
|
pi.ping = ping
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
var json = downloadJson(PEER_LIST_URL)
|
var json = downloadJson(PEER_LIST_URL)
|
||||||
var countries = CCPCountry.getLibraryMasterCountriesEnglish()
|
var countries = CCPCountry.getLibraryMasterCountriesEnglish()
|
||||||
val mapType: Type = object :
|
val mapType: Type = object :
|
||||||
@ -113,6 +115,9 @@ class PeerListActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch(e: FileNotFoundException){
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
var currentPeers = ArrayList(cp.sortedWith(compareBy { it.ping }))
|
var currentPeers = ArrayList(cp.sortedWith(compareBy { it.ping }))
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
adapter.addAll(0, currentPeers)
|
adapter.addAll(0, currentPeers)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user