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

BlockedContactsActivity

public class BlockedContactsActivity extends android.app.ListActivity

Fields Summary
ImApp
mApp
SimpleAlertHandler
mHandler
private static final String[]
PROJECTION
static final int
ACCOUNT_COLUMN
static final int
PROVIDER_COLUMN
static final int
NICKNAME_COLUMN
static final int
USERNAME_COLUMN
static final int
AVATAR_COLUMN
Constructors Summary
Methods Summary
protected voidonCreate(android.os.Bundle icicle)


    
        
        super.onCreate(icicle);

        requestWindowFeature(Window.FEATURE_LEFT_ICON);

        setContentView(R.layout.blocked_contacts_activity);
        mHandler = new SimpleAlertHandler(this);

        mApp = ImApp.getApplication(this);
        mApp.startImServiceIfNeed();
        if (!resolveIntent()) {
            finish();
            return;
        }
    
protected voidonListItemClick(android.widget.ListView l, android.view.View v, int position, long id)

        Cursor c = (Cursor) l.getAdapter().getItem(position);
        if (c == null) {
            mHandler.showAlert(R.string.error, R.string.select_contact);
            return;
        }
        long providerId = c.getLong(PROVIDER_COLUMN);
        String username = c.getString(USERNAME_COLUMN);
        String nickname = c.getString(NICKNAME_COLUMN);
        mApp.callWhenServiceConnected(mHandler, new UnblockAction(providerId, username, nickname));
    
private booleanresolveIntent()

        Intent i = getIntent();
        Uri uri = i.getData();
        if (uri == null) {
            warning("No data to show");
            return false;
        }

        long accountId = ContentUris.parseId(uri);
        Uri accountUri = ContentUris.withAppendedId(Im.Account.CONTENT_URI, accountId);
        Cursor accountCursor = getContentResolver().query(accountUri, null, null, null, null);
        if (accountCursor == null) {
            warning("Bad account");
            return false;
        }
        if (!accountCursor.moveToFirst()) {
            warning("Bad account");
            accountCursor.close();
            return false;
        }

        long providerId = accountCursor.getLong(
                accountCursor.getColumnIndexOrThrow(Im.Account.PROVIDER));
        String username = accountCursor.getString(
                accountCursor.getColumnIndexOrThrow(Im.Account.USERNAME));

        BrandingResources brandingRes = mApp.getBrandingResource(providerId);
        getWindow().setFeatureDrawable(Window.FEATURE_LEFT_ICON,
                brandingRes.getDrawable(BrandingResourceIDs.DRAWABLE_LOGO));

        setTitle(getResources().getString(R.string.blocked_list_title, username));
        accountCursor.close();

        Cursor c = managedQuery(uri, PROJECTION, null, Im.BlockedList.DEFAULT_SORT_ORDER);
        if (c == null) {
            warning("Database error when query " + uri);
            return false;
        }

        ListAdapter adapter = new BlockedContactsAdapter(c, this);
        setListAdapter(adapter);
        return true;
    
private static voidwarning(java.lang.String msg)

        Log.w(ImApp.LOG_TAG, "<BlockContactsActivity> " + msg);