From 8daea241afecbec87c3f6229572ab6c54156b9b2 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Mon, 10 Sep 2012 11:11:40 -0400 Subject: [PATCH] Cache the read and unread color chip variants per account. --- src/com/fsck/k9/Account.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/com/fsck/k9/Account.java b/src/com/fsck/k9/Account.java index cb67c1c42..88c142ccf 100644 --- a/src/com/fsck/k9/Account.java +++ b/src/com/fsck/k9/Account.java @@ -190,6 +190,9 @@ public class Account implements BaseAccount { private CryptoProvider mCryptoProvider = null; + private ColorChip mUnreadColorChip; + private ColorChip mReadColorChip; + /** * Indicates whether this account is enabled, i.e. ready for use, or not. * @@ -749,6 +752,8 @@ public class Account implements BaseAccount { public synchronized void setChipColor(int color) { mChipColor = color; + mUnreadColorChip = null; + mReadColorChip = null; } public synchronized int getChipColor() { @@ -757,7 +762,17 @@ public class Account implements BaseAccount { public ColorChip generateColorChip(boolean messageRead) { - return new ColorChip(mChipColor, messageRead); + if (messageRead) { + if (mReadColorChip == null) { + mReadColorChip = new ColorChip(mChipColor, true); + } + return mReadColorChip; + } else { + if (mUnreadColorChip == null) { + mUnreadColorChip = new ColorChip(mChipColor, false); + } + return mUnreadColorChip; + } } public ColorChip generateColorChip() {