This commit is contained in:
noemi3 2020-01-07 10:51:33 +01:00
parent bce45d2605
commit ac590e418d

View File

@ -3,6 +3,7 @@ package it.unisannio.ding.ids.wedroid.app.view
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import android.webkit.URLUtil
import android.widget.Toast import android.widget.Toast
import it.unisannio.ding.ids.wedroid.app.R import it.unisannio.ding.ids.wedroid.app.R
import it.unisannio.ding.ids.wedroid.app.util.SharedPreferenceHelper import it.unisannio.ding.ids.wedroid.app.util.SharedPreferenceHelper
@ -39,10 +40,17 @@ class LoginActivity : AppCompatActivity() {
val userNameText = username.text.toString() val userNameText = username.text.toString()
val passwordText = password.text.toString() val passwordText = password.text.toString()
val instanceServerText = instanceServer.text.toString()
if (!URLUtil.isValidUrl(instanceServerText)){
Toast.makeText(this, "Formato URL non valido", Toast.LENGTH_LONG)
.show()
return
}
val service = Retrofit.Builder() val service = Retrofit.Builder()
.addConverterFactory(GsonConverterFactory.create()) .addConverterFactory(GsonConverterFactory.create())
.baseUrl(instanceServer.text.toString()) .baseUrl(instanceServerText)
.build() .build()
.create(LoginService::class.java) .create(LoginService::class.java)