]>
Commit | Line | Data |
---|---|---|
1 | package ro.ieval.unical; | |
2 | ||
3 | import android.content.ContentResolver; | |
4 | import android.content.Context; | |
5 | import android.database.Cursor; | |
6 | import android.provider.BaseColumns; | |
7 | import android.provider.CalendarContract.Attendees; | |
8 | ||
9 | final class Attendee { | |
10 | private static final String[] PROJECTION = { | |
11 | BaseColumns._ID, | |
12 | Attendees.EVENT_ID, | |
13 | Attendees.ATTENDEE_NAME, | |
14 | Attendees.ATTENDEE_EMAIL, | |
15 | Attendees.ATTENDEE_RELATIONSHIP, | |
16 | Attendees.ATTENDEE_TYPE, | |
17 | Attendees.ATTENDEE_STATUS, | |
18 | }; | |
19 | ||
20 | /** Attendee ID */ | |
21 | public final long _id; | |
22 | /** Event ID */ | |
23 | public final long eventID; | |
24 | /** Attendee name */ | |
25 | public final String name; | |
26 | /** Attendee email address **/ | |
27 | public final String email; | |
28 | /** | |
29 | * Attendee relationship. | |
30 | * | |
31 | * One of {@link CalendarContract.AttendeesColumns#RELATIONSHIP_ATTENDEE RELATIONSHIP_ATENDEE}, | |
32 | * {@link CalendarContract.AttendeesColumns#RELATIONSHIP_NONE RELATIONSHIP_NONE}, | |
33 | * {@link CalendarContract.AttendeesColumns#RELATIONSHIP_ORGANIZER RELATIONSHIP_ORGANIZER}, | |
34 | * {@link CalendarContract.AttendeesColumns#RELATIONSHIP_PERFORMER RELATIONSHIP_PERFORMER}, | |
35 | * {@link CalendarContract.AttendeesColumns#RELATIONSHIP_SPEAKER RELATIONSHIP_SPEAKER} | |
36 | */ | |
37 | public final int relationship; | |
38 | /** | |
39 | * Attendee type. | |
40 | * | |
41 | * One of {@link CalendarContract.AttendeesColumns#TYPE_NONE TYPE_NONE}, | |
42 | * {@link CalendarContract.AttendeesColumns#TYPE_OPTIONAL TYPE_OPTIONAL}, | |
43 | * {@link CalendarContract.AttendeesColumns#TYPE_REQUIRED TYPE_REQUIRED}, | |
44 | * {@link CalendarContract.AttendeesColumns#TYPE_RESOURCE TYPE_RESOURCE} | |
45 | */ | |
46 | public final int type; | |
47 | /** | |
48 | * Attendee status. | |
49 | * | |
50 | * One of {@link CalendarContract.AttendeesColumns#ATTENDEE_STATUS_ACCEPTED ATTENDEE_STATUS_ACCEPTED}, | |
51 | * {@link CalendarContract.AttendeesColumns#ATTENDEE_STATUS_DECLINED ATTENDEE_STATUS_DECLINED}, | |
52 | * {@link CalendarContract.AttendeesColumns#ATTENDEE_STATUS_INVITED ATTENDEE_STATUS_INVITED}, | |
53 | * {@link CalendarContract.AttendeesColumns#ATTENDEE_STATUS_NONE ATTENDEE_STATUS_NONE}, | |
54 | * {@link CalendarContract.AttendeesColumns#ATTENDEE_STATUS_TENTATIVE ATTENDEE_STATUS_TENTATIVE} | |
55 | */ | |
56 | public final int status; | |
57 | ||
58 | private Attendee(final long _id, final long eventID, final String name, final String email, final int relationship, final int type, final int status){ | |
59 | this._id=_id; | |
60 | this.eventID=eventID; | |
61 | this.name=name; | |
62 | this.email=email; | |
63 | this.relationship=relationship; | |
64 | this.type=type; | |
65 | this.status=status; | |
66 | } | |
67 | ||
68 | public static Attendee[] getAttendeesByEvent(final Context context, final long eventID){ | |
69 | final ContentResolver cr=context.getContentResolver(); | |
70 | final Cursor cursor = Attendees.query(cr, eventID, PROJECTION); | |
71 | cursor.moveToFirst(); | |
72 | final Attendee[] attendees = new Attendee[cursor.getCount()]; | |
73 | for(int i=0;i<attendees.length;i++){ | |
74 | attendees[i]=new Attendee(cursor.getLong(0), cursor.getLong(1), cursor.getString(2), cursor.getString(3), cursor.getInt(4), cursor.getInt(5), cursor.getInt(6)); | |
75 | cursor.moveToNext(); | |
76 | } | |
77 | cursor.close(); | |
78 | return attendees; | |
79 | } | |
80 | } |