Replace deprecated usages of getActivity with requireActivity, replace onClick with lambda, and use NonNull
Signed-off-by: June <june@eridan.me>
This commit is contained in:
parent
61247aaa6a
commit
5984291b44
@ -1,12 +1,12 @@
|
|||||||
package org.grapheneos.pdfviewer.fragment;
|
package org.grapheneos.pdfviewer.fragment;
|
||||||
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.NumberPicker;
|
import android.widget.NumberPicker;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.fragment.app.DialogFragment;
|
import androidx.fragment.app.DialogFragment;
|
||||||
|
|
||||||
@ -31,12 +31,13 @@ public class JumpToPageFragment extends DialogFragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
mPicker = new NumberPicker(getActivity());
|
mPicker = new NumberPicker(getActivity());
|
||||||
mPicker.setMinValue(1);
|
mPicker.setMinValue(1);
|
||||||
mPicker.setMaxValue(((PdfViewer)getActivity()).mNumPages);
|
mPicker.setMaxValue(((PdfViewer)requireActivity()).mNumPages);
|
||||||
mPicker.setValue(((PdfViewer)getActivity()).mPage);
|
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(
|
||||||
@ -44,14 +45,11 @@ public class JumpToPageFragment extends DialogFragment {
|
|||||||
FrameLayout.LayoutParams.WRAP_CONTENT,
|
FrameLayout.LayoutParams.WRAP_CONTENT,
|
||||||
Gravity.CENTER));
|
Gravity.CENTER));
|
||||||
|
|
||||||
return new AlertDialog.Builder(getActivity())
|
return new AlertDialog.Builder(requireActivity())
|
||||||
.setView(layout)
|
.setView(layout)
|
||||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
.setPositiveButton(android.R.string.ok, (dialogInterface, i) -> {
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
|
||||||
mPicker.clearFocus();
|
mPicker.clearFocus();
|
||||||
((PdfViewer)getActivity()).onJumpToPageInDocument(mPicker.getValue());
|
((PdfViewer)requireActivity()).onJumpToPageInDocument(mPicker.getValue());
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
.create();
|
.create();
|
||||||
|
Loading…
Reference in New Issue
Block a user