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

Make ContactItem immutable

This commit is contained in:
cketti 2012-04-09 01:14:51 +02:00
parent a09f26a227
commit 56d4cca4dd
4 changed files with 13 additions and 22 deletions

View File

@ -25,12 +25,13 @@ public class EmailAddressList extends K9ListActivity implements OnItemClickListe
return;
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.email_address_list_item, contact.getEmailAddresses());
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.email_address_list_item, contact.emailAddresses);
ListView listView = getListView();
listView.setOnItemClickListener(this);
listView.setAdapter(adapter);
setTitle(contact.getDisplayName());
setTitle(contact.displayName);
}
@Override

View File

@ -1802,7 +1802,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
Toast.makeText(this, getString(R.string.error_contact_address_not_found), Toast.LENGTH_LONG).show();
return;
}
if (contact.getEmailAddresses().size() > 1) {
if (contact.emailAddresses.size() > 1) {
Intent i = new Intent(this, EmailAddressList.class);
i.putExtra("contact", contact);
@ -1816,14 +1816,14 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
return;
}
if (K9.DEBUG) {
ArrayList<String> emails = contact.getEmailAddresses();
List<String> emails = contact.emailAddresses;
for (int i = 0; i < emails.size(); i++) {
Log.v(K9.LOG_TAG, "email[" + i + "]: " + emails.get(i));
}
}
String email = contact.getEmailAddresses().get(0);
String email = contact.emailAddresses.get(0);
if (requestCode == CONTACT_PICKER_TO) {
addAddress(mToView, new Address(email, ""));
} else if (requestCode == CONTACT_PICKER_CC) {

View File

@ -1,24 +1,17 @@
package com.fsck.k9.helper;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class ContactItem implements Serializable {
private static final long serialVersionUID = 4893328130147843375L;
private String displayName = null;
private ArrayList<String> emailAddresses = null;
public final String displayName;
public final List<String> emailAddresses;
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
public ContactItem(String displayName, List<String> emailAddresses) {
this.displayName = displayName;
}
public ArrayList<String> getEmailAddresses() {
return emailAddresses;
}
public void setEmailAddresses(ArrayList<String> emailAddresses) {
this.emailAddresses = emailAddresses;
this.emailAddresses = Collections.unmodifiableList(emailAddresses);
}
}

View File

@ -229,10 +229,7 @@ public class ContactsSdk5 extends com.fsck.k9.helper.Contacts {
displayName = email.get(0);
}
ContactItem item = new ContactItem();
item.setDisplayName(displayName);
item.setEmailAddresses(email);
return item;
return new ContactItem(displayName, email);
}
} catch (Exception e) {
Log.e(K9.LOG_TAG, "Failed to get email data", e);