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,11 +100,12 @@ public class CompileDialogFragment extends AppCompatDialogFragment {
if (result instanceof UnknownError) { if (result instanceof UnknownError) {
text = context.getString(R.string.compile_failed); text = context.getString(R.string.compile_failed);
} else { } else {
text = context.getString(R.string.compile_failed_with_info) + result.toString(); text = context.getString(R.string.compile_failed_with_info) + result;
} }
} else { } else {
text = context.getString(R.string.compile_done); text = context.getString(R.string.compile_done);
} }
try {
CompileDialogFragment fragment = outerRef.get(); CompileDialogFragment fragment = outerRef.get();
if (fragment != null) { if (fragment != null) {
fragment.dismissAllowingStateLoss(); fragment.dismissAllowingStateLoss();
@ -113,6 +114,8 @@ public class CompileDialogFragment extends AppCompatDialogFragment {
((BaseFragment) parent).showHint(text, true); ((BaseFragment) parent).showHint(text, true);
} }
} }
} catch (IllegalStateException ignored) {
}
} }
} }
} }