android: navController check null
This commit is contained in:
parent
5113d73b37
commit
1de1fdeb47
@ -85,9 +85,12 @@ public class DoricPanelFragment extends Fragment implements IDoricNavigator {
|
||||
argument.putString("source", source);
|
||||
argument.putString("alias", alias);
|
||||
argument.putString("extra", extra);
|
||||
NavController navController = getNavController();
|
||||
if (navController != null) {
|
||||
getNavController()
|
||||
.navigate(R.id.action_doricPanelFragment_to_doricPanelFragment, argument);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@ -95,14 +98,19 @@ public class DoricPanelFragment extends Fragment implements IDoricNavigator {
|
||||
if (getActivity() == null || getActivity().isFinishing()) {
|
||||
return;
|
||||
}
|
||||
if (!getNavController().popBackStack()) {
|
||||
NavController navController = getNavController();
|
||||
if (navController != null && navController.popBackStack()) {
|
||||
if (getActivity() != null) {
|
||||
getActivity().finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private NavController getNavController() {
|
||||
if (getView() == null) {
|
||||
return null;
|
||||
}
|
||||
return Navigation.findNavController(getView());
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user