From 385147f2350f144f9ddd5f44fa5330f4fdd55fc1 Mon Sep 17 00:00:00 2001 From: qwerty287 Date: Sun, 18 Sep 2022 23:28:53 +0200 Subject: [PATCH] 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 Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1210 Reviewed-by: 6543 <6543@obermui.de> Co-authored-by: qwerty287 Co-committed-by: qwerty287 --- .../java/org/mian/gitnex/adapters/WikiListAdapter.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/mian/gitnex/adapters/WikiListAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/WikiListAdapter.java index 6a128bff..758ded81 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/WikiListAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/WikiListAdapter.java @@ -220,10 +220,14 @@ public class WikiListAdapter extends RecyclerView.Adapter 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);