]> git.ktnx.net Git - mobile-ledger.git/commitdiff
profile editor: streamlined handling of authentication switch
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Wed, 6 May 2020 07:45:48 +0000 (10:45 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Wed, 6 May 2020 07:45:48 +0000 (10:45 +0300)
focus moves only when responding to the UI, hook to the LiveData, not
to the UI element

app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java

index 61d0d519f4988c96d3bc649e7e06026eb8a8d82f..aba3b0f2c4f9b9829a996b8bfca9a988046f10f1 100644 (file)
@@ -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 -> {