this.calendarID=calendarID;
}
- public static Event[] getEventsByCalendar(final Context context, final long calendarID, final String sort){
+ public static Event[] getEventsByCalendar(final Context context, final Calendar calendar, final String sort){
final ContentResolver cr=context.getContentResolver();
final Cursor cursor = cr.query(Events.CONTENT_URI,
PROJECTION,
Events.CALENDAR_ID+" = ?",
- new String[]{Long.toString(calendarID)},
+ new String[]{Long.toString(calendar._id)},
sort);
cursor.moveToFirst();
final Event[] events = new Event[cursor.getCount()];
for(int i=0;i<events.length;i++){
- events[i]=new Event(cursor.getLong(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getInt(5), cursor.getLong(6), cursor.getLong(7), cursor.getLong(8));
+ int colour=cursor.getInt(5);
+ colour=colour == 0 ? calendar.colour : colour;
+ events[i]=new Event(cursor.getLong(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), colour, cursor.getLong(6), cursor.getLong(7), cursor.getLong(8));
cursor.moveToNext();
}
cursor.close();
public static Event[] getAllEvents(final Context context) {
final ArrayList<Event> r = new ArrayList<Event>();
for(final Calendar calendar : Calendar.getAllCalendars(context))
- for(final Event event : getEventsByCalendar(context, calendar._id, null))
+ for(final Event event : getEventsByCalendar(context, calendar, null))
r.add(event);
return r.toArray(new Event[r.size()]);
}