/** Display refreshed data. */ private void iterateThroughEvents() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); boolean showPastEvents = prefs.getBoolean("show_past_events", false); int month = 0; for (Event event : events) { Calendar c = Calendar.getInstance(); if (!showPastEvents && (c.getTime().getTime() > event.getEndDate().getTime())) continue; c.setTime(event.getStartDate()); if (c.get(Calendar.MONTH) != month) { month = c.get(Calendar.MONTH); listData.add( new EventRow(DateUtils.getMonthName(month) + " " + c.get(Calendar.YEAR) + ".")); } listData.add(new EventRow(event)); } listviewAdapter.notifyDataSetChanged(); }