From 5f95be3e9e6654ba79121f5b4c69dfabd72327f5 Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 19 Oct 2020 15:12:01 +0200 Subject: [PATCH] Factor out bind seen --- .../eu/faircode/email/AdapterMessage.java | 78 ++++++++++--------- 1 file changed, 42 insertions(+), 36 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index a94652366a..c1efb15807 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -901,24 +901,10 @@ public class AdapterMessage extends RecyclerView.Adapter 0 ? 1.1f : 1f); - float fz_subject = (font_size_subject == null ? textSize : font_size_subject) * 0.9f; - tvFrom.setTextSize(TypedValue.COMPLEX_UNIT_PX, fz_sender); - tvSubject.setTextSize(TypedValue.COMPLEX_UNIT_PX, fz_subject); tvKeywords.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize * 0.9f); tvFolder.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize * 0.9f); tvLabels.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize * 0.9f); tvPreview.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize * 0.9f); - - if (avatars) { - int px = Math.round(fz_sender + fz_subject + (compact ? 0 : textSize * 0.9f)); - ViewGroup.LayoutParams lparams = ibAvatar.getLayoutParams(); - if (lparams.width != px || lparams.height != px) { - lparams.width = px; - lparams.height = px; - ibAvatar.requestLayout(); - } - } } // Selected / disabled @@ -959,27 +945,7 @@ public class AdapterMessage extends RecyclerView.Adapter 0 ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT); - tvFrom.setTypeface(typeface); - tvSize.setTypeface(typeface); - tvTime.setTypeface(typeface); - if (subject_italic) - if (message.unseen > 0) - tvSubject.setTypeface(null, Typeface.BOLD_ITALIC); - else - tvSubject.setTypeface(null, Typeface.ITALIC); - else - tvSubject.setTypeface(typeface); - tvCount.setTypeface(typeface); - - int colorUnseen = (message.unseen > 0 ? colorUnread : colorRead); - if (!Objects.equals(tvFrom.getTag(), colorUnseen)) { - tvFrom.setTag(colorUnseen); - tvFrom.setTextColor(colorUnseen); - tvSize.setTextColor(colorUnseen); - tvTime.setTextColor(colorUnseen); - } + bindSeen(message); // Account color int colorBackground = @@ -1382,6 +1348,46 @@ public class AdapterMessage extends RecyclerView.Adapter 0 ? 1.1f : 1f); + float fz_subject = (font_size_subject == null ? textSize : font_size_subject) * 0.9f; + tvFrom.setTextSize(TypedValue.COMPLEX_UNIT_PX, fz_sender); + tvSubject.setTextSize(TypedValue.COMPLEX_UNIT_PX, fz_subject); + + if (avatars) { + int px = Math.round(fz_sender + fz_subject + (compact ? 0 : textSize * 0.9f)); + ViewGroup.LayoutParams lparams = ibAvatar.getLayoutParams(); + if (lparams.width != px || lparams.height != px) { + lparams.width = px; + lparams.height = px; + ibAvatar.requestLayout(); + } + } + } + + Typeface typeface = (message.unseen > 0 ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT); + tvFrom.setTypeface(typeface); + tvSize.setTypeface(typeface); + tvTime.setTypeface(typeface); + if (subject_italic) + if (message.unseen > 0) + tvSubject.setTypeface(null, Typeface.BOLD_ITALIC); + else + tvSubject.setTypeface(null, Typeface.ITALIC); + else + tvSubject.setTypeface(typeface); + tvCount.setTypeface(typeface); + + int colorUnseen = (message.unseen > 0 ? colorUnread : colorRead); + if (!Objects.equals(tvFrom.getTag(), colorUnseen)) { + tvFrom.setTag(colorUnseen); + tvFrom.setTextColor(colorUnseen); + tvSize.setTextColor(colorUnseen); + tvTime.setTextColor(colorUnseen); + } + } + private void bindFlagged(TupleMessageEx message, boolean expanded) { boolean pro = ActivityBilling.isPro(context); boolean flagged = (message.count - message.unflagged) > 0; @@ -3048,7 +3054,7 @@ public class AdapterMessage extends RecyclerView.Adapter