]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java
remove obsolete comments
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / profiles / ProfileDetailFragment.java
index b66cc053a6b51823f4425df257050205b6845376..d7b740e7dfcef5b383fc423bea9deafa8f6b6c30 100644 (file)
@@ -18,9 +18,9 @@
 package net.ktnx.mobileledger.ui.profiles;
 
 import android.app.Activity;
-import android.content.Context;
 import android.os.Bundle;
 import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
 import android.support.design.widget.CollapsingToolbarLayout;
 import android.support.design.widget.FloatingActionButton;
 import android.support.v4.app.Fragment;
@@ -94,9 +94,6 @@ public class ProfileDetailFragment extends Fragment {
         super.onCreate(savedInstanceState);
 
         if ((getArguments() != null) && getArguments().containsKey(ARG_ITEM_ID)) {
-            // Load the dummy content specified by the fragment
-            // arguments. In a real-world scenario, use a Loader
-            // to load content from a content provider.
             int index = getArguments().getInt(ARG_ITEM_ID, -1);
             if (index != -1) mProfile = Data.profiles.get(index);
 
@@ -109,11 +106,13 @@ public class ProfileDetailFragment extends Fragment {
             }
         }
     }
-
     @Override
-    public void onAttach(Context context) {
-        super.onAttach(context);
-        fab = ((Activity) context).findViewById(R.id.fab);
+    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
+        super.onActivityCreated(savedInstanceState);
+        Activity context = getActivity();
+        if (context == null) return;
+
+        fab = context.findViewById(R.id.fab);
         fab.setOnClickListener(v -> {
             if (mProfile != null) {
                 mProfile.setName(profileName.getText());
@@ -158,6 +157,7 @@ public class ProfileDetailFragment extends Fragment {
         useAuthentication.setOnCheckedChangeListener((buttonView, isChecked) -> {
             Log.d("profiles", isChecked ? "auth enabled " : "auth disabled");
             authParams.setVisibility(isChecked ? View.VISIBLE : View.GONE);
+            if (isChecked) userName.requestFocus();
         });
 
         if (mProfile != null) {