@Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); Intent intent = getIntent(); if (intent == null) { finish(); return; } mEventId = intent.getLongExtra(EXTRA_EVENT_ID, -1); if (mEventId == -1) { finish(); return; } // Set listener getListView().setOnItemClickListener(QuickResponseActivity.this); // Populate responses String[] responses = Utils.getQuickResponses(this); Arrays.sort(responses); // Add "Custom response..." mResponses = new String[responses.length + 1]; int i; for (i = 0; i < responses.length; i++) { mResponses[i] = responses[i]; } mResponses[i] = getResources().getString(R.string.quick_response_custom_msg); setListAdapter(new ArrayAdapter<String>(this, R.layout.quick_response_item, mResponses)); }
@SuppressLint("NewApi") @Override public void onItemClick(AdapterView<?> parent, View view, int position, long i) { AlertActivity alertActivity = AlertActivity.this; Cursor cursor = alertActivity.getItemForView(view); long alarmId = cursor.getLong(INDEX_ROW_ID); long eventId = cursor.getLong(AlertActivity.INDEX_EVENT_ID); long startMillis = cursor.getLong(AlertActivity.INDEX_BEGIN); // Mark this alarm as DISMISSED dismissAlarm(alarmId, eventId, startMillis); // build an intent and task stack to start EventInfoActivity with AllInOneActivity // as the parent activity rooted to home. long endMillis = cursor.getLong(AlertActivity.INDEX_END); Intent eventIntent = AlertUtils.buildEventViewIntent(AlertActivity.this, eventId, startMillis, endMillis); if (Utils.isJellybeanOrLater()) { TaskStackBuilder.create(AlertActivity.this) .addParentStack(EventInfoActivity.class) .addNextIntent(eventIntent) .startActivities(); } else { alertActivity.startActivity(eventIntent); } alertActivity.finish(); }