avoid deprecated DialogFragment onActivityCreated

This commit is contained in:
Daniel Micay 2022-12-28 12:08:22 -05:00
parent b8dcc33696
commit fd510a3c19

View File

@ -22,23 +22,19 @@ public class JumpToPageFragment extends DialogFragment {
private NumberPicker mPicker; private NumberPicker mPicker;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (savedInstanceState != null) {
mPicker.setMinValue(savedInstanceState.getInt(STATE_PICKER_MIN));
mPicker.setMaxValue(savedInstanceState.getInt(STATE_PICKER_MAX));
mPicker.setValue(savedInstanceState.getInt(STATE_PICKER_CUR));
}
}
@NonNull @NonNull
@Override @Override
public Dialog onCreateDialog(Bundle savedInstanceState) { public Dialog onCreateDialog(Bundle savedInstanceState) {
mPicker = new NumberPicker(getActivity()); mPicker = new NumberPicker(getActivity());
mPicker.setMinValue(1); if (savedInstanceState != null) {
mPicker.setMaxValue(((PdfViewer)requireActivity()).mNumPages); mPicker.setMinValue(savedInstanceState.getInt(STATE_PICKER_MIN));
mPicker.setValue(((PdfViewer)requireActivity()).mPage); mPicker.setMaxValue(savedInstanceState.getInt(STATE_PICKER_MAX));
mPicker.setValue(savedInstanceState.getInt(STATE_PICKER_CUR));
} else {
mPicker.setMinValue(1);
mPicker.setMaxValue(((PdfViewer)requireActivity()).mNumPages);
mPicker.setValue(((PdfViewer)requireActivity()).mPage);
}
final FrameLayout layout = new FrameLayout(getActivity()); final FrameLayout layout = new FrameLayout(getActivity());
layout.addView(mPicker, new FrameLayout.LayoutParams( layout.addView(mPicker, new FrameLayout.LayoutParams(