Search in sources :

Example 1 with CalendarRow

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();
}
Also used : ContentValues(android.content.ContentValues) Uri(android.net.Uri) ListAdapter(android.widget.ListAdapter) CalendarRow(com.android.calendar.selectcalendars.SelectCalendarsSyncAdapter.CalendarRow)

Aggregations

ContentValues (android.content.ContentValues)1 Uri (android.net.Uri)1 ListAdapter (android.widget.ListAdapter)1 CalendarRow (com.android.calendar.selectcalendars.SelectCalendarsSyncAdapter.CalendarRow)1