]>
Commit | Line | Data |
---|---|---|
f3ad4740 MG |
1 | package ro.ieval.unical; |
2 | ||
3 | import android.content.ContentResolver; | |
4 | import android.content.Context; | |
5 | import android.database.Cursor; | |
8a817995 | 6 | import android.provider.BaseColumns; |
f3ad4740 | 7 | import android.provider.CalendarContract.Attendees; |
f3ad4740 MG |
8 | |
9 | final class Attendee { | |
10 | private static final String[] PROJECTION = { | |
8a817995 | 11 | BaseColumns._ID, |
f3ad4740 MG |
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 | ||
452aaab6 | 68 | public static Attendee[] getAttendeesByEvent(final Context context, final long eventID){ |
f3ad4740 MG |
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()]; | |
16e2550c | 73 | for(int i=0;i<attendees.length;i++){ |
f3ad4740 | 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)); |
16e2550c MG |
75 | cursor.moveToNext(); |
76 | } | |
8a817995 | 77 | cursor.close(); |
f3ad4740 MG |
78 | return attendees; |
79 | } | |
80 | } |