From 20f0aa63a7e0d53910691a427471d8109bb92dd6 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 17 Feb 2021 18:16:12 +0100 Subject: [PATCH] Optimization --- .../eu/faircode/email/AdapterMessage.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index ecfe0a35c1..b148b1576e 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -511,12 +511,6 @@ public class AdapterMessage extends RecyclerView.Adapter 0 + boolean shadow = (message.unseen > 0); + int color = (shadow ? ColorUtils.setAlphaComponent(colorAccent, 127) : Color.TRANSPARENT); - if (!Objects.equals(itemView.getTag(), color)) { - itemView.setTag(color); + if (!Objects.equals(itemView.getTag(), shadow)) { + itemView.setTag(shadow); + itemView.setBackgroundColor(color); + + ViewGroup.MarginLayoutParams lparam = (ViewGroup.MarginLayoutParams) itemView.getLayoutParams(); + lparam.topMargin = (shadow ? dp1 : 0); + lparam.bottomMargin = (shadow ? dp1 : 0); + itemView.setLayoutParams(lparam); } }