1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-26 01:28:50 -05:00

Don't embed helper instance inside a data transfer object (ideally, the populate() method should be moved outside that DTO to an external service/helper) as this might lead future development to introduce unwanted dependency graphs (= memory leaks)

This commit is contained in:
Fiouz 2010-10-02 09:07:14 +00:00
parent bb64a0ab01
commit 75984939d1

View File

@ -43,8 +43,6 @@ public class MessageInfoHolder
public String account; public String account;
public String uri; public String uri;
private Contacts mContacts;
// Empty constructor for comparison // Empty constructor for comparison
public MessageInfoHolder() public MessageInfoHolder()
{ {
@ -55,8 +53,6 @@ public class MessageInfoHolder
{ {
this(); this();
mContacts = Contacts.getInstance(context);
Account account = m.getFolder().getAccount(); Account account = m.getFolder().getAccount();
populate(context, m, new FolderInfoHolder(context, m.getFolder(), m.getFolder().getAccount()), account); populate(context, m, new FolderInfoHolder(context, m.getFolder(), m.getFolder().getAccount()), account);
} }
@ -65,13 +61,12 @@ public class MessageInfoHolder
{ {
this(); this();
mContacts = Contacts.getInstance(context);
populate(context, m, folder, account); populate(context, m, folder, account);
} }
public void populate(Context context, Message m, FolderInfoHolder folder, Account account) public void populate(Context context, Message m, FolderInfoHolder folder, Account account)
{ {
final Contacts contactHelper = Contacts.getInstance(context);
try try
{ {
LocalMessage message = (LocalMessage) m; LocalMessage message = (LocalMessage) m;
@ -105,13 +100,13 @@ public class MessageInfoHolder
if (addrs.length > 0 && account.isAnIdentity(addrs[0])) if (addrs.length > 0 && account.isAnIdentity(addrs[0]))
{ {
CharSequence to = Address.toFriendly(message .getRecipients(RecipientType.TO), mContacts); CharSequence to = Address.toFriendly(message .getRecipients(RecipientType.TO), contactHelper);
this.compareCounterparty = to.toString(); this.compareCounterparty = to.toString();
this.sender = new SpannableStringBuilder(context.getString(R.string.message_list_to_fmt)).append(to); this.sender = new SpannableStringBuilder(context.getString(R.string.message_list_to_fmt)).append(to);
} }
else else
{ {
this.sender = Address.toFriendly(addrs, mContacts); this.sender = Address.toFriendly(addrs, contactHelper);
this.compareCounterparty = this.sender.toString(); this.compareCounterparty = this.sender.toString();
} }