mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-23 18:02:15 -05:00
Make ContactItem immutable
This commit is contained in:
parent
a09f26a227
commit
56d4cca4dd
@ -25,12 +25,13 @@ public class EmailAddressList extends K9ListActivity implements OnItemClickListe
|
|||||||
return;
|
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 listView = getListView();
|
||||||
listView.setOnItemClickListener(this);
|
listView.setOnItemClickListener(this);
|
||||||
listView.setAdapter(adapter);
|
listView.setAdapter(adapter);
|
||||||
setTitle(contact.getDisplayName());
|
setTitle(contact.displayName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -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();
|
Toast.makeText(this, getString(R.string.error_contact_address_not_found), Toast.LENGTH_LONG).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (contact.getEmailAddresses().size() > 1) {
|
if (contact.emailAddresses.size() > 1) {
|
||||||
Intent i = new Intent(this, EmailAddressList.class);
|
Intent i = new Intent(this, EmailAddressList.class);
|
||||||
i.putExtra("contact", contact);
|
i.putExtra("contact", contact);
|
||||||
|
|
||||||
@ -1816,14 +1816,14 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (K9.DEBUG) {
|
if (K9.DEBUG) {
|
||||||
ArrayList<String> emails = contact.getEmailAddresses();
|
List<String> emails = contact.emailAddresses;
|
||||||
for (int i = 0; i < emails.size(); i++) {
|
for (int i = 0; i < emails.size(); i++) {
|
||||||
Log.v(K9.LOG_TAG, "email[" + i + "]: " + emails.get(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) {
|
if (requestCode == CONTACT_PICKER_TO) {
|
||||||
addAddress(mToView, new Address(email, ""));
|
addAddress(mToView, new Address(email, ""));
|
||||||
} else if (requestCode == CONTACT_PICKER_CC) {
|
} else if (requestCode == CONTACT_PICKER_CC) {
|
||||||
|
@ -1,24 +1,17 @@
|
|||||||
package com.fsck.k9.helper;
|
package com.fsck.k9.helper;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class ContactItem implements Serializable {
|
public class ContactItem implements Serializable {
|
||||||
private static final long serialVersionUID = 4893328130147843375L;
|
private static final long serialVersionUID = 4893328130147843375L;
|
||||||
|
|
||||||
private String displayName = null;
|
public final String displayName;
|
||||||
private ArrayList<String> emailAddresses = null;
|
public final List<String> emailAddresses;
|
||||||
|
|
||||||
public String getDisplayName() {
|
public ContactItem(String displayName, List<String> emailAddresses) {
|
||||||
return displayName;
|
|
||||||
}
|
|
||||||
public void setDisplayName(String displayName) {
|
|
||||||
this.displayName = displayName;
|
this.displayName = displayName;
|
||||||
}
|
this.emailAddresses = Collections.unmodifiableList(emailAddresses);
|
||||||
public ArrayList<String> getEmailAddresses() {
|
|
||||||
return emailAddresses;
|
|
||||||
}
|
|
||||||
public void setEmailAddresses(ArrayList<String> emailAddresses) {
|
|
||||||
this.emailAddresses = emailAddresses;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -229,10 +229,7 @@ public class ContactsSdk5 extends com.fsck.k9.helper.Contacts {
|
|||||||
displayName = email.get(0);
|
displayName = email.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ContactItem item = new ContactItem();
|
return new ContactItem(displayName, email);
|
||||||
item.setDisplayName(displayName);
|
|
||||||
item.setEmailAddresses(email);
|
|
||||||
return item;
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(K9.LOG_TAG, "Failed to get email data", e);
|
Log.e(K9.LOG_TAG, "Failed to get email data", e);
|
||||||
|
Loading…
Reference in New Issue
Block a user