FileDocCategorySizeDatePackage
AlertActivity.javaAPI DocAndroid 1.5 API10953Wed May 06 22:42:42 BST 2009com.android.calendar

AlertActivity

public class AlertActivity extends android.app.Activity
The alert panel that pops up when there is a calendar event alarm. This activity is started by an intent that specifies an event id.

Fields Summary
public static final long
SNOOZE_DELAY
private static final String[]
PROJECTION
public static final int
INDEX_TITLE
public static final int
INDEX_EVENT_LOCATION
public static final int
INDEX_ALL_DAY
public static final int
INDEX_BEGIN
public static final int
INDEX_END
public static final int
INDEX_EVENT_ID
public static final int
INDEX_COLOR
public static final int
INDEX_RRULE
public static final int
INDEX_HAS_ALARM
public static final int
INDEX_STATE
public static final int
INDEX_ALARM_TIME
public static final int
NOTIFICATION_ID
private android.content.ContentResolver
mResolver
private AlertAdapter
mAdapter
private QueryHandler
mQueryHandler
private android.database.Cursor
mCursor
private android.widget.ListView
mListView
private android.widget.Button
mSnoozeAllButton
private android.widget.Button
mDismissAllButton
private android.widget.AdapterView.OnItemClickListener
mViewListener
private android.view.View.OnClickListener
mSnoozeAllListener
private android.view.View.OnClickListener
mDismissAllListener
Constructors Summary
Methods Summary
public android.database.CursorgetItemForView(android.view.View view)

        int index = mListView.getPositionForView(view);
        if (index < 0) {
            return null;
        }
        return (Cursor) mListView.getAdapter().getItem(index);
    
public booleanisEmpty()

    
       
        return (mCursor.getCount() == 0);
    
protected voidonCreate(android.os.Bundle icicle)

    
    
        
        super.onCreate(icicle);
        
        setContentView(R.layout.alert_activity);
        setTitle(R.string.alert_title);
        
        WindowManager.LayoutParams lp = getWindow().getAttributes();
        lp.width = ViewGroup.LayoutParams.FILL_PARENT;
        lp.height = ViewGroup.LayoutParams.FILL_PARENT;
        
        // Get the dim amount from the theme
        TypedArray a = obtainStyledAttributes(com.android.internal.R.styleable.Theme);
        lp.dimAmount = a.getFloat(android.R.styleable.Theme_backgroundDimAmount, 0.5f);
        a.recycle();

        getWindow().setAttributes(lp);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
        
        mResolver = getContentResolver();
        mQueryHandler = new QueryHandler(mResolver);
        mAdapter = new AlertAdapter(this, R.layout.alert_item);
        
        mListView = (ListView) findViewById(R.id.alert_container);
        mListView.setItemsCanFocus(true);
        mListView.setAdapter(mAdapter);
        mListView.setOnItemClickListener(mViewListener);
        
        mSnoozeAllButton = (Button) findViewById(R.id.snooze_all);
        mSnoozeAllButton.setOnClickListener(mSnoozeAllListener);
        mDismissAllButton = (Button) findViewById(R.id.dismiss_all);
        mDismissAllButton.setOnClickListener(mDismissAllListener);

        // Disable the buttons, since they need mCursor, which is created asynchronously
        mSnoozeAllButton.setEnabled(false);
        mDismissAllButton.setEnabled(false);
    
protected voidonDestroy()

        super.onDestroy();
        if (mCursor != null) {
            mCursor.close();
        }
    
protected voidonResume()

        super.onResume();
        
        // If the cursor is null, start the async handler. If it is not null just requery.
        if (mCursor == null) {
            Uri uri = CalendarAlerts.CONTENT_URI_BY_INSTANCE;
            String selection = CalendarAlerts.STATE + "=" + CalendarAlerts.FIRED;
            mQueryHandler.startQuery(0, null, uri, PROJECTION, selection, 
                    null /* selection args */, CalendarAlerts.DEFAULT_SORT_ORDER);
        } else {
            mCursor.requery();
        }
    
protected voidonStop()

        super.onStop();
        AlertReceiver.updateAlertNotification(this);
        
        if (mCursor != null) {
            mCursor.deactivate();
        }