Delay formatting of dates in messagelist until we actually need them
-- it turns out they're very expensive.
This commit is contained in:
parent
4e53ee12b6
commit
28c9dfdcce
3 changed files with 18 additions and 10 deletions
|
@ -1,4 +1,5 @@
|
||||||
package com.fsck.k9.activity;
|
package com.fsck.k9.activity;
|
||||||
|
import com.fsck.k9.helper.MessageHelper;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import com.fsck.k9.mail.Message;
|
import com.fsck.k9.mail.Message;
|
||||||
|
@ -51,4 +52,10 @@ public class MessageInfoHolder
|
||||||
return uid.hashCode();
|
return uid.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDate(MessageHelper messageHelper) {
|
||||||
|
if (date == null) {
|
||||||
|
date = messageHelper.formatDate(message.getSentDate());
|
||||||
|
}
|
||||||
|
return date;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2718,7 +2718,7 @@ public class MessageList
|
||||||
holder.from.setTypeface(null, message.read ? Typeface.NORMAL : Typeface.BOLD);
|
holder.from.setTypeface(null, message.read ? Typeface.NORMAL : Typeface.BOLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.date.setText(message.date);
|
holder.date.setText(message.getDate(mMessageHelper));
|
||||||
holder.subject.setCompoundDrawablesWithIntrinsicBounds(
|
holder.subject.setCompoundDrawablesWithIntrinsicBounds(
|
||||||
message.answered ? mAnsweredIcon : null, // left
|
message.answered ? mAnsweredIcon : null, // left
|
||||||
null, // top
|
null, // top
|
||||||
|
|
|
@ -66,15 +66,6 @@ public class MessageHelper
|
||||||
|
|
||||||
target.folder = folder;
|
target.folder = folder;
|
||||||
|
|
||||||
if (Utility.isDateToday(date))
|
|
||||||
{
|
|
||||||
target.date = mTodayDateFormat.format(date);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
target.date = mDateFormat.format(date);
|
|
||||||
}
|
|
||||||
|
|
||||||
target.hasAttachments = message.getAttachmentCount() > 0;
|
target.hasAttachments = message.getAttachmentCount() > 0;
|
||||||
|
|
||||||
target.read = message.isSet(Flag.SEEN);
|
target.read = message.isSet(Flag.SEEN);
|
||||||
|
@ -122,4 +113,14 @@ public class MessageHelper
|
||||||
Log.w(K9.LOG_TAG, "Unable to load message info", me);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue