1
0
mirror of https://codeberg.org/gitnex/GitNex synced 2024-12-23 00:48:57 +01:00

Fix crash if wiki page has no title (#1210)

Close https://codeberg.org/gitnex/GitNex/issues/1204

The issue is not an empty wiki, but an empty title. Don't know *how* this can happen, but it *can* happen (I have one example in my local gitea).

Co-authored-by: qwerty287 <ndev@web.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1210
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org>
Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
This commit is contained in:
qwerty287 2022-09-18 23:28:53 +02:00 committed by 6543
parent 6e3877580e
commit 385147f235

View File

@ -220,10 +220,14 @@ public class WikiListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
ColorGenerator generator = ColorGenerator.Companion.getMATERIAL();
int color = generator.getColor(wikiPageMetaData.getTitle());
String firstCharacter = String.valueOf(wikiPageMetaData.getTitle().charAt(0));
if (wikiPageMetaData.getTitle() != null && wikiPageMetaData.getTitle().length() > 0) {
String firstCharacter = String.valueOf(wikiPageMetaData.getTitle().charAt(0));
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28).endConfig().buildRoundRect(firstCharacter, color, 14);
avatar.setImageDrawable(drawable);
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28).endConfig().buildRoundRect(firstCharacter, color, 14);
avatar.setImageDrawable(drawable);
} else {
avatar.setVisibility(View.GONE);
}
if(!((RepoDetailActivity) ctx).repository.getPermissions().isPush()) {
wikiMenu.setVisibility(View.GONE);