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;
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);
}
}
}
-
@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());
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) {