1
0
mirror of https://github.com/etesync/android synced 2024-11-15 20:38:58 +00:00

Use EntityEvent to populate entities from local DB

This commit is contained in:
Ricki Hirner 2015-05-03 18:32:56 +02:00
parent 365e04154b
commit f19d528739
2 changed files with 186 additions and 208 deletions

View File

@ -191,7 +191,7 @@ public class LocalAddressBook extends LocalCollection<Contact> {
try { try {
@Cleanup EntityIterator iter = ContactsContract.RawContacts.newEntityIterator(providerClient.query( @Cleanup EntityIterator iter = ContactsContract.RawContacts.newEntityIterator(providerClient.query(
ContactsContract.RawContactsEntity.CONTENT_URI, syncAdapterURI(ContactsContract.RawContactsEntity.CONTENT_URI),
null, RawContacts._ID + "=" + c.getLocalID(), null, RawContacts._ID + "=" + c.getLocalID(),
null, null)); null, null));
@ -252,8 +252,6 @@ public class LocalAddressBook extends LocalCollection<Contact> {
break; break;
} }
} }
Log.i(TAG, "Populated contact: " + c);
} else } else
throw new RecordNotFoundException(); throw new RecordNotFoundException();
} catch(RemoteException ex) { } catch(RemoteException ex) {
@ -341,7 +339,7 @@ public class LocalAddressBook extends LocalCollection<Contact> {
break; break;
case Phone.TYPE_CUSTOM: case Phone.TYPE_CUSTOM:
String customType = row.getAsString(Phone.LABEL); String customType = row.getAsString(Phone.LABEL);
if (!StringUtils.isEmpty(customType)) if (StringUtils.isNotEmpty(customType))
number.addType(TelephoneType.get(labelToXName(customType))); number.addType(TelephoneType.get(labelToXName(customType)));
} }
if (row.getAsBoolean(Phone.IS_PRIMARY)) if (row.getAsBoolean(Phone.IS_PRIMARY))
@ -363,7 +361,7 @@ public class LocalAddressBook extends LocalCollection<Contact> {
break; break;
case Email.TYPE_CUSTOM: case Email.TYPE_CUSTOM:
String customType = row.getAsString(Email.LABEL); String customType = row.getAsString(Email.LABEL);
if (!StringUtils.isEmpty(customType)) if (StringUtils.isNotEmpty(customType))
email.addType(EmailType.get(labelToXName(customType))); email.addType(EmailType.get(labelToXName(customType)));
} }
if (row.getAsBoolean(Email.IS_PRIMARY)) if (row.getAsBoolean(Email.IS_PRIMARY))
@ -393,18 +391,18 @@ public class LocalAddressBook extends LocalCollection<Contact> {
title = row.getAsString(Organization.TITLE), title = row.getAsString(Organization.TITLE),
role = row.getAsString(Organization.JOB_DESCRIPTION); role = row.getAsString(Organization.JOB_DESCRIPTION);
if (!StringUtils.isEmpty(company) || !StringUtils.isEmpty(department)) { if (StringUtils.isNotEmpty(company) || StringUtils.isNotEmpty(department)) {
ezvcard.property.Organization org = new ezvcard.property.Organization(); ezvcard.property.Organization org = new ezvcard.property.Organization();
if (!StringUtils.isEmpty(company)) if (StringUtils.isNotEmpty(company))
org.addValue(company); org.addValue(company);
if (!StringUtils.isEmpty(department)) if (StringUtils.isNotEmpty(department))
org.addValue(department); org.addValue(department);
c.setOrganization(org); c.setOrganization(org);
} }
if (!StringUtils.isEmpty(title)) if (StringUtils.isNotEmpty(title))
c.setJobTitle(title); c.setJobTitle(title);
if (!StringUtils.isEmpty(role)) if (StringUtils.isNotEmpty(role))
c.setJobDescription(role); c.setJobDescription(role);
} }
@ -454,7 +452,7 @@ public class LocalAddressBook extends LocalCollection<Contact> {
break; break;
case Im.TYPE_CUSTOM: case Im.TYPE_CUSTOM:
String customType = row.getAsString(Im.LABEL); String customType = row.getAsString(Im.LABEL);
if (!StringUtils.isEmpty(customType)) if (StringUtils.isNotEmpty(customType))
impp.addType(ImppType.get(labelToXName(customType))); impp.addType(ImppType.get(labelToXName(customType)));
} }
@ -483,7 +481,7 @@ public class LocalAddressBook extends LocalCollection<Contact> {
break; break;
case StructuredPostal.TYPE_CUSTOM: case StructuredPostal.TYPE_CUSTOM:
String customType = row.getAsString(StructuredPostal.LABEL); String customType = row.getAsString(StructuredPostal.LABEL);
if (!StringUtils.isEmpty(customType)) if (StringUtils.isNotEmpty(customType))
address.addType(AddressType.get(labelToXName(customType))); address.addType(AddressType.get(labelToXName(customType)));
break; break;
} }
@ -626,7 +624,7 @@ public class LocalAddressBook extends LocalCollection<Contact> {
types.add(RelatedType.SPOUSE); types.add(RelatedType.SPOUSE);
case Relation.TYPE_CUSTOM: case Relation.TYPE_CUSTOM:
String customType = row.getAsString(Relation.LABEL); String customType = row.getAsString(Relation.LABEL);
if (!StringUtils.isEmpty(customType)) if (StringUtils.isNotEmpty(customType))
types.add(RelatedType.get(customType)); types.add(RelatedType.get(customType));
} }
} }
@ -643,7 +641,7 @@ public class LocalAddressBook extends LocalCollection<Contact> {
break; break;
case SipAddress.TYPE_CUSTOM: case SipAddress.TYPE_CUSTOM:
String customType = row.getAsString(SipAddress.LABEL); String customType = row.getAsString(SipAddress.LABEL);
if (!StringUtils.isEmpty(customType)) if (StringUtils.isNotEmpty(customType))
impp.addType(ImppType.get(labelToXName(customType))); impp.addType(ImppType.get(labelToXName(customType)));
} }
c.getImpps().add(impp); c.getImpps().add(impp);

View File

@ -16,6 +16,8 @@ import android.content.ContentProviderOperation.Builder;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.ContentUris; import android.content.ContentUris;
import android.content.ContentValues; import android.content.ContentValues;
import android.content.Entity;
import android.content.EntityIterator;
import android.database.Cursor; import android.database.Cursor;
import android.database.DatabaseUtils; import android.database.DatabaseUtils;
import android.net.Uri; import android.net.Uri;
@ -260,7 +262,7 @@ public class LocalCalendar extends LocalCollection<Event> {
" AND " + Events.ORIGINAL_SYNC_ID + " NOT IN (" + StringUtils.join(sqlFileNames, ",") + ")"; // retain by remote file name " AND " + Events.ORIGINAL_SYNC_ID + " NOT IN (" + StringUtils.join(sqlFileNames, ",") + ")"; // retain by remote file name
pendingOperations.add(ContentProviderOperation pendingOperations.add(ContentProviderOperation
.newDelete(entriesURI()) .newDelete(entriesURI())
.withSelection(where, new String[] { String.valueOf(id) }) .withSelection(where, new String[]{String.valueOf(id)})
.withYieldAllowed(true) .withYieldAllowed(true)
.build() .build()
); );
@ -273,7 +275,7 @@ public class LocalCalendar extends LocalCollection<Event> {
// delete all exceptions of this event, too // delete all exceptions of this event, too
pendingOperations.add(ContentProviderOperation pendingOperations.add(ContentProviderOperation
.newDelete(entriesURI()) .newDelete(entriesURI())
.withSelection(Events.ORIGINAL_ID+"=?", new String[] { Long.toString(resource.getLocalID()) }) .withSelection(Events.ORIGINAL_ID + "=?", new String[] { Long.toString(resource.getLocalID()) })
.build() .build()
); );
} }
@ -286,7 +288,7 @@ public class LocalCalendar extends LocalCollection<Event> {
pendingOperations.add(ContentProviderOperation pendingOperations.add(ContentProviderOperation
.newUpdate(entriesURI()) .newUpdate(entriesURI())
.withValue(Events.DIRTY, 0) .withValue(Events.DIRTY, 0)
.withSelection(Events.ORIGINAL_ID+"=?", new String[] { Long.toString(resource.getLocalID()) }) .withSelection(Events.ORIGINAL_ID + "=?", new String[] { Long.toString(resource.getLocalID()) })
.build() .build()
); );
} }
@ -296,102 +298,119 @@ public class LocalCalendar extends LocalCollection<Event> {
@Override @Override
public void populate(Resource resource) throws LocalStorageException { public void populate(Resource resource) throws LocalStorageException {
Event e = (Event)resource; Event event = (Event)resource;
try { try {
@Cleanup Cursor cursor = providerClient.query(ContentUris.withAppendedId(entriesURI(), e.getLocalID()), @Cleanup EntityIterator iterEvents = CalendarContract.EventsEntity.newEntityIterator(
new String[] { providerClient.query(
/* 0 */ Events.TITLE, Events.EVENT_LOCATION, Events.DESCRIPTION, syncAdapterURI(CalendarContract.EventsEntity.CONTENT_URI),
/* 3 */ Events.DTSTART, Events.DTEND, Events.EVENT_TIMEZONE, Events.EVENT_END_TIMEZONE, Events.ALL_DAY, null, Events._ID + "=" + event.getLocalID(),
/* 8 */ Events.STATUS, Events.ACCESS_LEVEL, null, null),
/* 10 */ Events.RRULE, Events.RDATE, Events.EXRULE, Events.EXDATE, providerClient
/* 14 */ Events.HAS_ATTENDEE_DATA, Events.ORGANIZER, Events.SELF_ATTENDEE_STATUS, );
/* 17 */ entryColumnUID(), Events.DURATION, Events.AVAILABILITY, while (iterEvents.hasNext()) {
/* 20 */ Events.ORIGINAL_ALL_DAY, Events.ORIGINAL_INSTANCE_TIME Entity e = iterEvents.next();
}, null, null, null);
if (cursor != null && cursor.moveToNext()) { ContentValues values = e.getEntityValues();
e.setUid(cursor.getString(17)); populateEvent(event, values);
e.setSummary(cursor.getString(0)); List<Entity.NamedContentValues> subValues = e.getSubValues();
e.setLocation(cursor.getString(1)); for (Entity.NamedContentValues subValue : subValues) {
e.setDescription(cursor.getString(2)); values = subValue.values;
if (Attendees.CONTENT_URI.equals(subValue.uri))
boolean allDay = cursor.getInt(7) != 0; populateAttendee(event, values);
long tsStart = cursor.getLong(3), if (Reminders.CONTENT_URI.equals(subValue.uri))
tsEnd = cursor.getLong(4); populateReminder(event, values);
String duration = cursor.getString(18);
String tzId = null;
if (allDay) {
e.setDtStart(tsStart, null);
// provide only DTEND and not DURATION for all-day events
if (tsEnd == 0) {
Dur dur = new Dur(duration);
java.util.Date dEnd = dur.getTime(new java.util.Date(tsStart));
tsEnd = dEnd.getTime();
}
e.setDtEnd(tsEnd, null);
} else {
// use the start time zone for the end time, too
// because apps like Samsung Planner allow the user to change "the" time zone but change the start time zone only
tzId = cursor.getString(5);
e.setDtStart(tsStart, tzId);
if (tsEnd != 0)
e.setDtEnd(tsEnd, tzId);
else if (!StringUtils.isEmpty(duration))
e.setDuration(new Duration(new Dur(duration)));
}
// recurrence
try {
String strRRule = cursor.getString(10);
if (!StringUtils.isEmpty(strRRule))
e.setRrule(new RRule(strRRule));
String strRDate = cursor.getString(11);
if (!StringUtils.isEmpty(strRDate)) {
RDate rDate = new RDate();
rDate.setValue(strRDate);
e.setRdate(rDate);
}
String strExRule = cursor.getString(12);
if (!StringUtils.isEmpty(strExRule)) {
ExRule exRule = new ExRule();
exRule.setValue(strExRule);
e.setExrule(exRule);
}
String strExDate = cursor.getString(13);
if (!StringUtils.isEmpty(strExDate)) {
// ignored, see https://code.google.com/p/android/issues/detail?id=21426
ExDate exDate = new ExDate();
exDate.setValue(strExDate);
e.setExdate(exDate);
}
} catch (ParseException ex) {
Log.w(TAG, "Couldn't parse recurrence rules, ignoring", ex);
} catch (IllegalArgumentException ex) {
Log.w(TAG, "Invalid recurrence rules, ignoring", ex);
} }
// recurrence exceptions populateExceptions(event);
if (!cursor.isNull(21)) { }
long originalInstanceTime = cursor.getLong(21); } catch (RemoteException ex) {
boolean originalAllDay = cursor.getInt(20) != 0; throw new LocalStorageException("Couldn't process locally stored event", ex);
Date originalDate = originalAllDay ? }
new Date(originalInstanceTime) : }
new DateTime(originalInstanceTime);
if (originalDate instanceof DateTime)
((DateTime)originalDate).setUtc(true);
e.setRecurrenceId(new RecurrenceId(originalDate));
} else
// this event may have exceptions
populateExceptions(e);
// status protected void populateEvent(Event e, ContentValues values) {
switch (cursor.getInt(8)) { e.setUid(values.getAsString(entryColumnUID()));
e.setSummary(values.getAsString(Events.TITLE));
e.setLocation(values.getAsString(Events.EVENT_LOCATION));
e.setDescription(values.getAsString(Events.DESCRIPTION));
boolean allDay = values.getAsBoolean(Events.ALL_DAY);
long tsStart = values.getAsLong(Events.DTSTART);
Long tsEnd = values.getAsLong(Events.DTEND);
String duration = values.getAsString(Events.DURATION);
String tzId = null;
if (allDay) {
e.setDtStart(tsStart, null);
if (tsEnd == null) {
Dur dur = new Dur(duration);
java.util.Date dEnd = dur.getTime(new java.util.Date(tsStart));
tsEnd = dEnd.getTime();
}
e.setDtEnd(tsEnd, null);
} else {
// use the start time zone for the end time, too
// because apps like Samsung Planner allow the user to change "the" time zone but change the start time zone only
tzId = values.getAsString(Events.EVENT_TIMEZONE);
e.setDtStart(tsStart, tzId);
if (tsEnd != null)
e.setDtEnd(tsEnd, tzId);
else if (!StringUtils.isEmpty(duration))
e.setDuration(new Duration(new Dur(duration)));
}
// recurrence
try {
String strRRule = values.getAsString(Events.RRULE);
if (!StringUtils.isEmpty(strRRule))
e.setRrule(new RRule(strRRule));
String strRDate = values.getAsString(Events.RDATE);
if (!StringUtils.isEmpty(strRDate)) {
RDate rDate = new RDate();
rDate.setValue(strRDate);
e.setRdate(rDate);
}
String strExRule = values.getAsString(Events.EXRULE);
if (!StringUtils.isEmpty(strExRule)) {
ExRule exRule = new ExRule();
exRule.setValue(strExRule);
e.setExrule(exRule);
}
String strExDate = values.getAsString(Events.EXDATE);
if (!StringUtils.isEmpty(strExDate)) {
// ignored, see https://code.google.com/p/android/issues/detail?id=21426
ExDate exDate = new ExDate();
exDate.setValue(strExDate);
e.setExdate(exDate);
}
} catch (ParseException ex) {
Log.w(TAG, "Couldn't parse recurrence rules, ignoring", ex);
} catch (IllegalArgumentException ex) {
Log.w(TAG, "Invalid recurrence rules, ignoring", ex);
}
if (values.containsKey(Events.ORIGINAL_INSTANCE_TIME)) {
// this event is an exception of a recurring event
long originalInstanceTime = values.getAsLong(Events.ORIGINAL_INSTANCE_TIME);
boolean originalAllDay = values.getAsBoolean(Events.ORIGINAL_ALL_DAY);
Date originalDate = originalAllDay ?
new Date(originalInstanceTime) :
new DateTime(originalInstanceTime);
if (originalDate instanceof DateTime)
((DateTime)originalDate).setUtc(true);
e.setRecurrenceId(new RecurrenceId(originalDate));
}
// status
if (values.containsKey(Events.STATUS))
switch (values.getAsInteger(Events.STATUS)) {
case Events.STATUS_CONFIRMED: case Events.STATUS_CONFIRMED:
e.setStatus(Status.VEVENT_CONFIRMED); e.setStatus(Status.VEVENT_CONFIRMED);
break; break;
@ -400,50 +419,37 @@ public class LocalCalendar extends LocalCollection<Event> {
break; break;
case Events.STATUS_CANCELED: case Events.STATUS_CANCELED:
e.setStatus(Status.VEVENT_CANCELLED); e.setStatus(Status.VEVENT_CANCELLED);
} }
// availability // availability
e.setOpaque(cursor.getInt(19) != Events.AVAILABILITY_FREE); e.setOpaque(values.getAsInteger(Events.AVAILABILITY) != Events.AVAILABILITY_FREE);
// attendees // set ORGANIZER only when there are attendees
if (cursor.getInt(14) != 0) { // has attendees if (values.getAsBoolean(Events.HAS_ATTENDEE_DATA) && values.containsKey(Events.ORGANIZER))
try { try {
e.setOrganizer(new Organizer(new URI("mailto", cursor.getString(15), null))); e.setOrganizer(new Organizer(new URI("mailto", values.getAsString(Events.ORGANIZER), null)));
} catch (URISyntaxException ex) { } catch (URISyntaxException ex) {
Log.e(TAG, "Error when creating ORGANIZER URI, ignoring", ex); Log.e(TAG, "Error when creating ORGANIZER URI, ignoring", ex);
} }
populateAttendees(e);
} // classification
switch (values.getAsInteger(Events.ACCESS_LEVEL)) {
// classification case Events.ACCESS_CONFIDENTIAL:
switch (cursor.getInt(9)) { case Events.ACCESS_PRIVATE:
case Events.ACCESS_CONFIDENTIAL: e.setForPublic(false);
case Events.ACCESS_PRIVATE: break;
e.setForPublic(false); case Events.ACCESS_PUBLIC:
break; e.setForPublic(true);
case Events.ACCESS_PUBLIC:
e.setForPublic(true);
}
populateReminders(e);
} else
throw new RecordNotFoundException();
} catch(RemoteException ex) {
throw new LocalStorageException(ex);
} }
} }
void populateExceptions(Event e) throws RemoteException { void populateExceptions(Event e) throws RemoteException {
Uri exceptionsUri = Events.CONTENT_URI.buildUpon() @Cleanup Cursor c = providerClient.query(syncAdapterURI(Events.CONTENT_URI),
.appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER, "true") new String[]{Events._ID, entryColumnRemoteName()},
.build(); Events.ORIGINAL_ID + "=?", new String[]{ String.valueOf(e.getLocalID()) }, null);
@Cleanup Cursor c = providerClient.query(exceptionsUri, new String[] {
/* 0 */ Events._ID, entryColumnRemoteName()
}, Events.ORIGINAL_ID + "=?", new String[] { String.valueOf(e.getLocalID()) }, null);
while (c != null && c.moveToNext()) { while (c != null && c.moveToNext()) {
long exceptionId = c.getLong(0); long exceptionId = c.getLong(0);
String exceptionRemoteName = c.getString(1); String exceptionRemoteName = c.getString(1);
Log.i(TAG, "Found exception ID " + exceptionId + " of original ID " + e.getLocalID());
try { try {
Event exception = new Event(exceptionId, exceptionRemoteName, null); Event exception = new Event(exceptionId, exceptionRemoteName, null);
populate(exception); populate(exception);
@ -454,30 +460,22 @@ public class LocalCalendar extends LocalCollection<Event> {
} }
} }
void populateAttendees(Event e) throws RemoteException { void populateAttendee(Event event, ContentValues values) throws RemoteException {
Uri attendeesUri = Attendees.CONTENT_URI.buildUpon() try {
.appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER, "true") Attendee attendee = new Attendee(new URI("mailto", values.getAsString(Attendees.ATTENDEE_EMAIL), null));
.build(); ParameterList params = attendee.getParameters();
@Cleanup Cursor c = providerClient.query(attendeesUri, new String[]{
/* 0 */ Attendees.ATTENDEE_EMAIL, Attendees.ATTENDEE_NAME, Attendees.ATTENDEE_TYPE, String cn = values.getAsString(Attendees.ATTENDEE_NAME);
/* 3 */ Attendees.ATTENDEE_RELATIONSHIP, Attendees.STATUS if (cn != null)
}, Attendees.EVENT_ID + "=?", new String[]{String.valueOf(e.getLocalID())}, null); params.add(new Cn(cn));
while (c != null && c.moveToNext()) {
try { // type
Attendee attendee = new Attendee(new URI("mailto", c.getString(0), null)); int type = values.getAsInteger(Attendees.ATTENDEE_TYPE);
ParameterList params = attendee.getParameters(); params.add((type == Attendees.TYPE_RESOURCE) ? CuType.RESOURCE : CuType.INDIVIDUAL);
String cn = c.getString(1); // role
if (cn != null) int relationship = values.getAsInteger(Attendees.ATTENDEE_RELATIONSHIP);
params.add(new Cn(cn)); switch (relationship) {
// type
int type = c.getInt(2);
params.add((type == Attendees.TYPE_RESOURCE) ? CuType.RESOURCE : CuType.INDIVIDUAL);
// role
int relationship = c.getInt(3);
switch (relationship) {
case Attendees.RELATIONSHIP_ORGANIZER: case Attendees.RELATIONSHIP_ORGANIZER:
params.add(Role.CHAIR); params.add(Role.CHAIR);
break; break;
@ -488,10 +486,10 @@ public class LocalCalendar extends LocalCollection<Event> {
break; break;
case Attendees.RELATIONSHIP_NONE: case Attendees.RELATIONSHIP_NONE:
params.add(Role.NON_PARTICIPANT); params.add(Role.NON_PARTICIPANT);
} }
// status // status
switch (c.getInt(4)) { switch (values.getAsInteger(Attendees.ATTENDEE_STATUS)) {
case Attendees.ATTENDEE_STATUS_INVITED: case Attendees.ATTENDEE_STATUS_INVITED:
params.add(PartStat.NEEDS_ACTION); params.add(PartStat.NEEDS_ACTION);
break; break;
@ -504,37 +502,21 @@ public class LocalCalendar extends LocalCollection<Event> {
case Attendees.ATTENDEE_STATUS_TENTATIVE: case Attendees.ATTENDEE_STATUS_TENTATIVE:
params.add(PartStat.TENTATIVE); params.add(PartStat.TENTATIVE);
break; break;
}
e.getAttendees().add(attendee);
} catch (URISyntaxException ex) {
Log.e(TAG, "Couldn't parse attendee information, ignoring", ex);
} }
event.getAttendees().add(attendee);
} catch (URISyntaxException ex) {
Log.e(TAG, "Couldn't parse attendee information, ignoring", ex);
} }
} }
void populateReminders(Event e) throws RemoteException { void populateReminder(Event event, ContentValues row) throws RemoteException {
// reminders VAlarm alarm = new VAlarm(new Dur(0, 0, row.getAsInteger(Reminders.MINUTES), 0));
Uri remindersUri = Reminders.CONTENT_URI.buildUpon()
.appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER, "true") PropertyList props = alarm.getProperties();
.build(); props.add(Action.DISPLAY);
@Cleanup Cursor c = providerClient.query(remindersUri, new String[] { props.add(new Description(event.getSummary()));
/* 0 */ Reminders.MINUTES, Reminders.METHOD event.getAlarms().add(alarm);
}, Reminders.EVENT_ID + "=?", new String[] { String.valueOf(e.getLocalID()) }, null);
while (c != null && c.moveToNext()) {
VAlarm alarm = new VAlarm(new Dur(0, 0, -c.getInt(0), 0));
PropertyList props = alarm.getProperties();
switch (c.getInt(1)) {
/*case Reminders.METHOD_EMAIL:
props.add(Action.EMAIL);
break;*/
default:
props.add(Action.DISPLAY);
props.add(new Description(e.getSummary()));
}
e.getAlarms().add(alarm);
}
} }
@ -549,6 +531,7 @@ public class LocalCalendar extends LocalCollection<Event> {
.withValue(Events.ALL_DAY, event.isAllDay() ? 1 : 0) .withValue(Events.ALL_DAY, event.isAllDay() ? 1 : 0)
.withValue(Events.DTSTART, event.getDtStartInMillis()) .withValue(Events.DTSTART, event.getDtStartInMillis())
.withValue(Events.EVENT_TIMEZONE, event.getDtStartTzID()) .withValue(Events.EVENT_TIMEZONE, event.getDtStartTzID())
.withValue(Events.HAS_ALARM, event.getAlarms().isEmpty() ? 0 : 1)
.withValue(Events.HAS_ATTENDEE_DATA, event.getAttendees().isEmpty() ? 0 : 1) .withValue(Events.HAS_ATTENDEE_DATA, event.getAttendees().isEmpty() ? 0 : 1)
.withValue(Events.GUESTS_CAN_INVITE_OTHERS, 1) .withValue(Events.GUESTS_CAN_INVITE_OTHERS, 1)
.withValue(Events.GUESTS_CAN_MODIFY, 1) .withValue(Events.GUESTS_CAN_MODIFY, 1)
@ -650,17 +633,14 @@ public class LocalCalendar extends LocalCollection<Event> {
protected void removeDataRows(Resource resource) { protected void removeDataRows(Resource resource) {
Event event = (Event)resource; Event event = (Event)resource;
// delete exceptions // delete exceptions
pendingOperations.add(ContentProviderOperation.newDelete(entriesURI()) pendingOperations.add(ContentProviderOperation.newDelete(syncAdapterURI(Events.CONTENT_URI))
.withSelection(Events.ORIGINAL_ID + "=?", .withSelection(Events.ORIGINAL_ID + "=?", new String[] { String.valueOf(event.getLocalID())}).build());
new String[] { String.valueOf(event.getLocalID()) }).build());
// delete attendees // delete attendees
pendingOperations.add(ContentProviderOperation.newDelete(syncAdapterURI(Attendees.CONTENT_URI)) pendingOperations.add(ContentProviderOperation.newDelete(syncAdapterURI(Attendees.CONTENT_URI))
.withSelection(Attendees.EVENT_ID + "=?", .withSelection(Attendees.EVENT_ID + "=?", new String[] { String.valueOf(event.getLocalID()) }).build());
new String[] { String.valueOf(event.getLocalID()) }).build());
// delete reminders // delete reminders
pendingOperations.add(ContentProviderOperation.newDelete(syncAdapterURI(Reminders.CONTENT_URI)) pendingOperations.add(ContentProviderOperation.newDelete(syncAdapterURI(Reminders.CONTENT_URI))
.withSelection(Reminders.EVENT_ID + "=?", .withSelection(Reminders.EVENT_ID + "=?", new String[] { String.valueOf(event.getLocalID()) }).build());
new String[] { String.valueOf(event.getLocalID()) }).build());
} }