@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (position == 0) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(calendar.getTimeInMillis() + 3600 * 1000); snooze( calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1, calendar.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE)); reportSnooze(ActionReportService.LENGTH_HOUR); } else if (position == 1) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(calendar.getTimeInMillis() + 24 * 3600 * 1000); snooze( calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1, calendar.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE)); reportSnooze(ActionReportService.LENGTH_DAY); } else if (position == 2) { // Start the date picker Calendar calendar = Calendar.getInstance(); CalendarDatePickerDialog datePickerDialog = CalendarDatePickerDialog.newInstance( this, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)); datePickerDialog.show(getSupportFragmentManager(), "SnoozeDate"); } else if (position == 3) { displayPlacesDialog(); } else if (position == 4) { cancelNotification(); setResult(RESULT_OK); Toast.makeText(this, R.string.later_toast, Toast.LENGTH_SHORT).show(); finish(); } }
/** * @param callBack How the parent is notified that the date is set. * @param year The initial year of the dialog. * @param monthOfYear The initial month of the dialog. * @param dayOfMonth The initial day of the dialog. */ public static CalendarDatePickerDialog newInstance( OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth) { CalendarDatePickerDialog ret = new CalendarDatePickerDialog(); ret.initialize(callBack, year, monthOfYear, dayOfMonth); return ret; }