private void checkForNotifications() { Cursor notesCursor = mDbHelper.fetchAllNotes(); notesCursor.moveToFirst(); ArrayList<String> recordatoriosAtrasados = new ArrayList<String>(); ArrayList<String> recordatoriosHoy = new ArrayList<String>(); int i = 0; while (notesCursor.isAfterLast() == false) { String date = new String( notesCursor.getString(notesCursor.getColumnIndexOrThrow(NotesDbAdapter.KEY_F))); if (isOutdated(date) == -1) { String rec = new String( notesCursor.getString(notesCursor.getColumnIndexOrThrow(NotesDbAdapter.KEY_TITLE))); recordatoriosAtrasados.add(rec); } else if (isOutdated(date) == 0) { String rec = new String( notesCursor.getString(notesCursor.getColumnIndexOrThrow(NotesDbAdapter.KEY_TITLE))); recordatoriosHoy.add(rec); } i++; notesCursor.moveToNext(); } showNotification(recordatoriosHoy, 0); showNotification(recordatoriosAtrasados, -1); }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.reminder_list); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.coco_title); ctx = this.getBaseContext(); mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); mDbHelper = new NotesDbAdapter(this); mDbHelper.open(); fillData(); registerForContextMenu(getListView()); checkForNotifications(); }
private void fillData() { Cursor notesCursor = mDbHelper.fetchAllNotes(); // Get all of the rows from the database and create the item list startManagingCursor(notesCursor); // Create an array to specify the fields we want to display in the list (only TITLE) String[] from = new String[] {NotesDbAdapter.KEY_TITLE, NotesDbAdapter.KEY_F}; // and an array of the fields we want to bind those fields to (in this case just text1) int[] to = new int[] {R.id.text1, R.id.text2}; // Now create a simple cursor adapter and set it to display SimpleCursorAdapter notes = new SimpleCursorAdapter(this, R.layout.reminder_row, notesCursor, from, to); setListAdapter(notes); }