]> iEval git - unical.git/commitdiff
Default eventColour to the calendar colour
authorMarius Gavrilescu <marius@ieval.ro>
Sun, 9 Jun 2013 21:41:11 +0000 (00:41 +0300)
committerMarius Gavrilescu <marius@ieval.ro>
Sun, 9 Jun 2013 21:41:11 +0000 (00:41 +0300)
src/ro/ieval/unical/Event.java

index 23ccd74d5488b9ba411464bc294bf315c540a7ee..97ce822f498e97a6478be516df68889c83a055e4 100644 (file)
@@ -67,17 +67,19 @@ final class Event implements Parcelable{
                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();
@@ -87,7 +89,7 @@ final class Event implements Parcelable{
        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()]);
        }
This page took 0.019472 seconds and 4 git commands to generate.