Delay formatting of dates in messagelist until we actually need them

-- it turns out they're very expensive.
This commit is contained in:
Jesse Vincent 2010-10-13 10:53:08 +00:00
parent 4e53ee12b6
commit 28c9dfdcce
3 changed files with 18 additions and 10 deletions

View File

@ -1,4 +1,5 @@
package com.fsck.k9.activity;
import com.fsck.k9.helper.MessageHelper;
import java.util.Date;
import com.fsck.k9.mail.Message;
@ -51,4 +52,10 @@ public class MessageInfoHolder
return uid.hashCode();
}
public String getDate(MessageHelper messageHelper) {
if (date == null) {
date = messageHelper.formatDate(message.getSentDate());
}
return date;
}
}

View File

@ -2718,7 +2718,7 @@ public class MessageList
holder.from.setTypeface(null, message.read ? Typeface.NORMAL : Typeface.BOLD);
}
holder.date.setText(message.date);
holder.date.setText(message.getDate(mMessageHelper));
holder.subject.setCompoundDrawablesWithIntrinsicBounds(
message.answered ? mAnsweredIcon : null, // left
null, // top

View File

@ -66,15 +66,6 @@ public class MessageHelper
target.folder = folder;
if (Utility.isDateToday(date))
{
target.date = mTodayDateFormat.format(date);
}
else
{
target.date = mDateFormat.format(date);
}
target.hasAttachments = message.getAttachmentCount() > 0;
target.read = message.isSet(Flag.SEEN);
@ -122,4 +113,14 @@ public class MessageHelper
Log.w(K9.LOG_TAG, "Unable to load message info", me);
}
}
public String formatDate(Date date) {
if (Utility.isDateToday(date))
{
return mTodayDateFormat.format(date);
}
else
{
return mDateFormat.format(date);
}
}
}