0

A query of CalendarContracts.Instances comes back with all recurring events expanded to individual instance "placeholders". How can I tell which rows represent placeholders and which ones are unique, single events?

Peri Hartman
  • 19,314
  • 18
  • 55
  • 101

2 Answers2

1

1.How can I tell which rows represent placeholders and which ones are unique, single events?

To detect single, non-recurring events, it would be much easier for you to query CalendarContacts.Events and look for events whose recurring columns are null.

2.the latter two can only be defined if they appear in the rule defined by RRULE

False, RDATE and RRULE are completely independent of each other. See 4.6.1 Event Component:

       ; the following are optional,
       ; and MAY occur more than once

       attach / attendee / categories / comment /
       contact / EXDATE/ EXRULE/ rstatus / related /
       resources / RDATE / RRULE / x-prop    

3.Anyone care to explain?

RRULE specifies a recurring pattern.
While RDATE specifies a set of recurring date-times.

See 4.8.5 Recurrence Component Properties for formal definition and examples.

In fact, they can even co-exist together:

Description: This property [RDATE] can appear along with the "RRULE" property to define an aggregate set of repeating occurrences. When they both appear in an iCalendar object, the recurring events are defined by the union of occurrences defined by both the "RDATE" and "RRULE".

So the function basically says, "If any of the columns is NOT empty, return true".

Some Noob Student
  • 14,186
  • 13
  • 65
  • 103
  • I went back and looked at 4.8.5 again. Actually, I think the spec is vague about whether RDATE can occur without RRULE. It might be that you can specify a start date and then an arbrary collection of RDATES, which would effectively be a collection of single-occurence events. Thus I think the safe solution would be to consider an event recurring if RDATE *or* RRULE is defined. Thanks for helping me dig into this. – Peri Hartman Mar 03 '13 at 14:56
  • Yes, `isRecurrenceEvent` detects exactly that, plus a little more. Please checkmark it if it solves your problem =D – Some Noob Student Mar 04 '13 at 20:59
0

I found this code in the android Calendar source. I'm not sure why it checks for all three attributes as, I believe, the latter two can only be defined if they appear in the rule defined by RRULE. Anyone care to explain?

  public static boolean isRecurrenceEvent(ContentValues values) {  
    return (!TextUtils.isEmpty(values.getAsString(Events.RRULE))||  
            !TextUtils.isEmpty(values.getAsString(Events.RDATE))||  
            !TextUtils.isEmpty(values.getAsString(Events.ORIGINAL_EVENT)));  
  } 
Peri Hartman
  • 19,314
  • 18
  • 55
  • 101