FileDocCategorySizeDatePackage
ADNList.javaAPI DocAndroid 1.5 API6635Wed May 06 22:42:46 BST 2009com.android.phone

ADNList

public class ADNList extends android.app.ListActivity
ADN List activity for the Phone app.

Fields Summary
protected static final String
TAG
protected static final boolean
DBG
private static final String[]
COLUMN_NAMES
protected static final int
NAME_COLUMN
protected static final int
NUMBER_COLUMN
private static final int[]
VIEW_NAMES
protected static final int
QUERY_TOKEN
protected static final int
INSERT_TOKEN
protected static final int
UPDATE_TOKEN
protected static final int
DELETE_TOKEN
protected QueryHandler
mQueryHandler
protected android.widget.CursorAdapter
mCursorAdapter
protected android.database.Cursor
mCursor
private android.widget.TextView
mEmptyText
protected int
mInitialSelection
Constructors Summary
Methods Summary
private voiddisplayProgress(boolean flag)

        if (DBG) log("displayProgress: " + flag);
        mEmptyText.setText(flag ? R.string.simContacts_emptyLoading: R.string.simContacts_empty);
        getWindow().setFeatureInt(
                Window.FEATURE_INDETERMINATE_PROGRESS,
                flag ? PROGRESS_VISIBILITY_ON : PROGRESS_VISIBILITY_OFF);
    
protected voidlog(java.lang.String msg)

        Log.d(TAG, "[ADNList] " + msg);
    
protected android.widget.CursorAdapternewAdapter()

        return new SimpleCursorAdapter(this,
                    android.R.layout.simple_list_item_2,
                    mCursor, COLUMN_NAMES, VIEW_NAMES);
    
protected voidonCreate(android.os.Bundle icicle)


    
        
        super.onCreate(icicle);
        getWindow().requestFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
        setContentView(R.layout.adn_list);
        mEmptyText = (TextView) findViewById(android.R.id.empty);
        mQueryHandler = new QueryHandler(getContentResolver());
    
protected voidonResume()

        super.onResume();
        query();
    
protected voidonStop()

        super.onStop();
        if (mCursor != null) {
            mCursor.deactivate();
        }
    
private voidquery()

        Uri uri = resolveIntent();
        if (DBG) log("query: starting an async query");
        mQueryHandler.startQuery(QUERY_TOKEN, null, uri, COLUMN_NAMES,
                null, null, null);
        displayProgress(true);
    
private voidreQuery()

        query();
    
protected android.net.UriresolveIntent()

        Intent intent = getIntent();
        if (intent.getData() == null) {
            intent.setData(Uri.parse("content://sim/adn"));
        }

        return intent.getData();
    
private voidsetAdapter()

        // NOTE: 
        // As it it written, the positioning code below is NOT working.
        // However, this current non-working state is in compliance with
        // the UI paradigm, so we can't really do much to change it.
        
        // In the future, if we wish to get this "positioning" correct,
        // we'll need to do the following:
        //   1. Change the layout to in the cursor adapter to:
        //     android.R.layout.simple_list_item_checked
        //   2. replace the selection / focus code with:
        //     getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        //     getListView().setItemChecked(mInitialSelection, true);
        
        // Since the positioning is really only useful for the dialer's
        // SpecialCharSequence case (dialing '2#' to get to the 2nd
        // contact for instance), it doesn't make sense to mess with
        // the usability of the activity just for this case.
        
        // These artifacts include: 
        //  1. UI artifacts (checkbox and highlight at the same time)
        //  2. Allowing the user to edit / create new SIM contacts when 
        //    the user is simply trying to retrieve a number into the d
        //    dialer.
        
        if (mCursorAdapter == null) {
            mCursorAdapter = newAdapter();

            setListAdapter(mCursorAdapter);
        } else {
            mCursorAdapter.changeCursor(mCursor);
        }

        if (mInitialSelection >=0 && mInitialSelection < mCursorAdapter.getCount()) {
            setSelection(mInitialSelection);
            getListView().setFocusableInTouchMode(true);
            boolean gotfocus = getListView().requestFocus();
        }