Cache the read and unread color chip variants per account.

This commit is contained in:
Jesse Vincent 2012-09-10 11:11:40 -04:00
parent 86c9aab7a8
commit 8daea241af
1 changed files with 16 additions and 1 deletions

View File

@ -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() {