X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2Fprofiles%2FProfileDetailFragment.java;h=d7b740e7dfcef5b383fc423bea9deafa8f6b6c30;hp=b66cc053a6b51823f4425df257050205b6845376;hb=2b3bbc5edeefec1d1baf85ae430cf36e78da70ed;hpb=e809f9bacb61890374d1b9c8c46edeaed8a838b0 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 b66cc053..d7b740e7 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 @@ -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) {