FileDocCategorySizeDatePackage
ContactEntryAdapter.javaAPI DocAndroid 1.5 API11420Wed May 06 22:42:44 BST 2009com.android.contacts

ContactEntryAdapter

public abstract class ContactEntryAdapter extends android.widget.BaseAdapter

Fields Summary
public static final String[]
CONTACT_PROJECTION
public static final int
CONTACT_ID_COLUMN
public static final int
CONTACT_NAME_COLUMN
public static final int
CONTACT_NOTES_COLUMN
public static final int
CONTACT_PREFERRED_PHONE_COLUMN
public static final int
CONTACT_SERVER_STATUS_COLUMN
public static final int
CONTACT_STARRED_COLUMN
public static final int
CONTACT_CUSTOM_RINGTONE_COLUMN
public static final int
CONTACT_SEND_TO_VOICEMAIL_COLUMN
public static final int
CONTACT_PHONETIC_NAME_COLUMN
public static final String[]
PHONES_PROJECTION
public static final int
PHONES_ID_COLUMN
public static final int
PHONES_NUMBER_COLUMN
public static final int
PHONES_TYPE_COLUMN
public static final int
PHONES_LABEL_COLUMN
public static final int
PHONES_ISPRIMARY_COLUMN
public static final String[]
METHODS_PROJECTION
public static final String[]
METHODS_WITH_PRESENCE_PROJECTION
public static final int
METHODS_ID_COLUMN
public static final int
METHODS_KIND_COLUMN
public static final int
METHODS_DATA_COLUMN
public static final int
METHODS_TYPE_COLUMN
public static final int
METHODS_LABEL_COLUMN
public static final int
METHODS_ISPRIMARY_COLUMN
public static final int
METHODS_AUX_DATA_COLUMN
public static final int
METHODS_STATUS_COLUMN
public static final String[]
ORGANIZATIONS_PROJECTION
public static final int
ORGANIZATIONS_ID_COLUMN
public static final int
ORGANIZATIONS_TYPE_COLUMN
public static final int
ORGANIZATIONS_LABEL_COLUMN
public static final int
ORGANIZATIONS_COMPANY_COLUMN
public static final int
ORGANIZATIONS_TITLE_COLUMN
public static final int
ORGANIZATIONS_ISPRIMARY_COLUMN
protected ArrayList
mSections
protected android.view.LayoutInflater
mInflater
protected android.content.Context
mContext
protected boolean
mSeparators
Constructors Summary
ContactEntryAdapter(android.content.Context context, ArrayList sections, boolean separators)

        mContext = context;
        mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mSections = sections;
        mSeparators = separators;
    
Methods Summary
public final booleanareAllItemsEnabled()

see
android.widget.ListAdapter#hasSeparators()

        return mSeparators == false;
    
protected abstract voidbindView(android.view.View view, E entry)
Binds the data from an entry to a view.

param
view the view to display the entry in
param
entry the data to bind

public static intcountEntries(java.util.ArrayList sections, boolean separators)
Get the count of entries in all sections

param
sections the list of sections
return
the count of entries in all sections

        int count = 0;
        int numSections = sections.size();
        for (int i = 0; i < numSections; i++) {
            ArrayList<T> section = sections.get(i);
            int sectionSize = section.size();
            if (separators && sectionSize == 1) {
                // The section only contains a separator and nothing else, skip it
                continue;
            }
            count += sections.get(i).size();
        }
        return count;
    
public final intgetCount()

see
android.widget.ListAdapter#getCount()

        return countEntries(mSections, mSeparators);
    
public static final TgetEntry(java.util.ArrayList sections, int position, boolean separators)
Get the entry for the given position.

param
sections the list of sections
param
position the position for the desired entry
return
the ContactEntry for the given position

        int numSections = sections.size();
        for (int i = 0; i < numSections; i++) {
            ArrayList<T> section = sections.get(i);
            int sectionSize = section.size();
            if (separators && sectionSize == 1) {
                // The section only contains a separator and nothing else, skip it
                continue;
            }
            if (position < section.size()) {
                return section.get(position);
            }
            position -= section.size();
        }
        return null;
    
public final java.lang.ObjectgetItem(int position)

see
android.widget.ListAdapter#getItem(int)

        return getEntry(mSections, position, mSeparators);
    
public final longgetItemId(int position)

see
android.widget.ListAdapter#getItemId(int)

        Entry entry = getEntry(mSections, position, mSeparators);
        if (entry != null) {
            return entry.id;
        } else {
            return -1;
        }
    
public android.view.ViewgetView(int position, android.view.View convertView, android.view.ViewGroup parent)

see
android.widget.ListAdapter#getView(int, View, ViewGroup)

        View v;
        if (convertView == null) {
            v = newView(position, parent);
        } else {
            v = convertView;
        }
        bindView(v, getEntry(mSections, position, mSeparators));
        return v;
    
public final booleanisEnabled(int position)

see
android.widget.ListAdapter#isSeparator(int)

        if (!mSeparators) {
            return true;
        }

        int numSections = mSections.size();
        for (int i = 0; i < numSections; i++) {
            ArrayList<E> section = mSections.get(i);
            int sectionSize = section.size();
            if (sectionSize == 1) {
                // The section only contains a separator and nothing else, skip it
                continue;
            }
            if (position == 0) {
                // The first item in a section is always the separator
                return false;
            }
            position -= sectionSize;
        }
        return true;
    
protected abstract android.view.ViewnewView(int position, android.view.ViewGroup parent)
Create a new view for an entry.

parent
the parent ViewGroup
return
the newly created view

public final voidsetSections(java.util.ArrayList sections, boolean separators)
Resets the section data.

param
sections the section data

        mSections = sections;
        mSeparators = separators;
        notifyDataSetChanged();
    
public final intsetSections(java.util.ArrayList sections, E entry)
Resets the section data and returns the position of the given entry.

param
sections the section data
param
entry the entry to return the position for
return
the position of entry, or -1 if it isn't found

        mSections = sections;
        notifyDataSetChanged();

        int numSections = mSections.size();
        int position = 0;
        for (int i = 0; i < numSections; i++) {
            ArrayList<E> section = mSections.get(i);
            int sectionSize = section.size();
            for (int j = 0; j < sectionSize; j++) {
                E e = section.get(j);
                if (e.equals(entry)) {
                    position += j;
                    return position;
                }
            }
            position += sectionSize;
        }
        return -1;