Avoid NPE when rendering empty markdown (#2626)

This commit is contained in:
LoveSy 2023-07-15 01:17:21 +08:00 committed by GitHub
parent bc381f4bb5
commit b178215f2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -153,7 +153,7 @@ public class RepoItemFragment extends BaseFragment implements RepoLoader.RepoLis
}
}
private void renderGithubMarkdown(WebView view, String text) {
private void renderGithubMarkdown(WebView view, @Nullable String text) {
try {
view.setBackgroundColor(Color.TRANSPARENT);
var setting = view.getSettings();
@ -173,6 +173,9 @@ public class RepoItemFragment extends BaseFragment implements RepoLoader.RepoLis
} else {
direction = "ltr";
}
if (text == null) {
text = "<center>" + App.getInstance().getString(R.string.list_empty) + "</center>";
}
if (ResourceUtils.isNightMode(getResources().getConfiguration())) {
body = App.HTML_TEMPLATE_DARK.get().replace("@dir@", direction).replace("@body@", text);
} else {