Refactoring

This commit is contained in:
M66B 2020-09-17 17:04:00 +02:00
parent 6752793a6d
commit ab93c3351b
1 changed files with 14 additions and 13 deletions

View File

@ -205,8 +205,22 @@ public class FragmentBase extends Fragment {
public void onCreate(Bundle savedInstanceState) {
Log.i("Create " + this + " saved=" + (savedInstanceState != null));
super.onCreate(savedInstanceState);
if (savedInstanceState != null)
subtitle = savedInstanceState.getString("fair:subtitle");
// https://developer.android.com/training/basics/fragments/pass-data-between
getParentFragmentManager().setFragmentResultListener(getClass().getName(), this, new FragmentResultListener() {
@Override
public void onFragmentResult(@NonNull String requestKey, @NonNull Bundle result) {
int requestCode = result.getInt("requestCode");
int resultCode = result.getInt("resultCode");
Intent data = new Intent();
data.putExtra("args", result);
onActivityResult(requestCode, resultCode, data);
}
});
}
@Override
@ -219,19 +233,6 @@ public class FragmentBase extends Fragment {
public void onActivityCreated(Bundle savedInstanceState) {
Log.d("Activity " + this + " saved=" + (savedInstanceState != null));
super.onActivityCreated(savedInstanceState);
getParentFragmentManager().setFragmentResultListener(getClass().getName(), getViewLifecycleOwner(), new FragmentResultListener() {
@Override
public void onFragmentResult(@NonNull String requestKey, @NonNull Bundle result) {
int requestCode = result.getInt("requestCode");
int resultCode = result.getInt("resultCode");
Intent data = new Intent();
data.putExtra("args", result);
onActivityResult(requestCode, resultCode, data);
}
});
scrollTo();
}