Implement URL input format checks

This commit is contained in:
Kirill Kamakin
2021-11-27 12:27:25 +03:00
parent ebba1889c7
commit 339f8327de
6 changed files with 52 additions and 2 deletions

View File

@@ -85,9 +85,13 @@ class AuthenticationFragment : Fragment() {
is Unauthorized -> getString(R.string.fragment_authentication_credentials_incorrect)
else -> null
}
urlInputLayout.error = when (it.exceptionOrNull()) {
urlInputLayout.error = when (val exception = it.exceptionOrNull()) {
is NoServerConnection -> getString(R.string.fragment_authentication_no_connection)
is NotMealie -> getString(R.string.fragment_authentication_unexpected_response)
is MalformedUrl -> {
val cause = exception.cause?.message ?: exception.message
getString(R.string.fragment_authentication_url_invalid, cause)
}
is Unauthorized, null -> null
else -> getString(R.string.fragment_authentication_unknown_error)
}