1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-25 17:27:00 +00:00

Factor out bind seen

This commit is contained in:
M66B 2020-10-19 15:12:01 +02:00
parent 42999a270b
commit 5f95be3e9e

View file

@ -901,24 +901,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
// Text size // Text size
if (textSize != 0) { if (textSize != 0) {
float fz_sender = (font_size_sender == null ? textSize : font_size_sender) * (message.unseen > 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); tvKeywords.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize * 0.9f);
tvFolder.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); tvLabels.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize * 0.9f);
tvPreview.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 // Selected / disabled
@ -959,27 +945,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
tvError.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f); tvError.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
} }
// Unseen bindSeen(message);
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);
}
// Account color // Account color
int colorBackground = int colorBackground =
@ -1382,6 +1348,46 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
pbCalendarWait.setVisibility(View.GONE); pbCalendarWait.setVisibility(View.GONE);
} }
private void bindSeen(TupleMessageEx message) {
if (textSize != 0) {
float fz_sender = (font_size_sender == null ? textSize : font_size_sender) * (message.unseen > 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) { private void bindFlagged(TupleMessageEx message, boolean expanded) {
boolean pro = ActivityBilling.isPro(context); boolean pro = ActivityBilling.isPro(context);
boolean flagged = (message.count - message.unflagged) > 0; boolean flagged = (message.count - message.unflagged) > 0;
@ -3048,7 +3054,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} else { } else {
message.ui_seen = !message.ui_seen; message.ui_seen = !message.ui_seen;
message.unseen = (message.ui_seen ? 0 : message.count); message.unseen = (message.ui_seen ? 0 : message.count);
bindTo(message, false); bindSeen(message);
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong("id", message.id); args.putLong("id", message.id);