From c47e6a774196c6d54e51756e7c81a8db56d9fdc9 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 3 Jun 2022 15:18:01 +0200 Subject: [PATCH] Fix issue #125 - Display name can be empty --- .../fedilab/android/ui/drawer/StatusAdapter.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java index 4f2b11285..22f017b4d 100644 --- a/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java @@ -38,6 +38,7 @@ import android.os.CountDownTimer; import android.os.Handler; import android.os.Looper; import android.text.Html; +import android.text.Spannable; import android.text.SpannableString; import android.text.Spanned; import android.text.TextUtils; @@ -715,7 +716,11 @@ public class StatusAdapter extends RecyclerView.Adapter //--- ACCOUNT INFO --- MastodonHelper.loadPPMastodon(holder.binding.avatar, statusToDeal.account); - holder.binding.displayName.setText(statusToDeal.account.span_display_name, TextView.BufferType.SPANNABLE); + Spannable span_display_name = statusToDeal.account.span_display_name; + if (span_display_name == null || span_display_name.toString().trim().length() == 0) { + span_display_name = new SpannableString(statusToDeal.account.username); + } + holder.binding.displayName.setText(span_display_name, TextView.BufferType.SPANNABLE); if (theme_text_header_1_line != -1) { holder.binding.displayName.setTextColor(theme_text_header_1_line); } @@ -784,7 +789,11 @@ public class StatusAdapter extends RecyclerView.Adapter //--- BOOSTER INFO --- if (status.reblog != null) { MastodonHelper.loadPPMastodon(holder.binding.statusBoosterAvatar, status.account); - holder.binding.statusBoosterDisplayName.setText(status.account.span_display_name, TextView.BufferType.SPANNABLE); + Spannable span_display_name_boost = status.account.span_display_name; + if (span_display_name_boost == null || span_display_name_boost.toString().trim().length() == 0) { + span_display_name_boost = new SpannableString(status.account.username);²& + } + holder.binding.statusBoosterDisplayName.setText(span_display_name_boost, TextView.BufferType.SPANNABLE); holder.binding.statusBoosterInfo.setVisibility(View.VISIBLE); holder.binding.boosterDivider.setVisibility(View.VISIBLE); if (theme_text_header_1_line != -1) {