FileDocCategorySizeDatePackage
ContactListFilterView.javaAPI DocAndroid 1.5 API4446Wed May 06 22:42:46 BST 2009com.android.im.app

ContactListFilterView

public class ContactListFilterView extends android.widget.LinearLayout

Fields Summary
private android.widget.ListView
mContactListView
private android.widget.Filter
mFilter
private ContactAdapter
mContactAdapter
private android.net.Uri
mUri
Constructors Summary
public ContactListFilterView(android.content.Context context, android.util.AttributeSet attrs)

        super(context, attrs);
    
Methods Summary
public voiddoFilter(android.net.Uri uri, java.lang.String filterString)

        if (!uri.equals(mUri)) {
            mUri = uri;

            Cursor contactCursor = runQuery(filterString);

            if (mContactAdapter == null) {
                mContactAdapter = new ContactAdapter(mContext, contactCursor);
                mFilter = mContactAdapter.getFilter();
                mContactListView.setAdapter(mContactAdapter);
            } else {
                mContactAdapter.changeCursor(contactCursor);
            }
        } else {
            mFilter.filter(filterString);
        }
    
public android.database.CursorgetContactAtPosition(int position)

        return (Cursor) mContactAdapter.getItem(position);
    
public android.widget.ListViewgetListView()

        return mContactListView;
    
protected voidonFinishInflate()


        mContactListView = (ListView) findViewById(R.id.filteredList);
        mContactListView.setTextFilterEnabled(true);

        mContactListView.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView parent, View view, int position,
                    long id) {
                if (mContext instanceof ContactListActivity) {
                    ContactListActivity list = (ContactListActivity) mContext;
                    mContactListView.setSelection(position);
                    Cursor c = (Cursor) mContactListView.getSelectedItem();
                    list.mContactListView.startChat(c);
                    list.showContactListView();
                }
            }
        });
    
android.database.CursorrunQuery(java.lang.CharSequence constraint)

        StringBuilder buf = new StringBuilder();

        // exclude chatting contact
        buf.append(Im.Chats.LAST_MESSAGE_DATE);
        buf.append(" IS NULL");

        if (constraint != null) {
            buf.append(" AND ");
            buf.append(Im.Contacts.NICKNAME);
            buf.append(" LIKE ");
            DatabaseUtils.appendValueToSql(buf, "%" + constraint + "%");
        }

        return mContext.getContentResolver().query(mUri, ContactView.CONTACT_PROJECTION,
                buf == null ? null : buf.toString(), null, Im.Contacts.DEFAULT_SORT_ORDER);