From 8ee42b51c43efbd0ff6fa0fec257132d4421f53d Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Wed, 6 May 2020 10:45:48 +0300 Subject: [PATCH] profile editor: streamlined handling of authentication switch focus moves only when responding to the UI, hook to the LiveData, not to the UI element --- .../mobileledger/ui/profiles/ProfileDetailFragment.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java b/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java index 61d0d519..aba3b0f2 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java @@ -321,12 +321,14 @@ public class ProfileDetailFragment extends Fragment { useAuthentication = context.findViewById(R.id.enable_http_auth); useAuthentication.setOnCheckedChangeListener((buttonView, isChecked) -> { model.setUseAuthentication(isChecked); - authParams.setVisibility(isChecked ? View.VISIBLE : View.GONE); if (isChecked) userName.requestFocus(); + }); + model.observeUseAuthentication(viewLifecycleOwner, isChecked -> { + useAuthentication.setChecked(isChecked); + authParams.setVisibility(isChecked ? View.VISIBLE : View.GONE); checkInsecureSchemeWithAuth(); }); - model.observeUseAuthentication(viewLifecycleOwner, useAuthentication::setChecked); userName = context.findViewById(R.id.auth_user_name); model.observeUserName(viewLifecycleOwner, text -> { -- 2.39.2