From 455b04f18354cbf58fa3abe720275b921ffd76da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Borcz?= Date: Mon, 2 Sep 2019 10:05:42 +0200 Subject: [PATCH] Fix empty hosts list after activity recreating (#477) --- .../modules/login/form/LoginFormFragment.kt | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormFragment.kt index ce6db1ca..94259aa8 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormFragment.kt @@ -34,13 +34,11 @@ class LoginFormFragment : BaseFragment(), LoginFormView { fun newInstance() = LoginFormFragment() } - override val formNameValue: String - get() = loginFormName.text.toString() + override val formNameValue get() = loginFormName.text.toString() - override val formPassValue: String - get() = loginFormPass.text.toString() + override val formPassValue get() = loginFormPass.text.toString() - override val formHostValue: String? + override val formHostValue get() = hostValues.getOrNull(hostKeys.indexOf(loginFormHost.text.toString())) private lateinit var hostKeys: Array @@ -71,6 +69,9 @@ class LoginFormFragment : BaseFragment(), LoginFormView { } with(loginFormHost) { + //Bug with filter in ExposedDropdownMenu on restoring state + isSaveEnabled = false + setText(hostKeys.getOrElse(0) { "" }) setAdapter(ArrayAdapter(context, R.layout.support_simple_spinner_dropdown_item, hostKeys)) keyListener = null @@ -83,28 +84,28 @@ class LoginFormFragment : BaseFragment(), LoginFormView { } override fun setErrorNameRequired() { - loginFormNameLayout.run { + with(loginFormNameLayout) { requestFocus() error = getString(R.string.login_field_required) } } override fun setErrorPassRequired(focus: Boolean) { - loginFormPassLayout.run { + with(loginFormPassLayout) { if (focus) requestFocus() error = getString(R.string.login_field_required) } } override fun setErrorPassInvalid(focus: Boolean) { - loginFormPassLayout.run { + with(loginFormPassLayout) { if (focus) requestFocus() error = getString(R.string.login_invalid_password) } } override fun setErrorPassIncorrect() { - loginFormPassLayout.run { + with(loginFormPassLayout) { requestFocus() error = getString(R.string.login_incorrect_password) } @@ -136,7 +137,7 @@ class LoginFormFragment : BaseFragment(), LoginFormView { @SuppressLint("SetTextI18n") override fun showVersion() { - loginFormVersion.apply { + with(loginFormVersion) { visibility = VISIBLE text = "${getString(R.string.app_name)} ${appInfo.versionName}" } @@ -147,11 +148,12 @@ class LoginFormFragment : BaseFragment(), LoginFormView { } override fun notifyParentAccountLogged(students: List) { - (activity as? LoginActivity)?.onFormFragmentAccountLogged(students, Triple( - loginFormName.text.toString(), - loginFormPass.text.toString(), - resources.getStringArray(R.array.endpoints_values)[1] - )) + (activity as? LoginActivity)?.onFormFragmentAccountLogged(students, + Triple( + loginFormName.text.toString(), + loginFormPass.text.toString(), + resources.getStringArray(R.array.endpoints_values)[1] + )) } override fun openPrivacyPolicyPage() {