1. added new peer input fields checks

This commit is contained in:
vadym 2020-08-08 05:43:02 -07:00
parent 72ec1a5300
commit a7322a7ff3

View File

@ -161,8 +161,20 @@ class PeerListActivity : AppCompatActivity() {
var portInput = view.findViewById<TextView>(R.id.portInput) var portInput = view.findViewById<TextView>(R.id.portInput)
var ccpInput = view.findViewById<com.hbb20.CountryCodePicker>(R.id.ccp) var ccpInput = view.findViewById<com.hbb20.CountryCodePicker>(R.id.ccp)
var schema = schemaInput.text.toString().toLowerCase() var schema = schemaInput.text.toString().toLowerCase()
if(schema.isEmpty()){
schemaInput.error = "Schema is required"
}
var ip = ipInput.text.toString().toLowerCase() var ip = ipInput.text.toString().toLowerCase()
if(ip.isEmpty()){
ipInput.error = "IP address is required"
}
var port = portInput.text.toString().toInt() var port = portInput.text.toString().toInt()
if(port<=0){
portInput.error = "Port should be > 0"
}
if(port>=Short.MAX_VALUE){
portInput.error = "Port should be < "+Short.MAX_VALUE
}
var ccp = ccpInput.selectedCountryNameCode var ccp = ccpInput.selectedCountryNameCode
GlobalScope.launch { GlobalScope.launch {
var pi = PeerInfo(schema, InetAddress.getByName(ip), port, ccp) var pi = PeerInfo(schema, InetAddress.getByName(ip), port, ccp)