use of com.android.calendar.selectcalendars.SelectCalendarsSyncAdapter.CalendarRow in project Etar-Calendar by Etar-Group.
the class SelectCalendarsSyncFragment method onPause.
@Override
public void onPause() {
final ListAdapter listAdapter = getListAdapter();
if (listAdapter != null) {
HashMap<Long, CalendarRow> changes = ((SelectCalendarsSyncAdapter) listAdapter).getChanges();
if (changes != null && changes.size() > 0) {
for (CalendarRow row : changes.values()) {
if (row.synced == row.originalSynced) {
continue;
}
long id = row.id;
mService.cancelOperation((int) id);
// Use the full long id in case it makes a difference
Uri uri = ContentUris.withAppendedId(Calendars.CONTENT_URI, row.id);
ContentValues values = new ContentValues();
// Toggle the current setting
int synced = row.synced ? 1 : 0;
values.put(Calendars.SYNC_EVENTS, synced);
values.put(Calendars.VISIBLE, synced);
mService.startUpdate((int) id, null, uri, values, null, null, 0);
}
changes.clear();
}
}
getActivity().getContentResolver().unregisterContentObserver(mCalendarsObserver);
super.onPause();
}
Aggregations