Refactoring

This commit is contained in:
M66B 2021-11-12 20:04:26 +01:00
parent dd40f0634f
commit 19289192e5
1 changed files with 8 additions and 5 deletions

View File

@ -1256,8 +1256,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
tvSubject.invalidate();
if (keywords_header) {
SpannableStringBuilder keywords = getKeywords(message);
tvKeywords.setVisibility(keywords.length() > 0 ? View.VISIBLE : View.GONE);
Spanned keywords = getKeywords(message);
tvKeywords.setVisibility(keywords == null ? View.GONE : View.VISIBLE);
tvKeywords.setText(keywords);
} else
tvKeywords.setVisibility(View.GONE);
@ -2211,8 +2211,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
tvKeywordsEx.setVisibility(show_addresses && message.keywords.length > 0 ? View.VISIBLE : View.GONE);
tvKeywordsEx.setText(TextUtils.join(" ", message.keywords));
} else {
SpannableStringBuilder keywords = getKeywords(message);
tvKeywordsEx.setVisibility(show_addresses && keywords.length() > 0 ? View.VISIBLE : View.GONE);
Spanned keywords = getKeywords(message);
tvKeywordsEx.setVisibility(!show_addresses || keywords == null ? View.GONE : View.VISIBLE);
tvKeywordsEx.setText(keywords);
}
}
@ -5657,7 +5657,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
return ssb;
}
private SpannableStringBuilder getKeywords(TupleMessageEx message) {
private Spanned getKeywords(TupleMessageEx message) {
if (message.keywords == null || message.keywords.length == 0)
return null;
SpannableStringBuilder ssb = new SpannableStringBuilderEx();
if (message.keyword_titles == null || message.keyword_colors == null) {