FileDocCategorySizeDatePackage
RecipientEntry.javaAPI DocAndroid 5.1 API10100Thu Mar 12 22:22:50 GMT 2015com.android.ex.chips

RecipientEntry

public class RecipientEntry extends Object
Represents one entry inside recipient auto-complete list.

Fields Summary
static final int
INVALID_CONTACT
static final int
GENERATED_CONTACT
A GENERATED_CONTACT is one that was created based entirely on information passed in to the RecipientEntry from an external source that is not a real contact.
public static final int
INVALID_DESTINATION_TYPE
Used when {@link #mDestinationType} is invalid and thus shouldn't be used for display.
public static final int
ENTRY_TYPE_PERSON
public static final int
ENTRY_TYPE_SIZE
private final int
mEntryType
private boolean
mIsFirstLevel
True when this entry is the first entry in a group, which should have a photo and display name, while the second or later entries won't.
private final String
mDisplayName
private final String
mDestination
Destination for this contact entry. Would be an email address or a phone number.
private final int
mDestinationType
Type of the destination like {@link Email#TYPE_HOME}
private final String
mDestinationLabel
Label of the destination which will be used when type was {@link Email#TYPE_CUSTOM}. Can be null when {@link #mDestinationType} is {@link #INVALID_DESTINATION_TYPE}.
private final long
mContactId
ID for the person
private final Long
mDirectoryId
ID for the directory this contact came from, or null
private final long
mDataId
ID for the destination
private final boolean
mIsDivider
private final android.net.Uri
mPhotoThumbnailUri
private boolean
mIsValid
private byte[]
mPhotoBytes
This can be updated after this object being constructed, when the photo is fetched from remote directories.
private final String
mLookupKey
See {@link android.provider.ContactsContract.ContactsColumns#LOOKUP_KEY}
Constructors Summary
protected RecipientEntry(int entryType, String displayName, String destination, int destinationType, String destinationLabel, long contactId, Long directoryId, long dataId, android.net.Uri photoThumbnailUri, boolean isFirstLevel, boolean isValid, String lookupKey)


          
                   
                   
              
        mEntryType = entryType;
        mIsFirstLevel = isFirstLevel;
        mDisplayName = displayName;
        mDestination = destination;
        mDestinationType = destinationType;
        mDestinationLabel = destinationLabel;
        mContactId = contactId;
        mDirectoryId = directoryId;
        mDataId = dataId;
        mPhotoThumbnailUri = photoThumbnailUri;
        mPhotoBytes = null;
        mIsDivider = false;
        mIsValid = isValid;
        mLookupKey = lookupKey;
    
Methods Summary
public static com.android.ex.chips.RecipientEntryconstructFakeEntry(java.lang.String address, boolean isValid)
Construct a RecipientEntry from just an address that has been entered. This address has not been resolved to a contact and therefore does not have a contact id or photo.

        final Rfc822Token[] tokens = Rfc822Tokenizer.tokenize(address);
        final String tokenizedAddress = tokens.length > 0 ? tokens[0].getAddress() : address;

        return new RecipientEntry(ENTRY_TYPE_PERSON, tokenizedAddress, tokenizedAddress,
                INVALID_DESTINATION_TYPE, null, INVALID_CONTACT, null /* directoryId */,
                INVALID_CONTACT, null, true, isValid, null /* lookupKey */);
    
public static com.android.ex.chips.RecipientEntryconstructFakePhoneEntry(java.lang.String phoneNumber, boolean isValid)
Construct a RecipientEntry from just a phone number.

        return new RecipientEntry(ENTRY_TYPE_PERSON, phoneNumber, phoneNumber,
                INVALID_DESTINATION_TYPE, null, INVALID_CONTACT, null /* directoryId */,
                INVALID_CONTACT, null, true, isValid, null /* lookupKey */);
    
public static com.android.ex.chips.RecipientEntryconstructGeneratedEntry(java.lang.String display, java.lang.String address, boolean isValid)
Construct a RecipientEntry from just an address that has been entered with both an associated display name. This address has not been resolved to a contact and therefore does not have a contact id or photo.

        return new RecipientEntry(ENTRY_TYPE_PERSON, display, address, INVALID_DESTINATION_TYPE,
                null, GENERATED_CONTACT, null /* directoryId */, GENERATED_CONTACT, null, true,
                isValid, null /* lookupKey */);
    
public static com.android.ex.chips.RecipientEntryconstructSecondLevelEntry(java.lang.String displayName, int displayNameSource, java.lang.String destination, int destinationType, java.lang.String destinationLabel, long contactId, java.lang.Long directoryId, long dataId, java.lang.String thumbnailUriAsString, boolean isValid, java.lang.String lookupKey)

        return new RecipientEntry(ENTRY_TYPE_PERSON, pickDisplayName(displayNameSource,
                displayName, destination), destination, destinationType, destinationLabel,
                contactId, directoryId, dataId, (thumbnailUriAsString != null
                ? Uri.parse(thumbnailUriAsString) : null), false, isValid, lookupKey);
    
public static com.android.ex.chips.RecipientEntryconstructTopLevelEntry(java.lang.String displayName, int displayNameSource, java.lang.String destination, int destinationType, java.lang.String destinationLabel, long contactId, java.lang.Long directoryId, long dataId, android.net.Uri photoThumbnailUri, boolean isValid, java.lang.String lookupKey)

        return new RecipientEntry(ENTRY_TYPE_PERSON, pickDisplayName(displayNameSource,
                displayName, destination), destination, destinationType, destinationLabel,
                contactId, directoryId, dataId, photoThumbnailUri, true, isValid, lookupKey);
    
public static com.android.ex.chips.RecipientEntryconstructTopLevelEntry(java.lang.String displayName, int displayNameSource, java.lang.String destination, int destinationType, java.lang.String destinationLabel, long contactId, java.lang.Long directoryId, long dataId, java.lang.String thumbnailUriAsString, boolean isValid, java.lang.String lookupKey)

        return new RecipientEntry(ENTRY_TYPE_PERSON, pickDisplayName(displayNameSource,
                displayName, destination), destination, destinationType, destinationLabel,
                contactId, directoryId, dataId, (thumbnailUriAsString != null
                ? Uri.parse(thumbnailUriAsString) : null), true, isValid, lookupKey);
    
public longgetContactId()

        return mContactId;
    
public longgetDataId()

        return mDataId;
    
public java.lang.StringgetDestination()

        return mDestination;
    
public java.lang.StringgetDestinationLabel()

        return mDestinationLabel;
    
public intgetDestinationType()

        return mDestinationType;
    
public java.lang.LonggetDirectoryId()

        return mDirectoryId;
    
public java.lang.StringgetDisplayName()

        return mDisplayName;
    
public intgetEntryType()

        return mEntryType;
    
public java.lang.StringgetLookupKey()

        return mLookupKey;
    
public synchronized byte[]getPhotoBytes()
This can be called outside main Looper thread.

        return mPhotoBytes;
    
public android.net.UrigetPhotoThumbnailUri()

        return mPhotoThumbnailUri;
    
public static booleanisCreatedRecipient(long id)
Determine if this was a RecipientEntry created from recipient info or an entry from contacts.

        return id == RecipientEntry.INVALID_CONTACT || id == RecipientEntry.GENERATED_CONTACT;
    
public booleanisFirstLevel()

        return mIsFirstLevel;
    
public booleanisSamePerson(com.android.ex.chips.RecipientEntry entry)
Returns if entry represents the same person as this instance. The default implementation checks whether the contact ids are the same, and subclasses may opt to override this.

        return entry != null && mContactId == entry.mContactId;
    
public booleanisSelectable()

        return mEntryType == ENTRY_TYPE_PERSON;
    
public booleanisSeparator()

        return mIsDivider;
    
public booleanisValid()

        return mIsValid;
    
private static java.lang.StringpickDisplayName(int displayNameSource, java.lang.String displayName, java.lang.String destination)

return
the display name for the entry. If the display name source is larger than {@link DisplayNameSources#PHONE} we use the contact's display name, but if not, i.e. the display name came from an email address or a phone number, we don't use it to avoid confusion and just use the destination instead.

        return (displayNameSource > DisplayNameSources.PHONE) ? displayName : destination;
    
public synchronized voidsetPhotoBytes(byte[] photoBytes)
This can be called outside main Looper thread.

        mPhotoBytes = photoBytes;
    
public java.lang.StringtoString()

        return mDisplayName + " <" + mDestination + ">, isValid=" + mIsValid;