Fix IllegalStateException (#1585)

Fragment may have detached and does not have parent fragment manager
This commit is contained in:
LoveSy 2022-01-30 12:57:57 +08:00 committed by GitHub
parent b4eed403e4
commit 8e6fba6852
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 7 deletions

View File

@ -100,18 +100,21 @@ public class CompileDialogFragment extends AppCompatDialogFragment {
if (result instanceof UnknownError) {
text = context.getString(R.string.compile_failed);
} else {
text = context.getString(R.string.compile_failed_with_info) + result.toString();
text = context.getString(R.string.compile_failed_with_info) + result;
}
} else {
text = context.getString(R.string.compile_done);
}
CompileDialogFragment fragment = outerRef.get();
if (fragment != null) {
fragment.dismissAllowingStateLoss();
var parent = fragment.getParentFragment();
if (parent instanceof BaseFragment) {
((BaseFragment) parent).showHint(text, true);
try {
CompileDialogFragment fragment = outerRef.get();
if (fragment != null) {
fragment.dismissAllowingStateLoss();
var parent = fragment.getParentFragment();
if (parent instanceof BaseFragment) {
((BaseFragment) parent).showHint(text, true);
}
}
} catch (IllegalStateException ignored) {
}
}
}