Only clear dirty flag if we're sure the events were uploaded

* Add new/changed id's to a list, and only clear the dirty flag for
  list members
* The implementation is analogous to how deleted items are handled

Bug: 2492857
Change-Id: I3353100ab307a45a5ab684d402253eb589f22008
This commit is contained in:
Marc Blank 2010-03-08 21:48:27 -08:00
parent f448e01478
commit bd2473e818

View File

@ -104,7 +104,7 @@ public class CalendarSyncAdapter extends AbstractSyncAdapter {
private long mCalendarId = -1;
private ArrayList<Long> mDeletedIdList = new ArrayList<Long>();
private ArrayList<Long> mUpdatedIdList = new ArrayList<Long>();
private ArrayList<Long> mUploadedIdList = new ArrayList<Long>();
private ArrayList<Long> mSendCancelIdList = new ArrayList<Long>();
private String[] mCalendarIdArgument;
@ -836,18 +836,24 @@ public class CalendarSyncAdapter extends AbstractSyncAdapter {
mOps.execute();
if (mOps.mResults != null) {
// Clear dirty flags for Events sent to server
ContentValues cv = new ContentValues();
cv.put(Events._SYNC_DIRTY, 0);
mContentResolver.update(sEventsUri, cv, DIRTY_IN_CALENDAR,
new String[] {Long.toString(mCalendarId)});
// Send meeting cancelation notices
// Really delete the events...
for (long eventId: mDeletedIdList) {
mContentResolver.delete(ContentUris.withAppendedId(sEventsUri, eventId),
null, null);
// Clear dirty flags for updates sent to server
if (!mUploadedIdList.isEmpty()) {
ContentValues cv = new ContentValues();
cv.put(Events._SYNC_DIRTY, 0);
for (long eventId: mUploadedIdList) {
mContentResolver.update(ContentUris.withAppendedId(sEventsUri, eventId), cv,
null, null);
}
mUploadedIdList.clear();
}
// Delete events marked for deletion
if (!mDeletedIdList.isEmpty()) {
for (long eventId: mDeletedIdList) {
mContentResolver.delete(ContentUris.withAppendedId(sEventsUri, eventId),
null, null);
}
mDeletedIdList.clear();
}
mDeletedIdList.clear();
}
}
@ -1364,7 +1370,7 @@ public class CalendarSyncAdapter extends AbstractSyncAdapter {
}
s.end().end(); // ApplicationData & Change
mUpdatedIdList.add(entityValues.getAsLong(Events._ID));
mUploadedIdList.add(eventId);
// Send the meeting invite if there are attendees and we're the organizer
boolean selfOrganizer = organizerEmail.equalsIgnoreCase(mAccount.mEmailAddress);