From f3ad474012285f75be4d43bf3a711b430e483673 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Wed, 29 May 2013 12:43:12 +0300 Subject: [PATCH] Add Attendee class --- src/ro/ieval/unical/Attendee.java | 78 +++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 src/ro/ieval/unical/Attendee.java diff --git a/src/ro/ieval/unical/Attendee.java b/src/ro/ieval/unical/Attendee.java new file mode 100644 index 0000000..6afeaf4 --- /dev/null +++ b/src/ro/ieval/unical/Attendee.java @@ -0,0 +1,78 @@ +package ro.ieval.unical; + +import android.content.ContentResolver; +import android.content.Context; +import android.database.Cursor; +import android.provider.CalendarContract; +import android.provider.CalendarContract.Attendees; +import android.provider.CalendarContract.Events; + +final class Attendee { + private static final String[] PROJECTION = { + Attendees._ID, + Attendees.EVENT_ID, + Attendees.ATTENDEE_NAME, + Attendees.ATTENDEE_EMAIL, + Attendees.ATTENDEE_RELATIONSHIP, + Attendees.ATTENDEE_TYPE, + Attendees.ATTENDEE_STATUS, + }; + + /** Attendee ID */ + public final long _id; + /** Event ID */ + public final long eventID; + /** Attendee name */ + public final String name; + /** Attendee email address **/ + public final String email; + /** + * Attendee relationship. + * + * One of {@link CalendarContract.AttendeesColumns#RELATIONSHIP_ATTENDEE RELATIONSHIP_ATENDEE}, + * {@link CalendarContract.AttendeesColumns#RELATIONSHIP_NONE RELATIONSHIP_NONE}, + * {@link CalendarContract.AttendeesColumns#RELATIONSHIP_ORGANIZER RELATIONSHIP_ORGANIZER}, + * {@link CalendarContract.AttendeesColumns#RELATIONSHIP_PERFORMER RELATIONSHIP_PERFORMER}, + * {@link CalendarContract.AttendeesColumns#RELATIONSHIP_SPEAKER RELATIONSHIP_SPEAKER} + */ + public final int relationship; + /** + * Attendee type. + * + * One of {@link CalendarContract.AttendeesColumns#TYPE_NONE TYPE_NONE}, + * {@link CalendarContract.AttendeesColumns#TYPE_OPTIONAL TYPE_OPTIONAL}, + * {@link CalendarContract.AttendeesColumns#TYPE_REQUIRED TYPE_REQUIRED}, + * {@link CalendarContract.AttendeesColumns#TYPE_RESOURCE TYPE_RESOURCE} + */ + public final int type; + /** + * Attendee status. + * + * One of {@link CalendarContract.AttendeesColumns#ATTENDEE_STATUS_ACCEPTED ATTENDEE_STATUS_ACCEPTED}, + * {@link CalendarContract.AttendeesColumns#ATTENDEE_STATUS_DECLINED ATTENDEE_STATUS_DECLINED}, + * {@link CalendarContract.AttendeesColumns#ATTENDEE_STATUS_INVITED ATTENDEE_STATUS_INVITED}, + * {@link CalendarContract.AttendeesColumns#ATTENDEE_STATUS_NONE ATTENDEE_STATUS_NONE}, + * {@link CalendarContract.AttendeesColumns#ATTENDEE_STATUS_TENTATIVE ATTENDEE_STATUS_TENTATIVE} + */ + public final int status; + + private Attendee(final long _id, final long eventID, final String name, final String email, final int relationship, final int type, final int status){ + this._id=_id; + this.eventID=eventID; + this.name=name; + this.email=email; + this.relationship=relationship; + this.type=type; + this.status=status; + } + + public static Attendee[] getAttendeesByEvent(final Context context, final int eventID){ + final ContentResolver cr=context.getContentResolver(); + final Cursor cursor = Attendees.query(cr, eventID, PROJECTION); + cursor.moveToFirst(); + final Attendee[] attendees = new Attendee[cursor.getCount()]; + for(int i=0;i